diff --git a/Cargo.lock b/Cargo.lock index 9719584..fd23023 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,9 +21,9 @@ dependencies = [ [[package]] name = "actix-cors" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b340e9cfa5b08690aae90fb61beb44e9b06f44fe3d0f93781aaa58cfba86245e" +checksum = "0346d8c1f762b41b458ed3145eea914966bb9ad20b9be0d6d463b20d45586370" dependencies = [ "actix-utils", "actix-web", @@ -36,9 +36,9 @@ dependencies = [ [[package]] name = "actix-http" -version = "3.4.0" +version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92ef85799cba03f76e4f7c10f533e66d87c9a7e7055f3391f09000ad8351bc9" +checksum = "129d4c88e98860e1758c5de288d1632b07970a16d59bdf7b8d66053d582bb71f" dependencies = [ "actix-codec", "actix-rt", @@ -46,7 +46,7 @@ dependencies = [ "actix-utils", "ahash", "base64", - "bitflags 2.4.0", + "bitflags 2.4.1", "brotli", "bytes", "bytestring", @@ -80,14 +80,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.38", + "syn 2.0.43", ] [[package]] name = "actix-router" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66ff4d247d2b160861fa2866457e85706833527840e4133f8f49aa423a38799" +checksum = "d22475596539443685426b6bdadb926ad0ecaefdfc5fb05e5e3441f15463c511" dependencies = [ "bytestring", "http", @@ -118,7 +118,7 @@ dependencies = [ "futures-core", "futures-util", "mio", - "socket2 0.5.4", + "socket2", "tokio", "tracing", ] @@ -146,9 +146,9 @@ dependencies = [ [[package]] name = "actix-web" -version = "4.4.0" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4a5b5e29603ca8c94a77c65cf874718ceb60292c5a5c3e5f4ace041af462b9" +checksum = "e43428f3bf11dee6d166b00ec2df4e3aa8cc1606aaa0b7433c146852e2f4e03b" dependencies = [ "actix-codec", "actix-http", @@ -179,7 +179,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "smallvec", - "socket2 0.5.4", + "socket2", "time", "url", ] @@ -193,7 +193,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.43", ] [[package]] @@ -219,21 +219,22 @@ checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if 1.0.0", "getrandom", "once_cell", "version_check", + "zerocopy", ] [[package]] name = "aho-corasick" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -285,13 +286,13 @@ checksum = "a26fa4d7e3f2eebadf743988fc8aec9fa9a9e82611acafd77c1462ed6262440a" [[package]] name = "async-trait" -version = "0.1.73" +version = "0.1.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.43", ] [[package]] @@ -328,9 +329,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "bincode" @@ -349,9 +350,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "block-buffer" @@ -375,9 +376,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "2.5.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da74e2b81409b1b743f8f0c62cc6254afefb8b8e50bbfe3735550f7aeefa3448" +checksum = "4e2e4afe60d7dd600fdd3de8d0f08c2b7ec039712e3b6137ff98b7004e82de4f" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -403,9 +404,9 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "bytestring" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "238e4886760d98c4f899360c834fa93e62cf7f721ac3c2da375cbdf4b8679aae" +checksum = "74d80203ea6b29df88012294f62733de21cfeab47f17b41af3a38bc30a03ee72" dependencies = [ "bytes", ] @@ -442,8 +443,9 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits", + "serde", "wasm-bindgen", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -480,9 +482,9 @@ dependencies = [ [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -490,15 +492,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -512,11 +514,22 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "cron" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ff76b51e4c068c52bfd2866e1567bee7c567ae8f24ada09fd4307019e25eab7" +dependencies = [ + "chrono", + "nom", + "once_cell", +] + [[package]] name = "crossbeam-channel" -version = "0.5.8" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +checksum = "82a9b73a36529d9c47029b9fb3a6f0ea3cc916a261195352ba19e770fc1748b2" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -524,9 +537,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +checksum = "fca89a0e215bab21874660c67903c5f143333cab1da83d041c7ded6053774751" dependencies = [ "cfg-if 1.0.0", "crossbeam-epoch", @@ -535,22 +548,20 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.15" +version = "0.9.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +checksum = "0e3681d554572a651dda4186cd47240627c3d0114d45a95f6ad27f2f22e7548d" dependencies = [ "autocfg", "cfg-if 1.0.0", "crossbeam-utils", - "memoffset", - "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c" dependencies = [ "cfg-if 1.0.0", ] @@ -567,12 +578,12 @@ dependencies = [ [[package]] name = "ctor" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e366bff8cd32dd8754b0991fb66b279dc48f598c3a18914852a6673deef583" +checksum = "30d2b3721e861707777e3195b0158f950ae6dc4a27e4d02ff9f67e3eb3de199e" dependencies = [ "quote", - "syn 2.0.38", + "syn 2.0.43", ] [[package]] @@ -586,9 +597,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" [[package]] name = "deadpool" @@ -634,9 +645,12 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.8" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] [[package]] name = "derive_more" @@ -653,11 +667,11 @@ dependencies = [ [[package]] name = "diesel" -version = "2.1.3" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2268a214a6f118fce1838edba3d1561cf0e78d8de785475957a580a7f8c69d33" +checksum = "62c6fcf842f17f8c78ecf7c81d75c5ce84436b41ee07e03f490fbb5f5a8731d8" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "byteorder", "diesel_derives", "itoa", @@ -675,7 +689,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.43", ] [[package]] @@ -687,7 +701,7 @@ dependencies = [ "diesel_table_macro_syntax", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.43", ] [[package]] @@ -707,7 +721,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5" dependencies = [ - "syn 2.0.38", + "syn 2.0.43", ] [[package]] @@ -775,13 +789,12 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.4" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add4f07d43996f76ef320709726a556a9d4f965d9410d8d0271132d2f8293480" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "errno-dragonfly", "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -802,9 +815,9 @@ checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "flate2" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", "miniz_oxide", @@ -833,18 +846,18 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] [[package]] name = "futures" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -857,9 +870,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -867,15 +880,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -884,32 +897,32 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.43", ] [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-timer" @@ -919,9 +932,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -947,9 +960,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if 1.0.0", "libc", @@ -958,9 +971,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "guess_host_triple" @@ -976,9 +989,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.21" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" dependencies = [ "bytes", "fnv", @@ -986,7 +999,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap", "slab", "tokio", "tokio-util", @@ -995,15 +1008,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.14.1" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "headers" @@ -1059,11 +1066,17 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "http" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" dependencies = [ "bytes", "fnv", @@ -1072,9 +1085,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http", @@ -1095,9 +1108,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ "bytes", "futures-channel", @@ -1110,7 +1123,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.9", + "socket2", "tokio", "tower-service", "tracing", @@ -1132,16 +1145,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -1155,9 +1168,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1199,22 +1212,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - -[[package]] -name = "indexmap" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.1", + "hashbrown", ] [[package]] @@ -1236,30 +1239,30 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "jobserver" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" dependencies = [ "wasm-bindgen", ] @@ -1287,9 +1290,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.149" +version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "libflate" @@ -1313,15 +1316,15 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.8" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3852614a3bd9ca9804678ba6be5e3b8ce76dfc902cae004e3e0c44051b6e88db" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "local-channel" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a493488de5f18c8ffcba89eebb8532ffc562dc400490eb65b84893fae0b178" +checksum = "b6cbc85e69b8df4b8bb8b89ec634e7189099cea8927a276b7384ce5488e53ec8" dependencies = [ "futures-core", "futures-sink", @@ -1330,15 +1333,15 @@ dependencies = [ [[package]] name = "local-waker" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e34f76eb3611940e0e7d53a9aaa4e6a3151f69541a282fd0dad5571420c53ff1" +checksum = "4d873d7c67ce09b42110d801813efbc9364414e356be9935700d368351657487" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -1361,18 +1364,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "memoffset" -version = "0.9.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "migrations_internals" @@ -1422,6 +1416,12 @@ dependencies = [ "unicase", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -1433,14 +1433,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "log", "wasi", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1457,7 +1457,7 @@ dependencies = [ "log", "memchr", "mime", - "spin 0.9.8", + "spin", "version_check", ] @@ -1492,6 +1492,16 @@ dependencies = [ "void", ] +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "ntapi" version = "0.3.7" @@ -1513,9 +1523,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -1532,26 +1542,26 @@ dependencies = [ [[package]] name = "object" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "openssl" -version = "0.10.57" +version = "0.10.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" +checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "cfg-if 1.0.0", "foreign-types", "libc", @@ -1568,7 +1578,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.43", ] [[package]] @@ -1579,9 +1589,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.93" +version = "0.9.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" +checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7" dependencies = [ "cc", "libc", @@ -1607,15 +1617,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if 1.0.0", "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -1626,9 +1636,9 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" @@ -1647,7 +1657,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.43", ] [[package]] @@ -1664,15 +1674,21 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" [[package]] name = "platforms" -version = "3.1.2" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626dec3cac7cc0e1577a2ec3fc496277ec2baa084bebad95bb6fdbfae235f84c" + +[[package]] +name = "powerfmt" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4503fa043bf02cee09a9582e9554b4c6403b2ef55e4612e96561d294419429f8" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" @@ -1721,9 +1737,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.68" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b1106fec09662ec6dd98ccac0f81cef56984d0b49f75c92d8cbad76e20c005c" +checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" dependencies = [ "unicode-ident", ] @@ -1789,23 +1805,23 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.9.6" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.9", - "regex-syntax 0.7.5", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", ] [[package]] @@ -1819,13 +1835,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.9" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.5", + "regex-syntax 0.8.2", ] [[package]] @@ -1836,15 +1852,15 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.22" +version = "0.11.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" +checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" dependencies = [ "base64", "bytes", @@ -1886,17 +1902,16 @@ checksum = "4389f1d5789befaf6029ebd9f7dac4af7f7e3d61b69d4f30e2ac02b57e7712b0" [[package]] name = "ring" -version = "0.16.20" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", + "getrandom", "libc", - "once_cell", - "spin 0.5.2", + "spin", "untrusted", - "web-sys", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -1965,7 +1980,7 @@ dependencies = [ "proc-macro2", "quote", "rust-embed-utils", - "syn 2.0.38", + "syn 2.0.43", "walkdir", ] @@ -1996,22 +2011,22 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.17" +version = "0.38.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f25469e9ae0f3d0047ca8b93fc56843f38e6774f0914a107ff8b41be8be8e0b7" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" dependencies = [ - "bitflags 2.4.0", - "errno 0.3.4", + "bitflags 2.4.1", + "errno 0.3.8", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", "ring", @@ -2021,18 +2036,18 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ "base64", ] [[package]] name = "rustls-webpki" -version = "0.101.6" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ "ring", "untrusted", @@ -2040,9 +2055,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "same-file" @@ -2055,11 +2070,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -2076,9 +2091,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ "ring", "untrusted", @@ -2109,35 +2124,35 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.43", ] [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -2160,9 +2175,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" dependencies = [ "serde", ] @@ -2246,36 +2261,20 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" - -[[package]] -name = "socket2" -version = "0.4.9" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi", -] +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.48.0", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "spin" version = "0.9.8" @@ -2367,9 +2366,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53" dependencies = [ "proc-macro2", "quote", @@ -2414,15 +2413,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.8.0" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" dependencies = [ "cfg-if 1.0.0", "fastrand", "redox_syscall", "rustix", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -2466,12 +2465,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.29" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe" +checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" dependencies = [ "deranged", "itoa", + "powerfmt", "serde", "time-core", "time-macros", @@ -2485,9 +2485,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" dependencies = [ "time-core", ] @@ -2509,9 +2509,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.32.0" +version = "1.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" dependencies = [ "backtrace", "bytes", @@ -2521,20 +2521,20 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.4", + "socket2", "tokio-macros", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.43", ] [[package]] @@ -2582,9 +2582,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -2608,9 +2608,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] @@ -2621,7 +2621,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.2", + "indexmap", "serde", "serde_spanned", "toml_datetime", @@ -2636,11 +2636,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if 1.0.0", "log", "pin-project-lite", "tracing-attributes", @@ -2649,31 +2648,32 @@ dependencies = [ [[package]] name = "tracing-appender" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d48f71a791638519505cefafe162606f706c25592e4bde4d97600c0195312e" +checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" dependencies = [ "crossbeam-channel", + "thiserror", "time", "tracing-subscriber", ] [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.43", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", @@ -2681,20 +2681,20 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] [[package]] name = "tracing-subscriber" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", @@ -2710,9 +2710,9 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tungstenite" @@ -2758,6 +2758,7 @@ dependencies = [ "anyhow", "bincode", "chrono", + "cron", "daemonize", "deadpool-diesel", "diesel", @@ -2765,6 +2766,7 @@ dependencies = [ "dotenv", "envy", "guess_host_triple", + "hex", "lazy_static", "libc", "nix", @@ -2853,9 +2855,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" [[package]] name = "unicode-ident" @@ -2886,15 +2888,15 @@ checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "untrusted" -version = "0.7.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -2909,9 +2911,9 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" [[package]] name = "uuid" -version = "1.4.1" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" dependencies = [ "getrandom", "serde", @@ -3006,9 +3008,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -3016,24 +3018,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.43", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -3043,9 +3045,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3053,28 +3055,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.43", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" dependencies = [ "js-sys", "wasm-bindgen", @@ -3112,12 +3114,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets", + "windows-targets 0.52.0", ] [[package]] @@ -3126,7 +3128,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -3135,13 +3146,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -3150,47 +3176,89 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winnow" -version = "0.5.16" +version = "0.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" +checksum = "97a4882e6b134d6c28953a387571f1acdd3496830d5e36c5e3a1075580ea641c" dependencies = [ "memchr", ] @@ -3202,35 +3270,53 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ "cfg-if 1.0.0", - "windows-sys", + "windows-sys 0.48.0", +] + +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.43", ] [[package]] name = "zstd" -version = "0.12.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" +checksum = "bffb3309596d527cfcba7dfc6ed6052f1d39dfbd7c867aa2e865e4a449c10110" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "6.0.6" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" +checksum = "43747c7422e2924c11144d5229878b98180ef8b06cca4ab5af37afc8a8d8ea3e" dependencies = [ - "libc", "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.8+zstd.1.5.5" +version = "2.0.9+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" +checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" dependencies = [ "cc", - "libc", "pkg-config", ] diff --git a/bin/u_agent/src/lib.rs b/bin/u_agent/src/lib.rs index faa3d3f..2680b8e 100644 --- a/bin/u_agent/src/lib.rs +++ b/bin/u_agent/src/lib.rs @@ -1,110 +1,102 @@ #[macro_use] extern crate log; -use std::process::exit; use tokio::runtime::Builder; use tokio::time::{sleep, Duration}; +use u_lib::models::PreparedJob; +use u_lib::scheduler::SCHEDULER; +use u_lib::u_runner::{IdentifiableFuture, URunner}; use u_lib::{ api::HttpClient, cache::JobCache, config::{get_self_id, EndpointsEnv, AGENT_ITERATION_INTERVAL}, error::ErrChan, - executor, - jobs::AnonymousJobBatch, logging::init_logger, messaging::Reportable, models::AssignedJobById, }; -async fn process_request(jobs: Vec, client: &HttpClient) { - if !jobs.is_empty() { - for jr in &jobs { - if !JobCache::contains(jr.job_id) { - info!("Fetching job: {}", &jr.job_id); - let mut fetched_job = loop { - //todo: use payload cache - match client.get_full_job(jr.job_id).await { - Ok(result) => break result, - Err(err) => { - debug!("{:?} \nretrying...", err); - sleep(AGENT_ITERATION_INTERVAL).await; - } - } - }; - if let Some(payload) = &mut fetched_job.payload { - if let Err(e) = payload.maybe_split_payload() { - ErrChan::send(e, "pld").await; +async fn process_request(assigned_jobs: Vec, client: &HttpClient) { + for asgn_job in assigned_jobs { + if !JobCache::contains(asgn_job.job_id) { + info!("Fetching job: {}", &asgn_job.job_id); + let mut fetched_job = loop { + //todo: use payload cache + match client.get_full_job(asgn_job.job_id).await { + Ok(result) => break result, + Err(err) => { + debug!("{:?} \nretrying...", err); + sleep(AGENT_ITERATION_INTERVAL).await; } } - JobCache::insert(fetched_job); + }; + if let Some(payload) = &mut fetched_job.payload { + if let Err(e) = payload.maybe_split_payload() { + ErrChan::send(e, "pay").await; + continue; + } } + JobCache::insert(fetched_job); } - info!( - "Scheduling jobs: {}", - jobs.iter() - .map(|j| j.job_id.to_string()) - .collect::>() - .join(", ") - ); - let meta_with_ids = jobs - .into_iter() - .map(|job| { - let meta = JobCache::get(job.job_id).unwrap().clone(); - (meta, job) - }) - .collect::>(); + let job = match JobCache::get(asgn_job.job_id).as_deref() { + Some(job) => job.clone(), + None => continue, + }; - AnonymousJobBatch::from_meta_with_id(meta_with_ids) - .spawn() - .await; - } -} + info!("Scheduling job {}", job.meta.id.to_string()); -async fn error_reporting(client: HttpClient) -> ! { - loop { - match ErrChan::recv().await { - Some(err) => { - 'retry: for _ in 0..3 { - match client.report([Reportable::Error(err.clone())]).await { - Ok(_) => break 'retry, - Err(e) => { - debug!("Reporting error: {:?}", e); - sleep(Duration::from_secs(10)).await; + let schedule = match job.meta.schedule.clone() { + Some(sched) => { + if sched.is_empty() { + None + } else { + match sched.as_str().try_into() { + Ok(s) => Some(s), + Err(err) => { + ErrChan::send(err, "sch").await; + continue; } } } } - None => sleep(Duration::from_secs(3)).await, - } + None => None, + }; + SCHEDULER + .add_job(schedule, PreparedJob { job, ids: asgn_job }) + .await; + } +} + +async fn error_reporting(client: HttpClient) { + while let Some(err) = ErrChan::recv().await { + let _ = client.report([Reportable::Error(err.clone())]).await; } } -async fn agent_loop(client: HttpClient) -> ! { +async fn agent_loop(client: HttpClient) { let self_id = get_self_id(); - loop { - match client.get_personal_jobs(self_id).await { - Ok(jobs) => { - process_request(jobs, &client).await; - } - Err(err) => ErrChan::send(err, "processing").await, + + match client.get_personal_jobs(self_id).await { + Ok(jobs) => { + process_request(jobs, &client).await; } + Err(err) => ErrChan::send(err, "pro").await, + } - let result: Vec = executor::pop_completed() - .await - .into_iter() - .map(|result| match result { - Ok(r) => Reportable::Assigned(r), - Err(e) => Reportable::Error(e), - }) - .collect(); - - if !result.is_empty() { - if let Err(err) = client.report(result).await { - ErrChan::send(err, "report").await; - } + let result: Vec = URunner::pop_completed() + .await + .into_iter() + .map(|result| match result { + Ok(r) => Reportable::Assigned(r), + Err(e) => Reportable::Error(e), + }) + .collect(); + + if !result.is_empty() { + if let Err(err) = client.report(result).await { + ErrChan::send(err, "rep").await; } - sleep(AGENT_ITERATION_INTERVAL).await; } } @@ -134,15 +126,42 @@ pub fn run_forever() -> ! { .build() .unwrap() .block_on(async { - match HttpClient::new(&env.u_server, None).await { - Ok(client) => { - tokio::spawn(error_reporting(client.clone())); - agent_loop(client).await - } - Err(e) => { - error!("client init failed: {}", e); - exit(7) // todo: wtf? + let client = loop { + match HttpClient::new(&env.u_server, None).await { + Ok(client) => break client, + Err(e) => { + error!("client init failed: {}", e); + sleep(Duration::from_secs(5)).await; + continue; + } } + }; + { + let client = client.clone(); + SCHEDULER + .add_job(Some("*/3 * * * * * *".try_into().unwrap()), move || { + let client = client.clone(); + + IdentifiableFuture::from_fut_with_ident("error_reporting", async move { + error_reporting(client.clone()).await + }) + }) + .await; + } + + { + let client = client.clone(); + SCHEDULER + .add_job(Some("*/3 * * * * * *".try_into().unwrap()), move || { + let client = client.clone(); + + IdentifiableFuture::from_fut_with_ident("agent_loop", async move { + agent_loop(client).await + }) + }) + .await; } + + SCHEDULER.start_blocking().await }) } diff --git a/bin/u_panel/src/gui/fe/src/app/app.module.ts b/bin/u_panel/src/gui/fe/src/app/app.module.ts index 5925085..e8831c3 100644 --- a/bin/u_panel/src/gui/fe/src/app/app.module.ts +++ b/bin/u_panel/src/gui/fe/src/app/app.module.ts @@ -12,6 +12,7 @@ import { MatSelectModule } from '@angular/material/select'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import { HttpClientModule } from '@angular/common/http'; import { MatDialogModule } from '@angular/material/dialog'; +import { MatGridListModule } from '@angular/material/grid-list'; import { MatIconModule } from '@angular/material/icon'; import { FormsModule } from '@angular/forms'; import { AgentComponent, JobComponent, ResultComponent, PayloadComponent } from './components/tables'; @@ -62,6 +63,7 @@ import { NewPayloadDialogComponent } from './components/dialogs/new-payload-dial MatSnackBarModule, MatSelectModule, MatListModule, + MatGridListModule, FormsModule, BrowserAnimationsModule ], diff --git a/bin/u_panel/src/gui/fe/src/app/components/dialogs/base-info-dialog.component.less b/bin/u_panel/src/gui/fe/src/app/components/dialogs/base-info-dialog.component.less index 23b8bc5..f5e1d33 100644 --- a/bin/u_panel/src/gui/fe/src/app/components/dialogs/base-info-dialog.component.less +++ b/bin/u_panel/src/gui/fe/src/app/components/dialogs/base-info-dialog.component.less @@ -11,4 +11,8 @@ div.info-dialog-forms-box-smol { width: 30%; float: left; margin-right: 10px; +} + +.code { + font-family: "Roboto Mono", monospace; } \ No newline at end of file diff --git a/bin/u_panel/src/gui/fe/src/app/components/payload-overview/payload-overview.component.html b/bin/u_panel/src/gui/fe/src/app/components/payload-overview/payload-overview.component.html index 4e4fc7c..bf929cb 100644 --- a/bin/u_panel/src/gui/fe/src/app/components/payload-overview/payload-overview.component.html +++ b/bin/u_panel/src/gui/fe/src/app/components/payload-overview/payload-overview.component.html @@ -1,6 +1,7 @@ - + Payload data - \ No newline at end of file diff --git a/bin/u_panel/src/gui/fe/src/index.html b/bin/u_panel/src/gui/fe/src/index.html index e299aec..33299f4 100644 --- a/bin/u_panel/src/gui/fe/src/index.html +++ b/bin/u_panel/src/gui/fe/src/index.html @@ -7,7 +7,7 @@ - + diff --git a/bin/u_server/src/handlers.rs b/bin/u_server/src/handlers.rs index e1a8ec7..b84ec2c 100644 --- a/bin/u_server/src/handlers.rs +++ b/bin/u_server/src/handlers.rs @@ -249,7 +249,10 @@ impl Endpoints { Reportable::Assigned(mut result) => { let result_agent_id = &result.agent_id; if agent_id != *result_agent_id { - warn!("Agent ids are not equal! actual id: {agent_id}, id from job: {result_agent_id}"); + warn!( + "Agent ids are not equal! actual id: {agent_id}, \ + id from job: {result_agent_id}" + ); continue; } result.touch(); @@ -260,26 +263,23 @@ impl Endpoints { JobType::Init => { result.state = JobState::Finished; - match &result.result { - Some(rbytes) => { - let mut agent: Agent = match serde_json::from_slice(&rbytes) { - Ok(a) => a, - Err(e) => { - error!("Error deserializing agent data from {agent_id}: {e}"); - continue; - } - }; - agent.state = AgentState::Active; - db.upsert_agent(&agent)?; - } - None => error!("Empty agent data"), - }}, - JobType::Shell => { - result.state = JobState::Finished - }, - JobType::Service => (), - JobType::Terminate => todo!(), - JobType::Update => todo!(), + let mut agent: Agent = match result.deserialize() { + Ok(a) => a, + Err(e) => { + error!( + "Error deserializing agent \ + data from {agent_id}: {e}" + ); + continue; + } + }; + agent.state = AgentState::Active; + db.upsert_agent(&agent)?; + } + JobType::Shell => result.state = JobState::Finished, + JobType::Stats => result.state = JobState::Finished, + JobType::Terminate => (), + JobType::Update => (), } db.update_result(&result)?; } @@ -287,7 +287,8 @@ impl Endpoints { error!("agent {agent_id} reported: {e}"); } Reportable::Dummy => (), - }} + } + } Ok(()) }) .await diff --git a/integration-tests/docker-compose.yml b/integration-tests/docker-compose.yml index 093312d..d7e937e 100644 --- a/integration-tests/docker-compose.yml +++ b/integration-tests/docker-compose.yml @@ -40,7 +40,7 @@ services: networks: - u_net ports: - - 54321:5432 + - 5432:5432 env_file: - ../.env - ../.env.private diff --git a/integration-tests/tests/fixtures/agent.rs b/integration-tests/tests/fixtures/agent.rs index db67502..07d912c 100644 --- a/integration-tests/tests/fixtures/agent.rs +++ b/integration-tests/tests/fixtures/agent.rs @@ -25,7 +25,7 @@ pub fn registered_agent(client: &HttpClient) -> RegisteredAgent { assert_eq!(job.meta.alias, Some("agent_hello".to_string())); - let mut agent_data = AssignedJob::from((&job.meta, resp)); + let mut agent_data = AssignedJob::from(&PreparedJob { job, ids: resp }); agent_data.set_result(&agent); client diff --git a/integration-tests/tests/helpers/panel.rs b/integration-tests/tests/helpers/panel.rs index f33085b..0423986 100644 --- a/integration-tests/tests/helpers/panel.rs +++ b/integration-tests/tests/helpers/panel.rs @@ -80,7 +80,7 @@ pub trait IntoArgs { impl IntoArgs for String { fn into_args(self) -> Vec { - >::as_ref(&self).into_args() + self.as_str().into_args() } fn display(&self) -> String { diff --git a/integration-tests/tests/integration_tests/behaviour.rs b/integration-tests/tests/integration_tests/behaviour.rs index cea4f85..f4a3b2d 100644 --- a/integration-tests/tests/integration_tests/behaviour.rs +++ b/integration-tests/tests/integration_tests/behaviour.rs @@ -16,7 +16,7 @@ async fn registration(registered_agent: &RegisteredAgent) { } #[tokio::test] -async fn setup_tasks() { +async fn setup_jobs() { let agents: Vec = Panel::check_output("agents read"); let agent_id = agents[0].id; let job_alias = "passwd_contents"; @@ -88,3 +88,52 @@ async fn large_payload() { }) .await; } + +#[tokio::test] +async fn gather_stats() { + let agent = &Panel::check_output::>("agents read")[0]; + let job_alias = "stats"; + let job = RawJob::default() + .with_type(JobType::Stats) + .with_alias(job_alias) + .with_target_platforms(&agent.platform) + .try_into_job() + .unwrap(); + let job_id = job.meta.id; + let agent_id = agent.id; + + Panel::check_status(["jobs", "create", &to_string(&RawJob::from(job)).unwrap()]); + + let assigned = AssignedJobById { + agent_id, + job_id, + ..Default::default() + }; + Panel::check_status(["map", "create", &to_string(&[assigned]).unwrap()]); + + let result = retry_with_interval(5, AGENT_ITERATION_INTERVAL, || { + let result = + Panel::check_output::>(["map", "read", &job_id.to_string()]).remove(0); + if result.state == JobState::Finished { + Ok(result) + } else { + Err("job didn't finish") + } + }) + .await; + + let stats = result.deserialize::().unwrap(); + + assert_eq!(stats.agent_id, agent_id); + assert!(stats.cached_jobs.contains(&job_id)); + assert!(stats + .scheduled_jobs + .iter() + .find(|j| j.job_ident == "error_reporting") + .is_some()); + assert!(stats + .scheduled_jobs + .iter() + .find(|j| j.job_ident == "agent_loop") + .is_some()) +} diff --git a/lib/u_lib/Cargo.toml b/lib/u_lib/Cargo.toml index 8cf77d7..191f52f 100644 --- a/lib/u_lib/Cargo.toml +++ b/lib/u_lib/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] anyhow = { workspace = true } -chrono = "0.4.19" +chrono = { version = "0.4.19", features = ["serde"] } diesel = { workspace = true, optional = true } diesel-derive-enum = { version = "2.0.0", features = ["postgres"], optional = true } deadpool-diesel = { workspace = true, optional = true } @@ -33,6 +33,8 @@ uuid = { workspace = true, features = ["serde", "v4"] } parking_lot = "0.12.1" bincode = "1.3.3" sha3 = "0.10.7" +cron = "0.12.0" +hex = "0.4.3" [target.'cfg(unix)'.dependencies] daemonize = "0.5" diff --git a/lib/u_lib/src/api.rs b/lib/u_lib/src/api.rs index e0e9771..48ac150 100644 --- a/lib/u_lib/src/api.rs +++ b/lib/u_lib/src/api.rs @@ -233,11 +233,8 @@ impl HttpClient { &self, assigned: impl IntoIterator, ) -> Result { - self.req_with_payload( - format!("assign_jobs"), - &assigned.into_iter().collect::>(), - ) - .await + self.req_with_payload("assign_jobs", &assigned.into_iter().collect::>()) + .await } /// get jobs for any agent by job_id, agent_id or result_id diff --git a/lib/u_lib/src/cache.rs b/lib/u_lib/src/cache.rs index 3031b0f..ef88ce1 100644 --- a/lib/u_lib/src/cache.rs +++ b/lib/u_lib/src/cache.rs @@ -22,7 +22,7 @@ impl JobCache { JOB_CACHE.read().contains_key(&id) } - pub fn get<'jh>(id: Id) -> Option> { + pub fn get(id: Id) -> Option { if !Self::contains(id) { return None; } @@ -33,11 +33,15 @@ impl JobCache { pub fn remove(id: Id) { JOB_CACHE.write().remove(&id); } + + pub fn stats() -> Vec { + JOB_CACHE.read().values().map(|job| job.meta.id).collect() + } } -pub struct JobCacheHolder<'jh>(pub RwLockReadGuard<'jh, Cache>, pub Id); +pub struct JobCacheHolder(pub RwLockReadGuard<'static, Cache>, pub Id); -impl<'jh> Deref for JobCacheHolder<'jh> { +impl Deref for JobCacheHolder { type Target = Val; fn deref(&self) -> &Self::Target { diff --git a/lib/u_lib/src/executor.rs b/lib/u_lib/src/executor.rs deleted file mode 100644 index 929011b..0000000 --- a/lib/u_lib/src/executor.rs +++ /dev/null @@ -1,167 +0,0 @@ -use crate::{models::AssignedJob, UResult}; -use lazy_static::lazy_static; -use std::collections::HashMap; -use std::future::Future; -use std::pin::Pin; -use tokio::{ - runtime::Handle, - sync::mpsc::{channel, Receiver, Sender}, - sync::Mutex, - task::{spawn, spawn_blocking, JoinHandle}, -}; -use uuid::Uuid; - -pub type ExecResult = UResult; -type BoxFuture<'a, T> = Pin + Send + 'a>>; - -lazy_static! { - static ref FUT_RESULTS: Mutex> = Mutex::new(HashMap::new()); - static ref FUT_CHANNEL: (Sender, Mutex>) = { - spawn(init_receiver()); - let (tx, rx) = channel(100); - (tx, Mutex::new(rx)) - }; -} - -struct JoinInfo { - handle: JoinHandle>, - completed: bool, - collectable: bool, // indicates if future can be popped from pool via pop_task_if_completed -} - -impl JoinInfo { - async fn wait_result(self) -> ExecResult { - self.handle.await.unwrap().await.unwrap() - } -} - -fn get_sender() -> Sender { - FUT_CHANNEL.0.clone() -} - -pub struct Waiter { - tasks: Vec>, - fids: Vec, -} - -impl Waiter { - pub fn new() -> Self { - Self { - tasks: vec![], - fids: vec![], - } - } - - pub fn push(&mut self, task: impl Future + Send + 'static) { - self.tasks.push(Box::pin(task)); - } - - /// Spawn prepared tasks - pub async fn spawn(mut self) -> Self { - let collectable = true; //TODO: self.tasks.len() != 1; - for f in self.tasks.drain(..) { - let handle = Handle::current(); - let fid = Uuid::new_v4(); - let tx = get_sender(); - self.fids.push(fid); - let task_wrapper = async move { - debug!("inside wrapper (started): {}", fid); - let result = f.await; - tx.send(fid).await.unwrap(); - result - }; - let handler = JoinInfo { - handle: spawn_blocking(move || handle.spawn(task_wrapper)), - completed: false, - collectable, - }; - FUT_RESULTS.lock().await.insert(fid, handler); - } - self - } - - /// Wait until a bunch of tasks is finished. - /// NOT GUARANTEED that all tasks will be returned due to - /// possibility to pop them in other places - pub async fn wait(self) -> Vec { - let mut result = vec![]; - for fid in self.fids { - if let Some(task) = pop_task(fid).await { - result.push(task.wait_result().await); - } - } - result - } -} - -async fn init_receiver() { - while let Some(fid) = FUT_CHANNEL.1.lock().await.recv().await { - let mut lock = FUT_RESULTS.lock().await; - if let Some(j) = lock.get_mut(&fid) { - j.completed = true; - } - } -} - -async fn pop_task(fid: Uuid) -> Option { - FUT_RESULTS.lock().await.remove(&fid) -} - -pub async fn pop_task_if_completed(fid: Uuid) -> Option { - let &JoinInfo { - handle: _, - collectable, - completed, - } = match FUT_RESULTS.lock().await.get(&fid) { - Some(t) => t, - None => return None, - }; - if collectable && completed { - let task = pop_task(fid).await.unwrap(); - Some(task.wait_result().await) - } else { - None - } -} - -pub async fn pop_completed() -> Vec { - let mut completed: Vec = vec![]; - let fids = FUT_RESULTS - .lock() - .await - .keys() - .copied() - .collect::>(); - for fid in fids { - if let Some(r) = pop_task_if_completed(fid).await { - completed.push(r) - } - } - completed -} - -#[cfg(test)] -mod tests { - use super::*; - - // WTF - // WTF - // WTF - #[tokio::test] - async fn test_spawn() { - use std::sync::Arc; - - let val = Arc::new(Mutex::new(0)); - let t = { - let v = val.clone(); - spawn(async move { - *v.lock().await = 5; - }) - }; - assert_eq!(0, *val.lock().await); - spawn(async {}).await.unwrap(); - assert_eq!(5, *val.lock().await); - t.await.unwrap(); - assert_eq!(5, *val.lock().await); - } -} diff --git a/lib/u_lib/src/jobs.rs b/lib/u_lib/src/jobs.rs index 899aa67..d122566 100644 --- a/lib/u_lib/src/jobs.rs +++ b/lib/u_lib/src/jobs.rs @@ -1,63 +1,67 @@ use crate::{ + cache::JobCache, combined_result::CombinedResult, - executor::{ExecResult, Waiter}, - models::{Agent, AssignedJob, AssignedJobById, Job, JobType, RawJob}, + config::get_self_id, + models::{Agent, AssignedJob, AssignedJobById, Job, JobType, PreparedJob, RawJob, Stats}, proc_output::ProcOutput, + scheduler::SCHEDULER, + u_runner::{ExecResult, IdentifiableFuture, URunner}, + ufs, }; use std::collections::HashMap; use std::process::exit; use tokio::process::Command; pub struct AnonymousJobBatch { - waiter: Waiter, + runner: URunner, is_running: bool, } impl AnonymousJobBatch { - pub fn from_meta_with_id(jobs: impl IntoIterator) -> Self { - let mut waiter = Waiter::new(); - for (job, ids) in jobs { - waiter.push(run_assigned_job(job, ids)); + pub fn from_prepared_jobs(jobs: impl IntoIterator) -> Self { + let mut runner = URunner::new(); + for job in jobs { + runner.push(IdentifiableFuture::from_fut_with_ident( + job.ids.id, + run_assigned_job(job), + )); } Self { - waiter, + runner, is_running: false, } } - pub fn from_meta(jobs: impl IntoIterator) -> Self { + pub fn from_jobs(jobs: impl IntoIterator) -> Self { let jobs_ids: Vec<_> = jobs .into_iter() - .map(|job| { - let job_id = job.meta.id; - ( - job, - AssignedJobById { - job_id, - ..Default::default() - }, - ) + .map(|job| PreparedJob { + ids: AssignedJobById { + job_id: job.meta.id, + ..Default::default() + }, + job, }) .collect(); - AnonymousJobBatch::from_meta_with_id(jobs_ids) + AnonymousJobBatch::from_prepared_jobs(jobs_ids) } /// Spawn jobs pub async fn spawn(mut self) -> Self { debug!("spawning jobs"); - self.waiter = self.waiter.spawn().await; + self.runner = self.runner.spawn().await; self.is_running = true; self } /// Spawn jobs and wait for result pub async fn wait(self) -> Vec { - let waiter = if !self.is_running { - self.spawn().await.waiter + let runner = if !self.is_running { + self.spawn().await.runner } else { - self.waiter + self.runner }; - waiter.wait().await + runner.wait().await } /// Spawn one job and wait for result @@ -102,7 +106,7 @@ impl NamedJobBatch { .map(|job| (job.meta.alias.clone().unwrap(), job)) .unzip(); Self { - runner: Some(AnonymousJobBatch::from_meta(jobs)), + runner: Some(AnonymousJobBatch::from_jobs(jobs)), job_names, results: HashMap::new(), } @@ -132,9 +136,9 @@ impl NamedJobBatch { } } -pub async fn run_assigned_job(job: Job, ids: AssignedJobById) -> ExecResult { - let Job { meta, payload } = job; - let mut result = AssignedJob::from((&meta, ids)); +pub async fn run_assigned_job(prepared_job: PreparedJob) -> ExecResult { + let mut result = AssignedJob::from(&prepared_job); + let Job { meta, payload } = prepared_job.job; match meta.exec_type { JobType::Shell => { let (argv, _prepared_payload) = { @@ -150,7 +154,11 @@ pub async fn run_assigned_job(job: Job, ids: AssignedJobById) -> ExecResult { let mut split_cmd = shlex::split(&argv).unwrap().into_iter(); let cmd = split_cmd.nth(0).unwrap(); let args = split_cmd.collect::>(); - let cmd_result = Command::new(cmd).args(args).output().await; + let cmd_result = Command::new(cmd) + .kill_on_drop(true) + .args(args) + .output() + .await; let (data, retcode) = match cmd_result { Ok(output) => ( ProcOutput::from_output(&output).into_vec(), @@ -172,8 +180,18 @@ pub async fn run_assigned_job(job: Job, ids: AssignedJobById) -> ExecResult { result.set_result(&agent); result.retcode = Some(0); } - JobType::Service => todo!(), - JobType::Update => todo!(), + JobType::Stats => { + let stats = Stats { + agent_id: get_self_id(), + running_jobs: URunner::stats().await, + scheduled_jobs: SCHEDULER.stats().await, + cached_jobs: JobCache::stats(), + cached_payloads: ufs::stats(), + }; + result.set_result(&stats); + result.retcode = Some(0) + } + JobType::Update => (), JobType::Terminate => exit(0), }; Ok(result) @@ -197,7 +215,7 @@ mod tests { let sleep_jobs = (0..50).map(|_| job.clone()).collect::>(); let now = SystemTime::now(); - AnonymousJobBatch::from_meta(sleep_jobs).wait().await; + AnonymousJobBatch::from_jobs(sleep_jobs).wait().await; assert!(now.elapsed().unwrap().as_secs() < SLEEP_SECS + 2) } @@ -236,7 +254,7 @@ mod tests { raw_job = raw_job.with_raw_payload(p); } let job = raw_job.try_into_job().unwrap(); - let result = AnonymousJobBatch::from_meta([job]) + let result = AnonymousJobBatch::from_jobs([job]) .wait_one() .await .unwrap(); @@ -250,8 +268,8 @@ mod tests { const SLEEP_SECS: u64 = 1; let now = SystemTime::now(); let longest_job = RawJob::from_shell(format!("sleep {}", SLEEP_SECS)).unwrap(); - let longest_job = AnonymousJobBatch::from_meta([longest_job]).spawn().await; - let ls = AnonymousJobBatch::from_meta([RawJob::from_shell("ls").unwrap()]) + let longest_job = AnonymousJobBatch::from_jobs([longest_job]).spawn().await; + let ls = AnonymousJobBatch::from_jobs([RawJob::from_shell("ls").unwrap()]) .wait_one() .await .unwrap(); @@ -264,7 +282,7 @@ mod tests { .map(|f| RawJob::from_shell(format!("ls {f}")).unwrap()) .collect::>(); - let ls_subfolders = AnonymousJobBatch::from_meta(subfolders_jobs).wait().await; + let ls_subfolders = AnonymousJobBatch::from_jobs(subfolders_jobs).wait().await; for result in ls_subfolders { assert_eq!(result.unwrap().retcode.unwrap(), 0); @@ -295,7 +313,7 @@ mod tests { #[tokio::test] async fn test_failing_shell_job() -> TestResult { let job = RawJob::from_shell("lol_kek_puk").unwrap(); - let job_result = AnonymousJobBatch::from_meta([job]) + let job_result = AnonymousJobBatch::from_jobs([job]) .wait_one() .await .unwrap(); diff --git a/lib/u_lib/src/lib.rs b/lib/u_lib/src/lib.rs index 52ada1b..59c30f5 100644 --- a/lib/u_lib/src/lib.rs +++ b/lib/u_lib/src/lib.rs @@ -7,7 +7,6 @@ pub mod conv; #[cfg(feature = "server")] pub mod db; pub mod error; -pub mod executor; pub mod jobs; pub mod logging; pub mod messaging; @@ -15,7 +14,9 @@ pub mod misc; pub mod models; pub mod platform; pub mod proc_output; +pub mod scheduler; pub mod types; +pub mod u_runner; pub mod ufs; #[cfg(unix)] pub mod unix; diff --git a/lib/u_lib/src/models/agent.rs b/lib/u_lib/src/models/agent.rs index a05e74d..efe8afa 100644 --- a/lib/u_lib/src/models/agent.rs +++ b/lib/u_lib/src/models/agent.rs @@ -13,8 +13,8 @@ mod server { use self::server::*; use crate::{ - config::get_self_id, conv::systime_to_string, executor::ExecResult, jobs::NamedJobBatch, - platform, types::Id, + config::get_self_id, conv::systime_to_string, jobs::NamedJobBatch, platform, types::Id, + u_runner::ExecResult, }; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Display)] diff --git a/lib/u_lib/src/models/jobs/assigned.rs b/lib/u_lib/src/models/jobs/assigned.rs index a7caf20..93f0a68 100644 --- a/lib/u_lib/src/models/jobs/assigned.rs +++ b/lib/u_lib/src/models/jobs/assigned.rs @@ -1,16 +1,19 @@ -use super::{JobMeta, JobState, JobType}; +use super::{JobState, JobType}; #[cfg(feature = "server")] use crate::models::schema::*; use crate::{ config::get_self_id, conv::{bytes_to_string_truncated, systime_to_string}, + models::Job, types::Id, + UError, UResult, }; #[cfg(feature = "server")] use diesel::{Identifiable, Insertable, Queryable}; -use serde::{Deserialize, Serialize}; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; use std::{borrow::Cow, fmt::Debug, time::SystemTime}; +/// A job assigned to some agents, stores execution state and result #[derive(Serialize, Deserialize, Clone, PartialEq)] #[cfg_attr( feature = "server", @@ -53,6 +56,13 @@ impl Debug for AssignedJob { } } +#[derive(Debug, Clone)] +pub struct PreparedJob { + pub job: Job, + pub ids: AssignedJobById, +} + +/// Lightweight linking struct between agent job and assigned job #[derive(Serialize, Deserialize, Clone, Copy, Debug)] pub struct AssignedJobById { pub agent_id: Id, @@ -61,20 +71,20 @@ pub struct AssignedJobById { pub job_id: Id, } -impl From<(&JobMeta, AssignedJobById)> for AssignedJob { - fn from((job, ids): (&JobMeta, AssignedJobById)) -> Self { +impl From<&PreparedJob> for AssignedJob { + fn from(prep_job: &PreparedJob) -> Self { let AssignedJobById { agent_id, id, job_id, - } = ids; + } = prep_job.ids; AssignedJob { id, agent_id, job_id, - alias: job.alias.clone(), - exec_type: job.exec_type, + alias: prep_job.job.meta.alias.clone(), + exec_type: prep_job.job.meta.exec_type, ..Default::default() } } @@ -136,7 +146,14 @@ impl AssignedJob { String::from_utf8_lossy(self.to_raw_result()) } - pub fn set_result(&mut self, result: &S) { + pub fn deserialize(&self) -> UResult { + let body = self.result.as_deref().unwrap_or_default(); + serde_json::from_slice(body).map_err(|e| { + UError::DeserializeError(e.to_string(), bytes_to_string_truncated(body, 1024)) + }) + } + + pub fn set_result(&mut self, result: &impl Serialize) { self.result = Some(serde_json::to_vec(result).unwrap()); } diff --git a/lib/u_lib/src/models/jobs/meta.rs b/lib/u_lib/src/models/jobs/meta.rs index 10a8026..a450f97 100644 --- a/lib/u_lib/src/models/jobs/meta.rs +++ b/lib/u_lib/src/models/jobs/meta.rs @@ -7,6 +7,7 @@ use crate::models::Payload; use crate::platform; use crate::types::Id; use crate::{UError, UResult}; +use cron::Schedule; #[cfg(feature = "server")] use diesel::{Identifiable, Insertable, Queryable}; use serde::{Deserialize, Serialize}; @@ -102,7 +103,7 @@ impl JobMeta { return Err(mk_err("Argv contains no executable placeholder")); } - if self.argv.contains("{}") && self.payload_id.is_none() { + if self.payload_id.is_none() && self.argv.contains("{}") { return Err(mk_err( "No payload provided, but argv contains executable placeholder", )); @@ -119,16 +120,24 @@ impl JobMeta { ))); } + if let Some(schedule) = &self.schedule { + Schedule::try_from(schedule.as_str()) + .map_err(|e| mk_err(format!("bad schedule: {e}")))?; + } + Ok(self) } } +/// An abstract valid-constructed job that can be assigned to any agent. +/// Contains job meta and payload meta #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct Job { pub meta: JobMeta, pub payload: Option, } +/// Job that has only been deserialized without checks #[derive(Serialize, Deserialize, Clone, Default)] pub struct RawJob<'p> { #[serde(default)] diff --git a/lib/u_lib/src/models/jobs/misc.rs b/lib/u_lib/src/models/jobs/misc.rs index faf108e..0fbca99 100644 --- a/lib/u_lib/src/models/jobs/misc.rs +++ b/lib/u_lib/src/models/jobs/misc.rs @@ -35,7 +35,7 @@ pub enum JobState { )] pub enum JobType { Init, - Service, + Stats, #[default] Shell, Terminate, diff --git a/lib/u_lib/src/models/mod.rs b/lib/u_lib/src/models/mod.rs index 61c9a56..4754ae4 100644 --- a/lib/u_lib/src/models/mod.rs +++ b/lib/u_lib/src/models/mod.rs @@ -3,8 +3,9 @@ mod jobs; mod payload; #[cfg(feature = "server")] pub mod schema; +mod stats; -pub use crate::models::{agent::*, jobs::*, payload::*}; +pub use crate::models::{agent::*, jobs::*, payload::*, stats::*}; use serde::Deserialize; use strum::{Display as StrumDisplay, EnumString}; diff --git a/lib/u_lib/src/models/payload.rs b/lib/u_lib/src/models/payload.rs index 84db3d7..f947a28 100644 --- a/lib/u_lib/src/models/payload.rs +++ b/lib/u_lib/src/models/payload.rs @@ -185,7 +185,7 @@ impl Payload { #[cfg(windows)] pub fn prepare_executable(&self) -> Result<(File, String)> { - todo!() + compile_error!("допилить") } } diff --git a/lib/u_lib/src/models/schema.rs b/lib/u_lib/src/models/schema.rs index 53a01fc..38683f1 100644 --- a/lib/u_lib/src/models/schema.rs +++ b/lib/u_lib/src/models/schema.rs @@ -86,4 +86,9 @@ diesel::joinable!(jobs -> payloads (payload_id)); diesel::joinable!(results -> agents (agent_id)); diesel::joinable!(results -> jobs (job_id)); -diesel::allow_tables_to_appear_in_same_query!(agents, jobs, payloads, results,); +diesel::allow_tables_to_appear_in_same_query!( + agents, + jobs, + payloads, + results, +); diff --git a/lib/u_lib/src/models/stats.rs b/lib/u_lib/src/models/stats.rs new file mode 100644 index 0000000..4b19462 --- /dev/null +++ b/lib/u_lib/src/models/stats.rs @@ -0,0 +1,14 @@ +use serde::{Deserialize, Serialize}; + +use crate::{messaging::AsMsg, scheduler::EntryStat, types::Id, ufs::IndexFileMeta}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Stats { + pub agent_id: Id, + pub running_jobs: Vec, + pub scheduled_jobs: Vec, + pub cached_jobs: Vec, + pub cached_payloads: Vec, +} + +impl AsMsg for Stats {} diff --git a/lib/u_lib/src/proc_output.rs b/lib/u_lib/src/proc_output.rs index 06de5a6..1fe5c33 100644 --- a/lib/u_lib/src/proc_output.rs +++ b/lib/u_lib/src/proc_output.rs @@ -7,7 +7,7 @@ pub struct ProcOutput { } impl ProcOutput { - const STDERR_DELIMETER: &[u8] = b"[STDERR]\n"; + const STDERR_DELIMETER: &'static [u8] = b"[STDERR]\n"; pub fn from_output(output: &Output) -> Self { Self::new() diff --git a/lib/u_lib/src/scheduler/entry.rs b/lib/u_lib/src/scheduler/entry.rs new file mode 100644 index 0000000..6eb7d47 --- /dev/null +++ b/lib/u_lib/src/scheduler/entry.rs @@ -0,0 +1,91 @@ +use crate::{models::PreparedJob, types::Id, u_runner::IdentifiableFuture}; +use chrono::{DateTime, Utc}; +use core::fmt; +use serde::{Deserialize, Serialize}; +use std::sync::Arc; + +pub trait SchedulerJob { + fn call(&self) -> IdentifiableFuture<()>; +} + +// scheduler job need to be called repeatedly, +// the only way to achieve this is to use Fn() -> Future +impl SchedulerJob for F +where + F: Fn() -> IdentifiableFuture<()>, +{ + fn call(&self) -> IdentifiableFuture<()> { + self() + } +} + +#[derive(Clone)] +pub struct Entry { + pub entry_id: Id, + pub schedule: Option, + pub next: Option>, + pub runnable: EntryType, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct EntryStat { + pub entry_id: Id, + pub job_ident: String, + pub schedule: String, + pub next: Option>, +} + +#[derive(Clone)] +pub enum EntryType { + Common(Arc), + URunner(PreparedJob), +} + +impl From for EntryType { + fn from(value: J) -> Self { + Self::Common(Arc::new(value)) + } +} + +impl From for EntryType { + fn from(value: PreparedJob) -> Self { + Self::URunner(value) + } +} + +impl Entry { + pub fn set_next_run_time(&mut self) { + self.next = self.get_next_run_time(); + } + + pub fn get_next_run_time(&self) -> Option> { + match &self.schedule { + Some(schedule) => schedule.upcoming(Utc).next(), + None => Some(Utc::now()), + } + } + + pub fn as_stat(&self) -> EntryStat { + let job_ident = match &self.runnable { + EntryType::URunner(entry) => entry.job.meta.id.to_string(), + EntryType::Common(entry) => entry.call().job_ident.to_string(), + }; + + EntryStat { + entry_id: self.entry_id, + job_ident, + schedule: self + .schedule + .as_ref() + .map(|s| s.to_string()) + .unwrap_or_default(), + next: self.next.clone(), + } + } +} + +impl fmt::Debug for Entry { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{} {:?} {:?}", self.entry_id, self.schedule, self.next) + } +} diff --git a/lib/u_lib/src/scheduler/mod.rs b/lib/u_lib/src/scheduler/mod.rs new file mode 100644 index 0000000..b40622c --- /dev/null +++ b/lib/u_lib/src/scheduler/mod.rs @@ -0,0 +1,178 @@ +mod entry; + +use std::sync::Arc; +use std::time::Duration; + +use chrono::Utc; +use cron::Schedule; +use entry::Entry; +use once_cell::sync::Lazy; +use tokio::sync::Mutex; +use uuid::Uuid; + +use crate::jobs::AnonymousJobBatch; +use crate::types::Id; + +use self::entry::EntryType; + +pub use entry::EntryStat; + +pub static SCHEDULER: Lazy = Lazy::new(|| AsyncScheduler::new()); + +#[derive(Clone)] +pub struct AsyncScheduler { + entries: Arc>>, +} + +impl AsyncScheduler { + pub fn new() -> AsyncScheduler { + AsyncScheduler { + entries: Arc::new(Mutex::new(Vec::new())), + } + } + + pub async fn start_blocking(&self) -> ! { + for entry in self.entries.lock().await.iter_mut() { + entry.set_next_run_time(); + } + + loop { + let mut entries = self.entries.lock().await; + entries.sort_by(|b, a| b.next.cmp(&a.next)); + + let wait_duration = if let Some(entry) = entries.first() { + let wait_millis = (entry.next.as_ref().unwrap().timestamp_millis() as u64) + .saturating_sub(Utc::now().timestamp_millis() as u64); + + Duration::from_millis(wait_millis) + } else { + Duration::from_secs(1) + }; + + drop(entries); + tokio::time::sleep(wait_duration).await; + + let mut entries = self.entries.lock().await; + let mut job_batch = vec![]; + + for entry in &mut *entries { + match entry.next.as_ref() { + Some(next) => { + if next.gt(&Utc::now()) { + break; + } + match &entry.runnable { + EntryType::Common(runnable) => { + let fut = runnable.call(); + tokio::spawn(fut); + } + EntryType::URunner(runnable) => { + debug!("starting assigned job {:?}", runnable.ids); + job_batch.push(runnable.clone()) + } + } + entry.set_next_run_time(); + } + None => {} + } + } + + AnonymousJobBatch::from_prepared_jobs(job_batch) + .spawn() + .await; + + entries.retain(|e| e.schedule.is_some()); + } + } + + pub async fn add_job(&self, schedule: Option, runnable: impl Into) -> Id { + let entry_id = Uuid::new_v4(); + let runnable = runnable.into(); + let mut entry = Entry { + entry_id, + schedule, + next: None, + runnable, + }; + + entry.set_next_run_time(); + self.entries.lock().await.push(entry); + + entry_id + } + + pub async fn del_job(&self, entry_id: Id) { + self.entries.lock().await.retain(|e| e.entry_id != entry_id); + } + + pub async fn stats(&self) -> Vec { + self.entries + .lock() + .await + .iter() + .map(|entry| entry.as_stat()) + .collect() + } + + pub async fn start(&self) { + let cloned = self.clone(); + tokio::spawn(async move { + cloned.start_blocking().await; + }); + } +} + +#[cfg(test)] +mod tests { + use std::time::Duration; + use tokio::time::sleep; + + use crate::u_runner::IdentifiableFuture; + + use super::*; + + #[tokio::test(flavor = "multi_thread")] + async fn scheduling() { + let v = Arc::new(Mutex::new(0)); + let scheduler = AsyncScheduler::new(); + + { + let v = v.clone(); + scheduler + .add_job(Some("*/1 * * * * * *".try_into().unwrap()), move || { + let v = v.clone(); + IdentifiableFuture::from_fut_with_ident("testf", async move { + *v.lock().await += 1; + }) + }) + .await; + } + + scheduler + .add_job(Some("*/1 * * * * * *".try_into().unwrap()), move || { + IdentifiableFuture::from_fut_with_ident("testf", async move { + println!("hello1"); + }) + }) + .await; + + scheduler + .add_job(Some("*/1 * * * * * *".try_into().unwrap()), move || { + IdentifiableFuture::from_fut_with_ident("testf", async move { + println!("hello2"); + }) + }) + .await; + + scheduler.start().await; + + sleep(Duration::from_secs_f32(0.1)).await; // wait for scheduler + sleep(Duration::from_secs(1)).await; + + assert_eq!(*v.lock().await, 1); + + sleep(Duration::from_secs(1)).await; + + assert_eq!(*v.lock().await, 2); + } +} diff --git a/lib/u_lib/src/u_runner.rs b/lib/u_lib/src/u_runner.rs new file mode 100644 index 0000000..59f34fc --- /dev/null +++ b/lib/u_lib/src/u_runner.rs @@ -0,0 +1,200 @@ +use crate::{models::AssignedJob, UResult}; +use lazy_static::lazy_static; +use std::future::Future; +use std::pin::Pin; +use std::task::Poll; +use std::{collections::HashMap, task::Context}; +use tokio::{ + runtime::Handle, + sync::mpsc::{channel, Receiver, Sender}, + sync::Mutex, + task::{spawn, spawn_blocking, JoinHandle}, +}; +use uuid::Uuid; + +pub type ExecResult = UResult; + +lazy_static! { + static ref FUT_RESULTS: Mutex> = Mutex::new(HashMap::new()); + static ref FUT_CHANNEL: (Sender, Mutex>) = { + spawn(init_receiver()); + let (tx, rx) = channel(100); + (tx, Mutex::new(rx)) + }; +} + +pub struct IdentifiableFuture { + pub job_ident: String, + fut: Pin + Send + Sync + 'static>>, +} + +impl IdentifiableFuture { + pub fn from_fut_with_ident( + job_ident: impl Into, + job: impl Future + Send + Sync + 'static, + ) -> Self { + Self { + fut: Box::pin(job), + job_ident: job_ident.into(), + } + } +} + +impl Future for IdentifiableFuture { + type Output = R; + + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + self.fut.as_mut().poll(cx) + } +} + +struct JoinInfo { + job_ident: String, + handle: JoinHandle>, + completed: bool, + // collectable: bool, // indicates if future can be popped from pool via pop_task_if_completed +} + +impl JoinInfo { + async fn wait_result(self) -> ExecResult { + self.handle.await.unwrap().await.unwrap() + } +} + +fn get_sender() -> Sender { + FUT_CHANNEL.0.clone() +} + +/// Job runner. Has multiple ways of work. +/// - run 1 or more jobs and wait until they're all done +/// - run 1 or more jobs in background and collect results of completed jobs later +pub struct URunner { + executables: Vec>, + fids: Vec, +} + +impl URunner { + pub fn new() -> Self { + Self { + executables: vec![], + fids: vec![], + } + } + + pub fn push(&mut self, job: IdentifiableFuture) { + self.executables.push(job); + } + + /// Spawn prepared tasks + pub async fn spawn(mut self) -> Self { + for executable in self.executables.drain(..) { + let handle = Handle::current(); + let fid = Uuid::new_v4(); + let tx = get_sender(); + let job_id = executable.job_ident.clone(); + self.fids.push(fid); + let job_wrapper = async move { + debug!("inside wrapper (started): {}", fid); + let result = executable.await; + tx.send(fid).await.ok(); + result + }; + let handler = JoinInfo { + job_ident: job_id, + handle: spawn_blocking(move || handle.spawn(job_wrapper)), + completed: false, + }; + FUT_RESULTS.lock().await.insert(fid, handler); + } + self + } + + /// Wait until a bunch of tasks is finished. + /// NOT GUARANTEED that all tasks will be returned due to + /// possibility to pop them in other places + pub async fn wait(self) -> Vec { + let mut result = vec![]; + for fid in self.fids { + if let Some(job) = Self::pop_job(fid).await { + result.push(job.wait_result().await); + } + } + result + } + + pub async fn pop_job_if_completed(fid: Uuid) -> Option { + let Some(&JoinInfo { completed, .. }) = FUT_RESULTS.lock().await.get(&fid) else { + return None; + }; + if completed { + let job = Self::pop_job(fid).await.unwrap(); + Some(job.wait_result().await) + } else { + None + } + } + + pub async fn pop_completed() -> Vec { + let mut completed: Vec = vec![]; + let fids = FUT_RESULTS + .lock() + .await + .keys() + .copied() + .collect::>(); + for fid in fids { + if let Some(r) = Self::pop_job_if_completed(fid).await { + completed.push(r) + } + } + completed + } + + pub async fn stats() -> Vec { + FUT_RESULTS + .lock() + .await + .values() + .map(|v| v.job_ident.clone()) + .collect() + } + + async fn pop_job(fid: Uuid) -> Option { + FUT_RESULTS.lock().await.remove(&fid) + } +} + +async fn init_receiver() { + while let Some(fid) = FUT_CHANNEL.1.lock().await.recv().await { + let mut lock = FUT_RESULTS.lock().await; + if let Some(j) = lock.get_mut(&fid) { + j.completed = true; + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + // WTF + // WTF + // WTF + #[tokio::test] + async fn test_spawn() { + use std::sync::Arc; + + let val = Arc::new(Mutex::new(0)); + let t = { + let v = val.clone(); + spawn(async move { + *v.lock().await = 5; + }) + }; + assert_eq!(0, *val.lock().await); + spawn(async {}).await.unwrap(); + assert_eq!(5, *val.lock().await); + t.await.unwrap(); + assert_eq!(5, *val.lock().await); + } +} diff --git a/lib/u_lib/src/ufs/index.rs b/lib/u_lib/src/ufs/index.rs index 9a58ef6..c6b0cb9 100644 --- a/lib/u_lib/src/ufs/index.rs +++ b/lib/u_lib/src/ufs/index.rs @@ -1,13 +1,15 @@ -use super::{Error, FileMeta}; +use super::Error; use once_cell::sync::Lazy; use parking_lot::Mutex; +use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::env::temp_dir; +use std::ffi::OsString; use std::fs; use std::path::PathBuf; // index format: given_name -> payload_meta -type Index = HashMap; +type Index = HashMap; static IDX_FILE_NAME: Lazy = Lazy::new(|| temp_dir().join(".i")); static INDEX: Lazy> = Lazy::new(|| { @@ -28,6 +30,35 @@ static INDEX: Lazy> = Lazy::new(|| { Mutex::new(idx) }); +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct IndexFileMeta { + extension: Option, + pub external: bool, // if file is present before adding to index + pub hashsum: String, + pub path: PathBuf, // actual file path + pub size: u64, +} + +impl IndexFileMeta { + pub fn new( + full_path: impl Into, + hashsum: String, + external: bool, + ) -> Result { + let full_path: PathBuf = full_path.into(); + let extension = full_path.extension().map(ToOwned::to_owned); + let size = fs::metadata(&full_path)?.len(); + + Ok(IndexFileMeta { + path: full_path, + extension, + external, + hashsum, + size, + }) + } +} + mod sync { use super::{Index, IDX_FILE_NAME}; use std::fs; @@ -57,7 +88,7 @@ mod sync { } } -pub fn get(name: impl AsRef) -> Option { +pub fn get(name: impl AsRef) -> Option { let mut index = INDEX.lock(); sync::deleted(&mut index); @@ -65,18 +96,18 @@ pub fn get(name: impl AsRef) -> Option { index.get(name.as_ref()).cloned() } -pub fn get_by_hash(hash: impl AsRef<[u8]>) -> Option<(String, FileMeta)> { +pub fn get_by_hash(hash: impl AsRef) -> Option<(String, IndexFileMeta)> { let mut index = INDEX.lock(); sync::deleted(&mut index); index .iter() - .find(|(_name, meta)| meta.hash == hash.as_ref()) + .find(|(_name, meta)| meta.hashsum == hash.as_ref()) .map(|(n, m)| (n.to_owned(), m.clone())) } -pub fn insert(name: impl Into, meta: FileMeta) { +pub fn insert(name: impl Into, meta: IndexFileMeta) { let mut index = INDEX.lock(); sync::deleted(&mut index); @@ -87,7 +118,7 @@ pub fn insert(name: impl Into, meta: FileMeta) { sync::index2fs(&mut index); } -pub fn remove(name: impl AsRef) -> Option { +pub fn remove(name: impl AsRef) -> Option { let mut index = INDEX.lock(); sync::deleted(&mut index); @@ -99,3 +130,7 @@ pub fn remove(name: impl AsRef) -> Option { result } + +pub fn stats() -> Vec { + INDEX.lock().values().cloned().collect() +} diff --git a/lib/u_lib/src/ufs/mod.rs b/lib/u_lib/src/ufs/mod.rs index 96f0bbd..dc9ac8e 100644 --- a/lib/u_lib/src/ufs/mod.rs +++ b/lib/u_lib/src/ufs/mod.rs @@ -1,49 +1,19 @@ -// This module is aiming to store (obfuscated?) payloads, get them by name, -// rename, update, delete or prepare to execute via memfd_create (unix) +/// This module is aiming to store (obfuscated?) payloads, get them by name, +/// rename, update, delete or prepare to execute via memfd_create (unix) +mod error; +mod index; use anyhow::{Context, Result}; -use serde::{Deserialize, Serialize}; use std::env::temp_dir; -use std::ffi::OsString; use std::fs; use std::path::{Path, PathBuf}; use uuid::Uuid; -mod error; -mod index; pub use error::Error; +pub use index::IndexFileMeta; const OBFUSCATE: bool = cfg!(feature = "agent"); -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct FileMeta { - extension: Option, - external: bool, // if file is present before adding to index - hash: Vec, - pub path: PathBuf, // actual file path - pub size: u64, -} - -impl FileMeta { - pub fn new( - full_path: impl Into, - hash: Vec, - external: bool, - ) -> Result { - let full_path: PathBuf = full_path.into(); - let extension = full_path.extension().map(ToOwned::to_owned); - let size = fs::metadata(&full_path)?.len(); - - Ok(FileMeta { - path: full_path, - extension, - external, - hash, - size, - }) - } -} - /// Check if file exists in index. /// File may present in fs but not in index, fn will return false then. pub fn exists_in_index(name: impl AsRef) -> bool { @@ -51,7 +21,7 @@ pub fn exists_in_index(name: impl AsRef) -> bool { } #[inline] -pub fn read_meta(name: impl AsRef) -> Result { +pub fn read_meta(name: impl AsRef) -> Result { index::get(&name) .ok_or_else(|| Error::not_found(name.as_ref())) .context("meta") @@ -113,7 +83,7 @@ pub fn put(name: impl AsRef, data: impl AsRef<[u8]>) -> Result<()> { }; index::insert( name, - FileMeta::new(path, data_hash, false).context("put_insert")?, + IndexFileMeta::new(path, data_hash, false).context("put_insert")?, ); Ok(()) @@ -123,7 +93,7 @@ pub fn edit(name: impl AsRef, data: impl AsRef<[u8]>) -> Result<()> { let meta = read_meta(&name).context("edit_meta")?; let data_hash = hash_data(&data); - if meta.hash == data_hash { + if meta.hashsum == data_hash { return Ok(()); } @@ -131,7 +101,7 @@ pub fn edit(name: impl AsRef, data: impl AsRef<[u8]>) -> Result<()> { .map_err(|e| Error::new(e, &meta.path)) .context("edit_write")?; - let new_meta = FileMeta::new(meta.path, data_hash, meta.external).context("edit_nmeta")?; + let new_meta = IndexFileMeta::new(meta.path, data_hash, meta.external).context("edit_nmeta")?; index::remove(&name); index::insert(name.as_ref(), new_meta); @@ -215,12 +185,16 @@ pub fn put_external(path: impl AsRef) -> Result<()> { index::insert( path_str, - FileMeta::new(path, data_hash, true).context("ext2")?, + IndexFileMeta::new(path, data_hash, true).context("ext2")?, ); Ok(()) } +pub fn stats() -> Vec { + index::stats() +} + /* pub fn cleanup() { let index = INDEX.read(); @@ -231,10 +205,11 @@ pub fn cleanup() { } */ -fn hash_data(data: impl AsRef<[u8]>) -> Vec { +fn hash_data(data: impl AsRef<[u8]>) -> String { use sha3::{Digest, Sha3_256}; let mut hasher = Sha3_256::new(); hasher.update(data); - hasher.finalize().to_vec() + let hashsum = hasher.finalize().to_vec(); + hex::encode(hashsum) } diff --git a/migrations/2020-10-24-111622_create_all/up.sql b/migrations/2020-10-24-111622_create_all/up.sql index f4058a8..3dce513 100644 --- a/migrations/2020-10-24-111622_create_all/up.sql +++ b/migrations/2020-10-24-111622_create_all/up.sql @@ -1,5 +1,5 @@ CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; -CREATE TYPE JobType AS ENUM ('shell', 'init', 'python', 'service'); +CREATE TYPE JobType AS ENUM ('shell', 'init', 'python', 'service', 'stats'); CREATE TYPE JobState AS ENUM ('queued', 'running', 'finished'); CREATE TYPE AgentState AS ENUM ('new', 'active', 'banned');