diff --git a/Cargo.lock b/Cargo.lock index 33548cc..3df95f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,6 +81,12 @@ version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.4.0" @@ -102,12 +108,24 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "bitflags" version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + [[package]] name = "bytes" version = "1.8.0" @@ -216,12 +234,32 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "either" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -255,6 +293,46 @@ dependencies = [ "spin", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", + "futures-sink", +] + [[package]] name = "futures-core" version = "0.3.31" @@ -297,8 +375,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", + "futures-io", "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", "slab", @@ -321,6 +402,25 @@ version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +[[package]] +name = "h2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.14.5" @@ -354,6 +454,257 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "http" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" + +[[package]] +name = "hyper" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" +dependencies = [ + "futures-util", + "http", + "hyper", + "hyper-util", + "rustls 0.23.20", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.26.1", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + [[package]] name = "indexmap" version = "2.6.0" @@ -364,6 +715,12 @@ dependencies = [ "hashbrown 0.15.1", ] +[[package]] +name = "ipnet" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -376,6 +733,16 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "js-sys" +version = "0.3.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -394,6 +761,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" + [[package]] name = "lock_api" version = "0.4.12" @@ -425,6 +798,22 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "miniz_oxide" version = "0.8.0" @@ -446,6 +835,23 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "ntapi" version = "0.4.1" @@ -497,12 +903,50 @@ version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +[[package]] +name = "openssl" +version = "0.10.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-sys" +version = "0.9.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "overload" version = "0.1.1" @@ -532,6 +976,12 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + [[package]] name = "pin-project-lite" version = "0.2.15" @@ -544,6 +994,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkg-config" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + [[package]] name = "proc-macro2" version = "1.0.89" @@ -686,6 +1142,51 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "reqwest" +version = "0.12.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-tls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "mime_guess", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows-registry", +] + [[package]] name = "ring" version = "0.17.8" @@ -716,7 +1217,7 @@ dependencies = [ "rustls-webpki", "thiserror", "tokio", - "tokio-rustls", + "tokio-rustls 0.25.0", ] [[package]] @@ -752,6 +1253,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls" +version = "0.23.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5065c3f250cbd332cd894be57c40fa52387247659b14a2d6041d121547903b1b" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + [[package]] name = "rustls-native-certs" version = "0.7.3" @@ -867,6 +1381,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -925,6 +1451,12 @@ dependencies = [ "lock_api", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "strsim" version = "0.11.1" @@ -948,6 +1480,26 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "sysinfo" version = "0.33.0" @@ -962,6 +1514,27 @@ dependencies = [ "windows", ] +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tempfile" version = "3.14.0" @@ -1005,6 +1578,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tokio" version = "1.42.0" @@ -1035,17 +1618,37 @@ dependencies = [ "syn", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls", + "rustls 0.22.4", "rustls-pki-types", "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" +dependencies = [ + "rustls 0.23.20", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.13" @@ -1063,6 +1666,12 @@ dependencies = [ "tokio", ] +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + [[package]] name = "tracing" version = "0.1.41" @@ -1124,6 +1733,18 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicase" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" + [[package]] name = "unicode-ident" version = "1.0.13" @@ -1136,6 +1757,37 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" +[[package]] +name = "uploader" +version = "0.1.0" +dependencies = [ + "clap", + "reqwest", +] + +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -1148,12 +1800,104 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38176d9b44ea84e9184eff0bc34cc167ed044f816accfe5922e54d84cf48eca2" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" + +[[package]] +name = "web-sys" +version = "0.3.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "which" version = "4.4.2" @@ -1206,7 +1950,7 @@ checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" dependencies = [ "windows-implement", "windows-interface", - "windows-result", + "windows-result 0.1.2", "windows-targets", ] @@ -1232,6 +1976,17 @@ dependencies = [ "syn", ] +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result 0.2.0", + "windows-strings", + "windows-targets", +] + [[package]] name = "windows-result" version = "0.1.2" @@ -1241,6 +1996,25 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result 0.2.0", + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.52.0" @@ -1323,8 +2097,87 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index ef404d4..c038a62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,16 @@ name = "odysseus-daemon" version = "0.1.0" edition = "2021" -[dependencies] +[workspace] +members = ["uploader"] + +[workspace.dependencies] +reqwest = { version = "0.12.9", features = ["blocking", "multipart"] } clap = { version = "4.5.23", features = ["derive", "env"] } + + +[dependencies] +clap.workspace = true protobuf = "3.7.1" rumqttc = "0.24.0" serde = { version = "1.0.216", features = ["derive"] } diff --git a/README.md b/README.md index 8ee19fa..2c4726f 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,16 @@ Core principles: Modules - `visual`: Camera process manager and writer. Status: Beta -- `lockdown`: Feature disabler and modifier upon HV enablement. Status: Alpha -- `audible`: Call feature trigger and monitor. Status: Alpha +- `lockdown`: Feature disabler and modifier upon HV enablement. Status: Beta +- `audible`: Call feature trigger and monitor. Status: Beta - `numerical`: Telemetry scraper and sender (tpu-telemetry python replacement). Status: Incomplete -- `logger`: MQTT receiver and disk logger. Status: Beta +- `logger`: MQTT receiver and disk logger. Status: Alpha + +Upload modules: +- `logger`: Upload from the logger module to scylla. Status: Beta +- `visual`: Camera video uploader to cloud platform. Status: Incomplete +- `serial`: (from `lockdown` module) Serial output uploader to cloud platform. Status Incomplete +- **This program will only run on Odysseus** diff --git a/src/audible.rs b/src/audible.rs index 0d125d0..abf290c 100644 --- a/src/audible.rs +++ b/src/audible.rs @@ -1,6 +1,6 @@ use std::error::Error; -use tokio::sync::watch::Receiver; +use tokio::{process::Command, sync::watch::Receiver}; use tokio_util::sync::CancellationToken; /// runs the mute/unmute functionality @@ -11,11 +11,16 @@ pub async fn audible_manager( loop { tokio::select! { _ = cancel_token.cancelled() => { - + Command::new("linphonecsh").args(["generic", "unmute"]).spawn()?.wait().await?; }, new = mute_stat_recv.changed() => { new?; - + // to mute or not + if *mute_stat_recv.borrow_and_update() { + Command::new("linphonecsh").args(["generic", "mute"]).spawn()?.wait().await?; + } else { + Command::new("linphonecsh").args(["generic", "unmute"]).spawn()?.wait().await?; + } } } } diff --git a/src/lib.rs b/src/lib.rs index a6755af..6959f27 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,3 +36,6 @@ pub const HV_EN_TOPIC: &str = "MPU/State/TSMS"; /// the topic to listen for mute enable, 1 is on 0 is off pub const MUTE_EN_TOPIC: &str = "WHEEL/Buttons/Mute"; + +/// The save location for all files +pub static SAVE_LOCATION: std::sync::OnceLock = std::sync::OnceLock::new(); diff --git a/src/lockdown.rs b/src/lockdown.rs index 415a491..09aaa7b 100644 --- a/src/lockdown.rs +++ b/src/lockdown.rs @@ -1,10 +1,14 @@ -use std::error::Error; +use std::{error::Error, process::Stdio, time::Duration}; -use tokio::{io, process::Command, sync::watch::Receiver}; +use tokio::{ + io, + process::{Child, Command}, + sync::watch::Receiver, +}; use tokio_util::sync::CancellationToken; use tracing::{info, warn}; -use crate::HVTransition; +use crate::{HVTransition, SAVE_LOCATION}; /// Run various HV on/off lockdowns /// Takes in a receiver of HV state @@ -12,10 +16,15 @@ pub async fn lockdown_runner( cancel_token: CancellationToken, mut hv_stat_recv: Receiver, ) -> Result<(), Box> { + let mut cmds: Option<(Child, Child)> = None; + if let Err(err) = hv_transition_disabled(&mut cmds).await { + warn!("Could not unlock!!! {}", err); + } + loop { tokio::select! { _ = cancel_token.cancelled() => { - if let Err(err) = hv_transition_disabled().await { + if let Err(err) = hv_transition_disabled(&mut cmds).await { warn!("Could not unlock!!! {}", err); } break Ok(()); @@ -23,20 +32,21 @@ pub async fn lockdown_runner( new = hv_stat_recv.changed() => { new?; let curr_data = *hv_stat_recv.borrow_and_update(); - let curr_state = match curr_data { - HVTransition::TransitionOn(_) => true, - HVTransition::TransitionOff => false, - }; - if curr_state { - info!("Locking down!"); - if let Err(err) = hv_transition_enabled().await { - warn!("Could not lock down!!! {}", err); - } - } else { - info!("Unlocking!"); - if let Err(err) = hv_transition_disabled().await { + match curr_data { + HVTransition::TransitionOn(hvon_data) => { + info!("Locking down!"); + let Ok(children) = hv_transition_enabled(hvon_data.time_ms).await else { + warn!("Could not lock down!!!"); + continue; + }; + cmds = Some(children); + }, + HVTransition::TransitionOff => { + info!("Unlocking!"); + if let Err(err) = hv_transition_disabled(&mut cmds).await { warn!("Could not unlock!!! {}", err); } + }, } } @@ -45,7 +55,9 @@ pub async fn lockdown_runner( } /// Transition to HV on -pub async fn hv_transition_enabled() -> io::Result<()> { +pub async fn hv_transition_enabled(time_ms: u64) -> io::Result<(Child, Child)> { + // unbind from the usbipd server + // this automatically brings back let mut cmd_cerb_dis = Command::new("usbip") .args(["unbind", "--busid", "1-1.3"]) .spawn()?; @@ -56,14 +68,62 @@ pub async fn hv_transition_enabled() -> io::Result<()> { cmd_cerb_dis.wait().await?; cmd_shep_dis.wait().await?; + tokio::time::sleep(Duration::from_secs(2)).await; + + let mut cmd_cerb_conf = Command::new("stty") + .args(["-F", "/dev/ttyCerberus", "115200"]) + .spawn()?; + + let mut cmd_shep_conf = Command::new("stty") + .args(["-F", "/dev/ttyShepherd", "115200"]) + .spawn()?; + + cmd_cerb_conf.wait().await?; + cmd_shep_conf.wait().await?; + + // TODO actually write the tty read from cat into a file, and + // if !cmd_cerb_dis.wait().await.unwrap().success() && !cmd_shep_dis.wait().await.unwrap().success() { // info!("Failed to run USBIP command(s) to unbind"); // } - Ok(()) + let cerb_save_loc = format!( + "{}/event-{}/cerberus-dump.cap", + SAVE_LOCATION.get().unwrap(), + time_ms + ); + let shep_save_loc = format!( + "{}/event-{}/shepherd-dump.cap", + SAVE_LOCATION.get().unwrap(), + time_ms + ); + Ok(( + Command::new("minicom") + .args([ + "-D", + "/dev/ttyCerberus", + "-O", + "timestamp=extended", + "-C", + &cerb_save_loc, + ]) + .stdout(Stdio::null()) + .spawn()?, + Command::new("minicom") + .args([ + "-D", + "/dev/ttyCerberus", + "-O", + "timestamp=extended", + "-C", + &shep_save_loc, + ]) + .stdout(Stdio::null()) + .spawn()?, + )) } /// Transition to HV off -pub async fn hv_transition_disabled() -> io::Result<()> { +pub async fn hv_transition_disabled(child_writers: &mut Option<(Child, Child)>) -> io::Result<()> { let mut cmd_cerb_rec = Command::new("usbip") .args(["bind", "--busid", "1-1.3"]) .spawn()?; @@ -74,6 +134,11 @@ pub async fn hv_transition_disabled() -> io::Result<()> { cmd_cerb_rec.wait().await?; cmd_shep_rec.wait().await?; + if let Some(child_writers) = child_writers { + child_writers.0.kill().await?; + child_writers.1.kill().await?; + } + // if !cmd_cerb_rec.wait().await.unwrap().success() && !cmd_shep_rec.wait().await.unwrap().success() { // println!("Failed to run USBIP command(s) to unbind"); // } diff --git a/src/logger.rs b/src/logger.rs index b422a70..6661c5a 100644 --- a/src/logger.rs +++ b/src/logger.rs @@ -1,33 +1,70 @@ use std::error::Error; use protobuf::Message; -use tokio::sync::mpsc::Receiver; +use tokio::{ + fs::File, + io::{AsyncWriteExt, BufWriter}, +}; use tokio_util::sync::CancellationToken; use tracing::warn; -use crate::playback_data; +use crate::{playback_data, HVTransition, SAVE_LOCATION}; /// runs the mute/unmute functionality /// Takes in a receiver of all MQTT messages pub async fn logger_manager( cancel_token: CancellationToken, - mut mqtt_recv_rx: Receiver, + mut mqtt_recv_rx: tokio::sync::mpsc::Receiver, + mut hv_stat_recv: tokio::sync::watch::Receiver, ) -> Result<(), Box> { + let mut writer: Option> = None; + loop { tokio::select! { _ = cancel_token.cancelled() => { + if let Some(writer) = writer.as_mut() { + return Ok(writer.flush().await?) + } return Ok(()) }, + new = hv_stat_recv.changed() => { + new?; + let val = *hv_stat_recv.borrow_and_update(); + match val { + HVTransition::TransitionOn(hvon_data) => { + let filename = format!("{}/event-{}/data_dump.log", SAVE_LOCATION.get().unwrap(), hvon_data.time_ms); + writer = Some(BufWriter::new(File::create_new(filename).await.expect("Could not create log file!"))); + }, + HVTransition::TransitionOff => { + if let Some(writ) = writer.as_mut() { + writ.flush().await?; + writer = None; + + } else { + warn!("Logger - Transition off was unexpected"); + } + }, + } + + }, msg = mqtt_recv_rx.recv() => { - let parsed_msg = match msg { + if writer.is_none() { + continue; + } + + match msg { Some(msg) => { - msg + if let Some(writ) = writer.as_mut() { + if let Err(err) = writ.write(&msg.write_length_delimited_to_bytes().unwrap()).await { + warn!("Could not write to log! {}", err); + } + } }, None => { warn!("Could not receive message!"); continue; } - }; + } //println!("{:?}", parsed_msg.write_to_bytes()); } } diff --git a/src/main.rs b/src/main.rs index f54c1c5..674439b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ use odysseus_daemon::{ numerical::collect_data, playback_data, visual::{run_save_pipeline, SavePipelineOpts}, - HVTransition, PublishableMessage, + HVTransition, PublishableMessage, SAVE_LOCATION, }; use rumqttc::v5::AsyncClient; use tokio::{ @@ -99,6 +99,9 @@ async fn main() { // use that subscriber to process traces emitted after this point tracing::subscriber::set_global_default(subscriber).expect("Could not init tracing"); + // set save location + SAVE_LOCATION.get_or_init(|| cli.output_folder); + // channel to pass the mqtt data // TODO tune buffer size let (mqtt_sender_tx, mqtt_sender_rx) = mpsc::channel::(1000); @@ -134,7 +137,6 @@ async fn main() { cli.mock, mute_stat_send, mqtt_recv_tx, - cli.output_folder.clone(), MqttProcessorOptions { mqtt_path: cli.mqtt_url, }, @@ -154,7 +156,6 @@ async fn main() { video: cli .video_uri .expect("Must provide video URI if video is enabled!"), - save_location: cli.output_folder, }, )); } @@ -165,7 +166,7 @@ async fn main() { if cli.lockdown { info!("Running lockdown module"); - task_tracker.spawn(lockdown_runner(token.clone(), hv_stat_recv)); + task_tracker.spawn(lockdown_runner(token.clone(), hv_stat_recv.clone())); } if cli.audible { @@ -174,7 +175,11 @@ async fn main() { } if cli.logger { info!("Running logger module"); - task_tracker.spawn(logger_manager(token.clone(), mqtt_recv_rx.unwrap())); + task_tracker.spawn(logger_manager( + token.clone(), + mqtt_recv_rx.unwrap(), + hv_stat_recv.clone(), + )); } task_tracker.close(); diff --git a/src/mqtt_handler.rs b/src/mqtt_handler.rs index cff4da6..f48cfe8 100644 --- a/src/mqtt_handler.rs +++ b/src/mqtt_handler.rs @@ -17,6 +17,7 @@ use tracing::{debug, trace, warn}; use crate::{ playback_data, serverdata, HVTransition, PublishableMessage, HV_EN_TOPIC, MUTE_EN_TOPIC, + SAVE_LOCATION, }; /// The chief processor of incoming mqtt data, this handles @@ -33,7 +34,6 @@ pub struct MqttProcessor { hv_stat_send: Sender, augment_hv_on: bool, mute_stat_send: Sender, - data_folder: String, mqtt_recv_tx: Option>, } @@ -52,7 +52,6 @@ impl MqttProcessor { augment_hv_on: bool, mute_stat_send: Sender, mqtt_recv_tx: Option>, - data_folder: String, opts: MqttProcessorOptions, ) -> (MqttProcessor, MqttOptions) { // create the mqtt client and configure it @@ -87,7 +86,6 @@ impl MqttProcessor { augment_hv_on, mute_stat_send, mqtt_recv_tx, - data_folder, }, mqtt_opts, ) @@ -110,7 +108,9 @@ impl MqttProcessor { .unwrap() .as_millis() as u64; warn!("HV status permanently set on!!"); - if let Err(err) = std::fs::create_dir(format!("{}/event-{}", self.data_folder, time)) { + if let Err(err) = + std::fs::create_dir(format!("{}/event-{}", SAVE_LOCATION.get().unwrap(), time)) + { panic!( "Could not create folder for data, bailing out of this loop! {}", err @@ -149,7 +149,7 @@ impl MqttProcessor { // ensure only triggering upon change from previous loop if val == 1 && !last_stat { debug!("Transitioning states to HV on, creating folder!"); - if let Err(err) = std::fs::create_dir(format!("{}/event-{}",self.data_folder, res.time_us / 1000)) { + if let Err(err) = std::fs::create_dir(format!("{}/event-{}", SAVE_LOCATION.get().unwrap(), res.time_us / 1000)) { warn!("Could not create folder for data, bailing out of this loop! {}", err); continue; } diff --git a/src/numerical.rs b/src/numerical.rs index fca55de..09d65ee 100644 --- a/src/numerical.rs +++ b/src/numerical.rs @@ -1,7 +1,7 @@ use std::{fs, time::Duration}; use sysinfo::{Components, MemoryRefreshKind, Pid, ProcessesToUpdate, System}; -use tokio::sync::{mpsc::Sender, Mutex}; +use tokio::sync::mpsc::Sender; use tokio_util::sync::CancellationToken; use tracing::{debug, trace, warn}; @@ -13,9 +13,8 @@ pub async fn collect_data( mqtt_sender_tx: Sender, ) { // create requisites - let sys = Mutex::new(System::new_all()); - let mut sys_l = sys.lock().await; - sys_l.refresh_all(); + let mut sys = System::new_all(); + sys.refresh_all(); // for CPU temp let mut components = Components::new_with_refreshed_list(); @@ -38,7 +37,6 @@ pub async fn collect_data( warn!("Could not parse mosquitto pid, using 1, error: {}", a); 1 }); - drop(sys_l); // STEP 1: add a refresh rates for the message @@ -69,7 +67,7 @@ pub async fn collect_data( } }; - vec![PublishableMessage{ topic: TOPIC, data: vec![value], unit: UNIT }] + vec![PublishableMessage{ topic: TOPIC, data: vec![value.unwrap()], unit: UNIT }] } _ = cpu_usage_int.tick() => { @@ -79,30 +77,28 @@ pub async fn collect_data( const TOPIC_B: &str = "TPU/OnBoard/BrokerCpuUsage"; const UNIT_B: &str = "%"; - let mut sys_l = sys.lock().await; - sys_l.refresh_cpu_usage(); - sys_l.refresh_processes(ProcessesToUpdate::Some(&[Pid::from_u32(pid_clean)]), + sys.refresh_cpu_usage(); + sys.refresh_processes(ProcessesToUpdate::Some(&[Pid::from_u32(pid_clean)]), true); - let process = sys_l.process(Pid::from_u32(pid_clean)).unwrap_or_else(|| { + let process = sys.process(Pid::from_u32(pid_clean)).unwrap_or_else(|| { warn!("Could not find mosquitto from PID, using 1"); - sys_l.process(Pid::from(1)).unwrap() + sys.process(Pid::from(1)).unwrap() }); trace!("Using process: {:?}", process.name()); vec![ - PublishableMessage{ topic: TOPIC_C, data: vec![sys_l.global_cpu_usage()], unit: UNIT_C }, + PublishableMessage{ topic: TOPIC_C, data: vec![sys.global_cpu_usage()], unit: UNIT_C }, PublishableMessage{ topic: TOPIC_B, data: vec![process.cpu_usage()], unit: UNIT_B }] }, _ = mem_avail_int.tick() => { const TOPIC: &str = "TPU/OnBoard/MemAvailable"; const UNIT: &str = "MB"; - let mut sys_l = sys.lock().await; - sys_l.refresh_memory_specifics(MemoryRefreshKind::new().with_ram()); + sys.refresh_memory_specifics(MemoryRefreshKind::nothing().with_ram()); - vec![PublishableMessage { topic: TOPIC, data: vec![sys_l.free_memory() as f32 / 1e6], unit: UNIT}] + vec![PublishableMessage { topic: TOPIC, data: vec![sys.free_memory() as f32 / 1e6], unit: UNIT}] } }; for msg in msgs { diff --git a/src/visual.rs b/src/visual.rs index 0c80739..e28b948 100644 --- a/src/visual.rs +++ b/src/visual.rs @@ -1,19 +1,17 @@ -use std::{error::Error, process::Stdio, sync::Arc, time::Duration}; +use std::{error::Error, process::Stdio, time::Duration}; use tokio::{ process::{Child, Command}, - sync::{watch::Receiver, RwLock}, + sync::watch::Receiver, }; use tokio_util::sync::CancellationToken; use tracing::{info, warn}; -use crate::HVTransition; +use crate::{HVTransition, SAVE_LOCATION}; pub struct SavePipelineOpts { /// the dev to read for video pub video: String, - /// the folder to save to - pub save_location: String, } /// Run a save pipeline on the items @@ -25,32 +23,26 @@ pub async fn run_save_pipeline( // ffmpeg -f video4linux2 -input_format mjpeg -s 1280x720 -i /dev/video0 -vf "drawtext=fontfile=FreeSerif.tff: \ //text='%{localtime\:%T}': fontcolor=white@0.8: x=7: y=700" -vcodec libx264 -preset veryfast -f mp4 -pix_fmt yuv420p -y output.mp4 - //let mut res: Option = None; - - let cmd: Arc> = Arc::new(RwLock::new( - Command::new("sleep") - .args(["2147483647"]) - .stdin(Stdio::null()) - .spawn()?, - )); - - //let mut first_run = false; + let mut cmd: Option = None; loop { tokio::select! { _ = cancel_token.cancelled() => { info!("Ffmpeg canceled"); - (*cmd.write().await).wait().await.unwrap(); + if cmd.as_ref().is_some() { + cmd.unwrap().wait().await.unwrap(); + } return Ok(()) }, new = hv_stat_recv.changed() => { new?; + let curr_data = *hv_stat_recv.borrow_and_update(); match curr_data { HVTransition::TransitionOn(hvon_data) => { let save_location = format!( "{}/event-{}/ner24-frontcam.avi", - vid_opts.save_location, + SAVE_LOCATION.get().unwrap(), hvon_data.time_ms ); info!("Creating and launching ffmpeg..."); @@ -76,11 +68,15 @@ pub async fn run_save_pipeline( "-y", &save_location ]).stdin(Stdio::null()).spawn()?; - *cmd.write().await = cmd_new; + cmd = Some(cmd_new); }, HVTransition::TransitionOff => { - let proc_id = cmd.read().await.id().unwrap_or_default(); + if cmd.is_none() { + continue; + } + if let Some(val) = cmd.as_mut() { + let proc_id = val.id().unwrap_or_default(); // logic to safely shutdown since ffmpeg doesnt capture our fake ctrl+c from mqtt // first try and run a SIGTERM kill if let Ok(mut child) = Command::new("kill").args(["-SIGTERM".to_string(), proc_id.to_string(), ]).spawn() { @@ -94,13 +90,15 @@ pub async fn run_save_pipeline( let mut tics_cnt = 0; while tics_cnt < 12 { tokio::time::sleep(Duration::from_secs(1)).await; - if (*cmd.write().await).try_wait().is_ok_and(|f| f.is_some()){ + if val.try_wait().is_ok_and(|f| f.is_some()){ break; } tics_cnt += 1; } // finally as a last sanity check kill the ffmpeg process, as worst case is leaving it dangling - let _ = (*cmd.write().await).kill().await; + let _ = val.kill().await; + } + }, } }, diff --git a/uploader/Cargo.toml b/uploader/Cargo.toml new file mode 100644 index 0000000..255dc76 --- /dev/null +++ b/uploader/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "uploader" +version = "0.1.0" +edition = "2021" + +[dependencies] +clap.workspace = true +reqwest.workspace = true \ No newline at end of file diff --git a/uploader/src/main.rs b/uploader/src/main.rs new file mode 100644 index 0000000..daa77a3 --- /dev/null +++ b/uploader/src/main.rs @@ -0,0 +1,97 @@ +use std::{ + fs::{self}, + path::Path, +}; + +use clap::Parser; +use reqwest::blocking::multipart; + +/// ody-visual command line arguments +#[derive(Parser, Debug)] +#[command(version)] +struct UploaderArgs { + /// The output folder of data (videos, audio, text logs, etc), no trailing slash + #[arg(short = 'f', long, env = "ODYSSEUS_DAEMON_OUTPUT_FOLDER")] + output_folder: String, + + /// The URL of Scylla + #[arg(short = 'u', long, env = "ODYSSEUS_DAEMON_SCYLLA_URL")] + scylla_url: String, +} + +/// Logger module: upload a data_dump.log file to scylla +fn logger_upload( + filepath: &Path, + scylla_uri: &str, + client: &reqwest::blocking::Client, +) -> Result<(), reqwest::Error> { + let res = client + .post(format!("{}/insert/file", scylla_uri)) + .multipart( + multipart::Form::new() + .file("", filepath) + .expect("Could not fetch file for sending"), + ) + .send()?; + + res.error_for_status()?; + + Ok(()) +} + +fn main() { + let cli = UploaderArgs::parse(); + + let client = reqwest::blocking::Client::new(); + + let entries = fs::read_dir(Path::new(&cli.output_folder)).expect("Invalid data output folder!"); + + println!("Traversing data"); + for entry in entries { + match entry { + Ok(dire) => { + if dire + .file_type() + .expect("Could not decode filetype") + .is_dir() + && dire + .file_name() + .into_string() + .expect("Could not decode folder names") + .starts_with("event-") + { + println!("Entering folder {:?}", dire.file_name()); + let entries = fs::read_dir(dire.path()).expect("Invalid folder!"); + for entry in entries { + match entry { + Ok(dire) => { + if dire + .file_type() + .expect("Could not decode filetype") + .is_file() + && dire.file_name() == "data_dump.log" + { + println!("Uploading log file: {:?}", dire.path()); + if let Err(err) = + logger_upload(&dire.path(), &cli.scylla_url, &client) + { + eprintln!("Failed to send log to scylla: {}", err); + } + } + } + Err(e) => eprintln!("Could not traverse folder {}", e), + } + } + } else { + eprintln!("Invalid item: {:?}", dire); + } + } + Err(e) => eprintln!("Could not traverse folder {}", e), + } + } + + println!( + "Done, feel free to clear the inside of the {} directory!", + cli.output_folder + ); +}