From 2f96742336a2dcf7758ba435d952bf3774230d15 Mon Sep 17 00:00:00 2001 From: Federico Ponzi Date: Wed, 16 Aug 2023 22:24:38 +0100 Subject: [PATCH 01/11] init packages --- .gitignore | 3 +- Cargo.lock | 219 ++++- Cargo.toml | 2 + commands/Cargo.toml | 15 + commands/README.md | 4 + commands/build.rs | 6 + commands/src/commands.proto | 26 + commands/src/lib.rs | 21 + commands/src/proto/mod.rs | 1 + commands/src/proto/tutorial.rs | 70 ++ horustctl/Cargo.lock | 1396 ++++++++++++++++++++++++++++++++ horustctl/Cargo.toml | 12 + horustctl/README.md | 0 horustctl/src/main.rs | 93 +++ horustctl/tests/cli.rs | 0 src/horust/mod.rs | 1 + src/horust/uds_messages.rs | 6 + 17 files changed, 1849 insertions(+), 26 deletions(-) create mode 100644 commands/Cargo.toml create mode 100644 commands/README.md create mode 100644 commands/build.rs create mode 100644 commands/src/commands.proto create mode 100644 commands/src/lib.rs create mode 100644 commands/src/proto/mod.rs create mode 100644 commands/src/proto/tutorial.rs create mode 100644 horustctl/Cargo.lock create mode 100644 horustctl/Cargo.toml create mode 100644 horustctl/README.md create mode 100644 horustctl/src/main.rs create mode 100644 horustctl/tests/cli.rs create mode 100644 src/horust/uds_messages.rs diff --git a/.gitignore b/.gitignore index 4ae822d..e854075 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target **/*.rs.bk -.idea \ No newline at end of file +.idea +**/target \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 9a51551..166e6d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -128,6 +128,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + [[package]] name = "bstr" version = "1.1.0" @@ -195,7 +201,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.28", ] [[package]] @@ -359,6 +365,18 @@ dependencies = [ "libc", ] +[[package]] +name = "fastrand" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + [[package]] name = "float-cmp" version = "0.9.0" @@ -527,6 +545,28 @@ dependencies = [ "toml", ] +[[package]] +name = "horust-commands-lib" +version = "0.1.0" +dependencies = [ + "log", + "prost", + "prost-build", + "serde", + "serde_json", +] + +[[package]] +name = "horustctl" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "crossbeam", + "env_logger", + "log", +] + [[package]] name = "http" version = "0.2.5" @@ -647,7 +687,7 @@ checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", - "rustix", + "rustix 0.37.11", "windows-sys", ] @@ -699,14 +739,17 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" +[[package]] +name = "linux-raw-sys" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" + [[package]] name = "log" -version = "0.4.17" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "maplit" @@ -770,13 +813,19 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "multimap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" + [[package]] name = "nix" version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset 0.7.1", @@ -830,6 +879,16 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +[[package]] +name = "petgraph" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" +dependencies = [ + "fixedbitset", + "indexmap", +] + [[package]] name = "pin-project-lite" version = "0.2.7" @@ -879,6 +938,16 @@ dependencies = [ "termtree", ] +[[package]] +name = "prettyplease" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +dependencies = [ + "proc-macro2", + "syn 1.0.105", +] + [[package]] name = "proc-macro2" version = "1.0.66" @@ -888,11 +957,65 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "prost" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" +dependencies = [ + "bytes", + "heck", + "itertools", + "lazy_static", + "log", + "multimap", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn 1.0.105", + "tempfile", + "which", +] + +[[package]] +name = "prost-derive" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 1.0.105", +] + +[[package]] +name = "prost-types" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" +dependencies = [ + "prost", +] + [[package]] name = "quote" -version = "1.0.33" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" dependencies = [ "proc-macro2", ] @@ -970,7 +1093,16 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" dependencies = [ - "bitflags", + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", ] [[package]] @@ -980,7 +1112,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ "getrandom", - "redox_syscall", + "redox_syscall 0.2.10", ] [[package]] @@ -1061,11 +1193,24 @@ version = "0.37.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85597d61f83914ddeba6a47b3b8ffe7365107221c2e557ed94426489fefb5f77" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", - "linux-raw-sys", + "linux-raw-sys 0.3.1", + "windows-sys", +] + +[[package]] +name = "rustix" +version = "0.38.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys 0.4.5", "windows-sys", ] @@ -1083,31 +1228,31 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.160" +version = "1.0.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" +checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.160" +version = "1.0.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" +checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.28", ] [[package]] name = "serde_json" -version = "1.0.68" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" dependencies = [ - "itoa 0.4.8", + "itoa 1.0.2", "ryu", "serde", ] @@ -1189,9 +1334,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.29" +version = "2.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" +checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" dependencies = [ "proc-macro2", "quote", @@ -1208,6 +1353,19 @@ dependencies = [ "remove_dir_all", ] +[[package]] +name = "tempfile" +version = "3.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc02fddf48964c42031a0b3fe0428320ecf3a73c401040fc0096f97794310651" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall 0.3.5", + "rustix 0.38.8", + "windows-sys", +] + [[package]] name = "termcolor" version = "1.1.2" @@ -1240,7 +1398,7 @@ checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.28", ] [[package]] @@ -1501,6 +1659,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "which" +version = "4.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +dependencies = [ + "either", + "libc", + "once_cell", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index b4d064c..d3aa42c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,3 +42,5 @@ rand = "~0.8" [profile.release] strip = "symbols" +[workspace] +members = ["horustctl", "commands"] diff --git a/commands/Cargo.toml b/commands/Cargo.toml new file mode 100644 index 0000000..e24d93d --- /dev/null +++ b/commands/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "horust-commands-lib" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +log = "^0.4.19" +serde = { version = "^1.0.183", features = ["derive"] } +serde_json = "^1.0.104" +prost = "^0.11.9" + +[build-dependencies] +prost-build = { version = "^0.11.9" } \ No newline at end of file diff --git a/commands/README.md b/commands/README.md new file mode 100644 index 0000000..9896f1e --- /dev/null +++ b/commands/README.md @@ -0,0 +1,4 @@ +## Compile +To compile this crate, you will need protobuf compiler. On debian-like you can run: + +apt-get install protobuf-compiler \ No newline at end of file diff --git a/commands/build.rs b/commands/build.rs new file mode 100644 index 0000000..cc0800e --- /dev/null +++ b/commands/build.rs @@ -0,0 +1,6 @@ +pub fn main() { + prost_build::Config::new() + .out_dir("src/proto") + .compile_protos(&["src/commands.proto"], &["src"]) + .expect("Could not compile protobuf types in commands.proto"); +} diff --git a/commands/src/commands.proto b/commands/src/commands.proto new file mode 100644 index 0000000..cb5149e --- /dev/null +++ b/commands/src/commands.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package tutorial; + +message Person { + string name = 1; + int32 id = 2; // Unique ID number for this person. + string email = 3; + + enum PhoneType { + MOBILE = 0; + HOME = 1; + WORK = 2; + } + + message PhoneNumber { + string number = 1; + PhoneType type = 2; + } + + repeated PhoneNumber phones = 4; +} + +// Our address book file is just one of these. +message AddressBook { + repeated Person people = 1; +} \ No newline at end of file diff --git a/commands/src/lib.rs b/commands/src/lib.rs new file mode 100644 index 0000000..6241c43 --- /dev/null +++ b/commands/src/lib.rs @@ -0,0 +1,21 @@ +mod proto; +use proto::tutorial::*; + +pub fn create_large_shirt(color: String) -> Person { + let mut person = Person::default(); + person +} + +pub fn add() { + println!("{:?}", create_large_shirt("blue".to_string())); +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + add(); + } +} diff --git a/commands/src/proto/mod.rs b/commands/src/proto/mod.rs new file mode 100644 index 0000000..0559c4b --- /dev/null +++ b/commands/src/proto/mod.rs @@ -0,0 +1 @@ +pub mod tutorial; diff --git a/commands/src/proto/tutorial.rs b/commands/src/proto/tutorial.rs new file mode 100644 index 0000000..28182cc --- /dev/null +++ b/commands/src/proto/tutorial.rs @@ -0,0 +1,70 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Person { + #[prost(string, tag = "1")] + pub name: ::prost::alloc::string::String, + /// Unique ID number for this person. + #[prost(int32, tag = "2")] + pub id: i32, + #[prost(string, tag = "3")] + pub email: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "4")] + pub phones: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `Person`. +pub mod person { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct PhoneNumber { + #[prost(string, tag = "1")] + pub number: ::prost::alloc::string::String, + #[prost(enumeration = "PhoneType", tag = "2")] + pub r#type: i32, + } + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum PhoneType { + Mobile = 0, + Home = 1, + Work = 2, + } + impl PhoneType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + PhoneType::Mobile => "MOBILE", + PhoneType::Home => "HOME", + PhoneType::Work => "WORK", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "MOBILE" => Some(Self::Mobile), + "HOME" => Some(Self::Home), + "WORK" => Some(Self::Work), + _ => None, + } + } + } +} +/// Our address book file is just one of these. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AddressBook { + #[prost(message, repeated, tag = "1")] + pub people: ::prost::alloc::vec::Vec, +} diff --git a/horustctl/Cargo.lock b/horustctl/Cargo.lock new file mode 100644 index 0000000..143e227 --- /dev/null +++ b/horustctl/Cargo.lock @@ -0,0 +1,1396 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" + +[[package]] +name = "anstyle-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + +[[package]] +name = "bumpalo" +version = "3.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" + +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + +[[package]] +name = "cc" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01" +dependencies = [ + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "4.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd" +dependencies = [ + "clap_builder", + "clap_derive", + "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "crossbeam" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c" +dependencies = [ + "cfg-if", + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset 0.9.0", + "scopeguard", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys", +] + +[[package]] +name = "encoding_rs" +version = "0.8.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" + +[[package]] +name = "futures-io" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" + +[[package]] +name = "futures-sink" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" + +[[package]] +name = "futures-task" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" + +[[package]] +name = "futures-util" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +dependencies = [ + "futures-core", + "futures-io", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" + +[[package]] +name = "h2" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 1.9.3", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" + +[[package]] +name = "horust" +version = "0.1.7" +dependencies = [ + "anyhow", + "clap", + "crossbeam", + "env_logger", + "humantime-serde", + "libc", + "log", + "maplit", + "nix", + "reqwest", + "serde", + "shellexpand", + "shlex", + "thiserror", + "toml", +] + +[[package]] +name = "horustctl" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "crossbeam", + "env_logger", + "horust", + "log", +] + +[[package]] +name = "http" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "humantime-serde" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c" +dependencies = [ + "humantime", + "serde", +] + +[[package]] +name = "hyper" +version = "0.14.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2 0.4.9", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", +] + +[[package]] +name = "ipnet" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" + +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi", + "rustix", + "windows-sys", +] + +[[package]] +name = "itoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" + +[[package]] +name = "js-sys" +version = "0.3.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "linux-raw-sys" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +dependencies = [ + "libc", + "wasi", + "windows-sys", +] + +[[package]] +name = "nix" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset 0.7.1", + "pin-utils", + "static_assertions", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "percent-encoding" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" + +[[package]] +name = "pin-project-lite" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "proc-macro2" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom", + "redox_syscall", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" + +[[package]] +name = "reqwest" +version = "0.11.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustix" +version = "0.38.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "ryu" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.183" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.183" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_spanned" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +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 = "shellexpand" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b" +dependencies = [ + "dirs", +] + +[[package]] +name = "shlex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" + +[[package]] +name = "slab" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +dependencies = [ + "autocfg", +] + +[[package]] +name = "socket2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "socket2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "2.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9207952ae1a003f42d3d5e892dac3c6ba42aa6ac0c79a6a91a2b5cb4253e75c" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1728216d3244de4f14f14f8c15c79be1a7c67867d28d69b719690e2a19fb445" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40de3a2ba249dcb097e01be5e67a5ff53cf250397715a071a81543e8a832a920" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "pin-project-lite", + "socket2 0.5.3", + "windows-sys", +] + +[[package]] +name = "tokio-util" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "toml" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.19.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +dependencies = [ + "indexmap 2.0.0", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[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.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" + +[[package]] +name = "web-sys" +version = "0.3.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1eeca1c172a285ee6c2c84c341ccea837e7c01b12fbb2d0fe3c9e550ce49ec8" +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", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b10d0c968ba7f6166195e13d593af609ec2e3d24f916f081690695cf5eaffb2f" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "571d8d4e62f26d4932099a9efe89660e8bd5087775a2ab5cdd8b747b811f1058" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2229ad223e178db5fbbc8bd8d3835e51e566b8474bfca58d2e6150c48bb723cd" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "600956e2d840c194eedfc5d18f8242bc2e17c7775b6684488af3a9fff6fe3287" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea99ff3f8b49fb7a8e0d305e5aec485bd068c2ba691b6e277d29eaeac945868a" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1a05a1ece9a7a0d5a7ccf30ba2c33e3a61a30e042ffd247567d1de1d94120d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d419259aba16b663966e29e6d7c6ecfa0bb8425818bb96f6f1f3c3eb71a6e7b9" + +[[package]] +name = "winnow" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83817bbecf72c73bad717ee86820ebf286203d2e04c3951f3cd538869c897364" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] diff --git a/horustctl/Cargo.toml b/horustctl/Cargo.toml new file mode 100644 index 0000000..bb2b37f --- /dev/null +++ b/horustctl/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "horustctl" +version = "0.1.0" +edition = "2021" +authors = ["Federico Ponzi "] + +[dependencies] +anyhow = "~1.0" +log = "~0.4" +env_logger = "0.10.0" +crossbeam = "~0.8" +clap = {version = "~4.3", features = ["derive"]} diff --git a/horustctl/README.md b/horustctl/README.md new file mode 100644 index 0000000..e69de29 diff --git a/horustctl/src/main.rs b/horustctl/src/main.rs new file mode 100644 index 0000000..b11b77f --- /dev/null +++ b/horustctl/src/main.rs @@ -0,0 +1,93 @@ +use anyhow::{bail, Result}; +use clap::{Args, Parser, Subcommand}; +use env_logger::Env; +use log::{debug, error}; +use std::env; +use std::fs::{read, read_dir}; +use std::io::Write; +use std::os::unix::net::UnixStream; +use std::path::{Path, PathBuf}; + +/// Simple program to greet a person +#[derive(Parser, Debug)] +#[command(author, version, about, long_about = None)] +struct HourstctlArgs { + /// Optional if only one horust is running in the system. + #[arg(short, long)] + pid: Option, + + #[arg(short, long, default_value = "/var/run/horust/")] + sockets_folder_path: PathBuf, + + #[command(subcommand)] + commands: Commands, +} + +#[derive(Subcommand, Debug)] +enum Commands { + Status(StatusArgs), +} + +#[derive(Args, Debug)] +struct StatusArgs { + service_name: Option, +} + +fn main() -> Result<()> { + env_logger::Builder::from_env(Env::default().default_filter_or("debug")).init(); + let args = HourstctlArgs::parse(); + debug!("args: {args:?}"); + + let uds_path = get_uds_path(args.pid, args.sockets_folder_path)?; + match &args.commands { + Commands::Status(status_args) => { + debug!("Status command received: {status_args:?}"); + debug!("uds path : {uds_path:?}") + } + } + Ok(()) +} + +fn get_uds_path(pid: Option, sockets_folder_path: PathBuf) -> Result { + if !sockets_folder_path.exists() { + bail!("the specified sockets folder path '{sockets_folder_path:?}' does not exists."); + } + if !sockets_folder_path.is_dir() { + bail!("the specified sockets folder path '{sockets_folder_path:?}' is not a directory."); + } + + let socket_file_name = if pid.is_none() { + let mut readdir_iter = read_dir(&sockets_folder_path)?; + let ret = readdir_iter + .next() + .unwrap()? // check if it's there. + .file_name() + .to_string_lossy() + .to_string(); + if readdir_iter.count() > 0 { + bail!("There is more than one socket in {sockets_folder_path:?}.Please use --pid to specify the pid of the horust process you want to talk to."); + } + ret + } else { + pid.map(|p| format!("{p}.uds")).unwrap() + }; + debug!("Socket filename: {socket_file_name}"); + Ok(sockets_folder_path.join(socket_file_name)) +} + +fn handle_status(socket_path: PathBuf) -> Result<()> { + // `args` returns the arguments passed to the program + let args: Vec = env::args().map(|x| x.to_string()).collect(); + + // Connect to socket + let mut stream = match UnixStream::connect(&socket_path) { + Err(_) => panic!("server is not running"), + Ok(stream) => stream, + }; + + // Send message + if let Err(_) = stream.write(b"hello") { + panic!("couldn't send message") + } + Ok(()) +} diff --git a/horustctl/tests/cli.rs b/horustctl/tests/cli.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/horust/mod.rs b/src/horust/mod.rs index e807c16..c1b0fa6 100644 --- a/src/horust/mod.rs +++ b/src/horust/mod.rs @@ -20,6 +20,7 @@ mod formats; mod healthcheck; mod signal_safe; mod supervisor; +mod uds_messages; #[derive(Debug)] pub struct Horust { diff --git a/src/horust/uds_messages.rs b/src/horust/uds_messages.rs new file mode 100644 index 0000000..8032f5f --- /dev/null +++ b/src/horust/uds_messages.rs @@ -0,0 +1,6 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Deserialize, Serialize)] +enum Messages { + Status(Option), +} From b01d9743ec3edb0a0b7632df6cc5a2cc9eba5d3e Mon Sep 17 00:00:00 2001 From: Federico Ponzi Date: Fri, 18 Aug 2023 18:33:15 +0100 Subject: [PATCH 02/11] Sample uds message exchange --- Cargo.lock | 244 +++++++++++++++++++++++++++++++++++---- commands/Cargo.toml | 7 +- commands/README.md | 10 +- commands/src/lib.rs | 111 ++++++++++++++++-- commands/tests/simple.rs | 31 +++++ rustfmt.toml | 3 +- 6 files changed, 367 insertions(+), 39 deletions(-) create mode 100644 commands/tests/simple.rs diff --git a/Cargo.lock b/Cargo.lock index 166e6d5..8575afb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" dependencies = [ "gimli", ] @@ -103,9 +103,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" dependencies = [ "addr2line", "cc", @@ -470,7 +470,13 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.0" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" + +[[package]] +name = "h2" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" @@ -549,11 +555,14 @@ dependencies = [ name = "horust-commands-lib" version = "0.1.0" dependencies = [ - "log", + "anyhow", "prost", "prost-build", "serde", "serde_json", + "tokio", + "tracing", + "tracing-test", ] [[package]] @@ -634,7 +643,7 @@ dependencies = [ "httpdate", "itoa 1.0.2", "pin-project-lite", - "socket2", + "socket2 0.4.2", "tokio", "tower-service", "tracing", @@ -745,6 +754,16 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +[[package]] +name = "lock_api" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.20" @@ -757,6 +776,15 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata", +] + [[package]] name = "matches" version = "0.1.9" @@ -839,6 +867,16 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-traits" version = "0.2.14" @@ -860,9 +898,9 @@ dependencies = [ [[package]] name = "object" -version = "0.32.1" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" dependencies = [ "memchr", ] @@ -873,6 +911,35 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.3.5", + "smallvec", + "windows-targets", +] + [[package]] name = "percent-encoding" version = "2.1.0" @@ -891,9 +958,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.7" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" +checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" [[package]] name = "pin-utils" @@ -1117,9 +1184,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.6" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" +checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" dependencies = [ "aho-corasick", "memchr", @@ -1131,12 +1198,15 @@ name = "regex-automata" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] [[package]] name = "regex-syntax" -version = "0.6.26" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "remove_dir_all" @@ -1278,6 +1348,15 @@ dependencies = [ "serde", ] +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + [[package]] name = "shellexpand" version = "3.1.0" @@ -1293,12 +1372,27 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + [[package]] name = "slab" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" +[[package]] +name = "smallvec" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" + [[package]] name = "socket2" version = "0.4.9" @@ -1309,6 +1403,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "socket2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +dependencies = [ + "libc", + "windows-sys", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -1401,6 +1505,16 @@ dependencies = [ "syn 2.0.28", ] +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "tinyvec" version = "1.5.0" @@ -1418,21 +1532,34 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.29.1" +version = "1.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +checksum = "40de3a2ba249dcb097e01be5e67a5ff53cf250397715a071a81543e8a832a920" dependencies = [ - "autocfg", "backtrace", "bytes", "libc", "mio", "num_cpus", + "parking_lot", "pin-project-lite", - "socket2", + "signal-hook-registry", + "socket2 0.5.3", + "tokio-macros", "windows-sys", ] +[[package]] +name = "tokio-macros" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] + [[package]] name = "tokio-util" version = "0.7.8" @@ -1489,22 +1616,87 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.29" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] + [[package]] name = "tracing-core" -version = "0.1.21" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "tracing-test" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" +checksum = "3a2c0ff408fe918a94c428a3f2ad04e4afd5c95bbc08fcf868eff750c15728a4" dependencies = [ "lazy_static", + "tracing-core", + "tracing-subscriber", + "tracing-test-macro", +] + +[[package]] +name = "tracing-test-macro" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "258bc1c4f8e2e73a977812ab339d503e6feeb92700f6d07a6de4d321522d5c08" +dependencies = [ + "lazy_static", + "quote", + "syn 1.0.105", ] [[package]] @@ -1552,6 +1744,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "wait-timeout" version = "0.2.0" diff --git a/commands/Cargo.toml b/commands/Cargo.toml index e24d93d..03cde72 100644 --- a/commands/Cargo.toml +++ b/commands/Cargo.toml @@ -6,10 +6,15 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -log = "^0.4.19" serde = { version = "^1.0.183", features = ["derive"] } serde_json = "^1.0.104" prost = "^0.11.9" +anyhow = "~1.0" +tokio = {version = "~1.31", features = ["full"]} +tracing = "0.1" + +[dev-dependencies] +tracing-test = { version = "0.2", features = ["no-env-filter"] } [build-dependencies] prost-build = { version = "^0.11.9" } \ No newline at end of file diff --git a/commands/README.md b/commands/README.md index 9896f1e..c4456ae 100644 --- a/commands/README.md +++ b/commands/README.md @@ -1,4 +1,12 @@ ## Compile To compile this crate, you will need protobuf compiler. On debian-like you can run: -apt-get install protobuf-compiler \ No newline at end of file +apt-get install protobuf-compiler + + +## TODOs: +* do I need to https://docs.rs/tokio/latest/tokio/net/struct.UnixStream.html + `let ready = stream.ready(Interest::READABLE | Interest::WRITABLE).await?;` + + +https://docs.rs/tokio/latest/tokio/net/struct.UnixListener.html#method.accept diff --git a/commands/src/lib.rs b/commands/src/lib.rs index 6241c43..21cff63 100644 --- a/commands/src/lib.rs +++ b/commands/src/lib.rs @@ -1,21 +1,108 @@ mod proto; + +use anyhow::{bail, Context, Result}; use proto::tutorial::*; +use std::path::{Path, PathBuf}; +use tokio::io::{AsyncReadExt, AsyncWriteExt}; +use tokio::net::{UnixListener, UnixStream}; +use tracing::info; -pub fn create_large_shirt(color: String) -> Person { - let mut person = Person::default(); - person +pub struct CommandsUdsConnectionHandler { + socket: UnixStream, } +impl CommandsUdsConnectionHandler { + fn get_path(socket_folder: &Path, socket_name: u32) -> PathBuf { + socket_folder.join(format!("hourst-{socket_name}.sock")) + } + fn new(socket: UnixStream) -> Self { + Self { socket } + } + pub async fn new_client(socket_path: PathBuf) -> Result { + Ok(Self { + socket: UnixStream::connect(socket_path) + .await + .context("Could not create stream")?, + }) + } -pub fn add() { - println!("{:?}", create_large_shirt("blue".to_string())); -} + pub async fn client(mut self) -> Result<()> { + info!("client: sending data"); + self.socket + .write_all(b"Hello?") + .await // we write bytes, &[u8] + .context("Failed at writing onto the unix stream")?; + info!("client: Completed."); + // server is waiting for EOF. + self.socket.shutdown().await?; + + let mut buf = String::new(); + info!("client: reading back:"); + //Reads all bytes until EOF in this source, appending them to buf. + self.socket + .read_to_string(&mut buf) + .await // we write bytes, &[u8] + .context("Failed at writing onto the unix stream")?; + info!("Client received: {}", buf); + Ok(()) + } -#[cfg(test)] -mod tests { - use super::*; + pub async fn server(mut self) -> Result<()> { + let mut message = String::new(); + info!("Server: receving data"); + // Reads all bytes until EOF in this source, appending them to buf. + self.socket + .read_to_string(&mut message) + .await + .context("Failed at reading the unix stream")?; + info!("Server: Received data: {message}"); + self.socket + .write_all(message.as_bytes()) + .await + .context("Failed at reading the unix stream")?; - #[test] - fn it_works() { - add(); + info!("Server: has written back {}", message); + Ok(()) } } +pub struct CommandsUdsServer { + unix_listener: UnixListener, +} +impl CommandsUdsServer { + pub async fn new(socket_path: &Path) -> Result { + Ok(Self { + unix_listener: UnixListener::bind(socket_path) + .context("Could not create the unix socket")?, + }) + } + pub async fn start(&mut self) -> Result<()> { + // put the server logic in a loop to accept several connections + loop { + self.accept().await?; + } + Ok(()) + } + pub async fn accept(&mut self) -> Result<()> { + match self.unix_listener.accept().await { + Ok((stream, _addr)) => { + tokio::spawn(async move { + CommandsUdsConnectionHandler::new(stream) + .server() + .await + .unwrap(); + }) + .await? + } + Err(e) => { + bail!("error accepting connction: {e}") + } + }; + Ok(()) + } +} + +fn create_uds() {} + +fn listen_uds() {} + +fn send_message() {} +fn receive_message() {} diff --git a/commands/tests/simple.rs b/commands/tests/simple.rs new file mode 100644 index 0000000..f228a5a --- /dev/null +++ b/commands/tests/simple.rs @@ -0,0 +1,31 @@ +use anyhow::Result; +use horust_commands_lib::{CommandsUdsConnectionHandler, CommandsUdsServer}; +use std::path::PathBuf; +use tracing::info; +use tracing_test::traced_test; + +#[tokio::test] +#[traced_test] +async fn test_simple() -> Result<()> { + info!("Starting"); + + let socket_path: PathBuf = "/tmp/simple.sock".into(); + if socket_path.exists() { + std::fs::remove_file(&socket_path)?; + } + let socket_path2 = socket_path.clone(); + let s_handle = tokio::spawn(async move { + let mut uds = CommandsUdsServer::new(&socket_path2).await.unwrap(); + info!("uds created"); + uds.accept().await.unwrap(); + }); + let c_handle = tokio::spawn(async { + let client = CommandsUdsConnectionHandler::new_client(socket_path) + .await + .unwrap(); + client.client().await.unwrap(); + }); + s_handle.await?; + c_handle.await?; + Ok(()) +} diff --git a/rustfmt.toml b/rustfmt.toml index e9f9b84..a48e4ab 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -6,8 +6,7 @@ use_small_heuristics = "Default" reorder_imports = true reorder_modules = true remove_nested_parens = true -fn_args_layout = "Tall" -edition = "2015" +edition = "2021" merge_derives = true use_try_shorthand = false use_field_init_shorthand = false From cf7829a43b6dfc03550a1317b1f5998e185e3777 Mon Sep 17 00:00:00 2001 From: Federico Ponzi Date: Sun, 20 Aug 2023 14:28:46 +0100 Subject: [PATCH 03/11] refactor horust to a crate of the workspace --- .github/workflows/CI.yml | 2 +- Cargo.lock | 552 +++-- Cargo.toml | 46 +- commands/src/proto/tutorial.rs | 70 - horust/Cargo.lock | 1980 +++++++++++++++++ horust/Cargo.toml | 43 + {src => horust/src}/horust/bus.rs | 0 {src => horust/src}/horust/error.rs | 0 .../src}/horust/formats/horust_config.rs | 0 {src => horust/src}/horust/formats/mod.rs | 0 {src => horust/src}/horust/formats/service.rs | 2 +- .../src}/horust/healthcheck/checks.rs | 0 {src => horust/src}/horust/healthcheck/mod.rs | 0 {src => horust/src}/horust/mod.rs | 0 {src => horust/src}/horust/signal_safe.rs | 0 {src => horust/src}/horust/supervisor/mod.rs | 0 .../src}/horust/supervisor/process_spawner.rs | 0 .../src}/horust/supervisor/reaper.rs | 0 {src => horust/src}/horust/supervisor/repo.rs | 0 .../src}/horust/supervisor/service_handler.rs | 0 .../src}/horust/supervisor/signal_handling.rs | 0 {src => horust/src}/horust/uds_messages.rs | 0 {src => horust/src}/lib.rs | 0 {src => horust/src}/main.rs | 0 {tests => horust/tests}/horust.rs | 0 .../tests}/section_environment.rs | 0 {tests => horust/tests}/section_failure.rs | 0 {tests => horust/tests}/section_general.rs | 0 .../tests}/section_healthiness.rs | 0 {tests => horust/tests}/section_restart.rs | 0 .../tests}/section_termination.rs | 0 .../tests}/service_deserialization.rs | 2 +- {tests => horust/tests}/utils/mod.rs | 0 33 files changed, 2294 insertions(+), 403 deletions(-) delete mode 100644 commands/src/proto/tutorial.rs create mode 100644 horust/Cargo.lock create mode 100644 horust/Cargo.toml rename {src => horust/src}/horust/bus.rs (100%) rename {src => horust/src}/horust/error.rs (100%) rename {src => horust/src}/horust/formats/horust_config.rs (100%) rename {src => horust/src}/horust/formats/mod.rs (100%) rename {src => horust/src}/horust/formats/service.rs (99%) rename {src => horust/src}/horust/healthcheck/checks.rs (100%) rename {src => horust/src}/horust/healthcheck/mod.rs (100%) rename {src => horust/src}/horust/mod.rs (100%) rename {src => horust/src}/horust/signal_safe.rs (100%) rename {src => horust/src}/horust/supervisor/mod.rs (100%) rename {src => horust/src}/horust/supervisor/process_spawner.rs (100%) rename {src => horust/src}/horust/supervisor/reaper.rs (100%) rename {src => horust/src}/horust/supervisor/repo.rs (100%) rename {src => horust/src}/horust/supervisor/service_handler.rs (100%) rename {src => horust/src}/horust/supervisor/signal_handling.rs (100%) rename {src => horust/src}/horust/uds_messages.rs (100%) rename {src => horust/src}/lib.rs (100%) rename {src => horust/src}/main.rs (100%) rename {tests => horust/tests}/horust.rs (100%) rename {tests => horust/tests}/section_environment.rs (100%) rename {tests => horust/tests}/section_failure.rs (100%) rename {tests => horust/tests}/section_general.rs (100%) rename {tests => horust/tests}/section_healthiness.rs (100%) rename {tests => horust/tests}/section_restart.rs (100%) rename {tests => horust/tests}/section_termination.rs (100%) rename {tests => horust/tests}/service_deserialization.rs (92%) rename {tests => horust/tests}/utils/mod.rs (100%) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c989db1..0288103 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -125,7 +125,7 @@ jobs: with: use-cross: true command: build - args: --release --target ${{ matrix.target }} + args: --release --package horust --bin horust --target ${{ matrix.target }} - name: Package shell: bash diff --git a/Cargo.lock b/Cargo.lock index 8575afb..8ef0668 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "0.7.18" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a" dependencies = [ "memchr", ] @@ -42,9 +42,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" +checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" [[package]] name = "anstyle-parse" @@ -76,9 +76,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.68" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "assert_cmd" @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "bitflags" @@ -136,33 +136,35 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "bstr" -version = "1.1.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45ea9b00a7b3f2988e9a65ad3917e62123c38dba709b666506207be96d1790b" +checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" dependencies = [ "memchr", - "once_cell", - "regex-automata", + "regex-automata 0.3.6", "serde", ] [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "bytes" -version = "1.1.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -172,9 +174,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.4.4" +version = "4.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d7b8d5ec32af0fadc644bf1fd509a688c2103b185644bb1e29d164e0703136" +checksum = "03aef18ddf7d879c15ce20f04826ef8418101c7e528014c3eeea13321047dca3" dependencies = [ "clap_builder", "clap_derive", @@ -182,9 +184,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.4" +version = "4.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5179bb514e4d7c2051749d8fcefa2ed6d06a9f4e6d69faf3805f5d80b8cf8d56" +checksum = "f8ce6fffb678c9b80a70b6b6de0aad31df727623a70fd9a842c30cd573e2fa98" dependencies = [ "anstream", "anstyle", @@ -201,7 +203,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -232,9 +234,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.1" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if", "crossbeam-utils", @@ -242,9 +244,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -253,22 +255,22 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.5" +version = "0.9.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" dependencies = [ + "autocfg", "cfg-if", "crossbeam-utils", - "lazy_static", - "memoffset 0.6.4", + "memoffset 0.9.0", "scopeguard", ] [[package]] name = "crossbeam-queue" -version = "0.3.2" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b10ddc024425c88c2ad148c1b0fd53f4c6d38db9697c9f1588381212fa657c9" +checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" dependencies = [ "cfg-if", "crossbeam-utils", @@ -276,12 +278,11 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.10" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ "cfg-if", - "once_cell", ] [[package]] @@ -292,22 +293,23 @@ checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" [[package]] name = "dirs" -version = "4.0.0" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ "dirs-sys", ] [[package]] name = "dirs-sys" -version = "0.3.7" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ "libc", + "option-ext", "redox_users", - "winapi", + "windows-sys", ] [[package]] @@ -318,15 +320,15 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "either" -version = "1.6.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "encoding_rs" -version = "0.8.29" +version = "0.8.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a74ea89a0a1b98f6332de42c95baff457ada66d1cb4030f9ff151b2041a1c746" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" dependencies = [ "cfg-if", ] @@ -344,11 +346,17 @@ dependencies = [ "termcolor", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" dependencies = [ "errno-dragonfly", "libc", @@ -394,11 +402,10 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.0.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ - "matches", "percent-encoding", ] @@ -410,44 +417,43 @@ checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" [[package]] name = "futures-channel" -version = "0.3.17" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.17" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-io" -version = "0.3.17" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-sink" -version = "0.3.17" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.17" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-util" -version = "0.3.17" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ - "autocfg", "futures-core", "futures-io", "futures-task", @@ -459,13 +465,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", - "wasi 0.10.2+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -476,15 +482,9 @@ checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" [[package]] name = "h2" -version = "0.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" - -[[package]] -name = "h2" -version = "0.3.21" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" dependencies = [ "bytes", "fnv", @@ -492,7 +492,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", @@ -506,25 +506,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] -name = "heck" -version = "0.4.0" +name = "hashbrown" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" [[package]] -name = "hermit-abi" -version = "0.1.19" +name = "heck" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "horust" @@ -578,20 +575,20 @@ dependencies = [ [[package]] name = "http" -version = "0.2.5" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", - "itoa 0.4.8", + "itoa", ] [[package]] name = "http-body" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", @@ -606,9 +603,9 @@ checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "humantime" @@ -641,9 +638,9 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 1.0.2", + "itoa", "pin-project-lite", - "socket2 0.4.2", + "socket2 0.4.9", "tokio", "tower-service", "tracing", @@ -652,11 +649,10 @@ dependencies = [ [[package]] name = "idna" -version = "0.2.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ - "matches", "unicode-bidi", "unicode-normalization", ] @@ -668,35 +664,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", ] [[package]] -name = "io-lifetimes" -version = "1.0.10" +name = "indexmap" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ - "hermit-abi 0.3.1", - "libc", - "windows-sys", + "equivalent", + "hashbrown 0.14.0", ] [[package]] name = "ipnet" -version = "2.3.1" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" +checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" [[package]] name = "is-terminal" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", - "rustix 0.37.11", + "hermit-abi", + "rustix", "windows-sys", ] @@ -711,21 +705,15 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - -[[package]] -name = "itoa" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.55" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" dependencies = [ "wasm-bindgen", ] @@ -742,12 +730,6 @@ version = "0.2.148" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" -[[package]] -name = "linux-raw-sys" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" - [[package]] name = "linux-raw-sys" version = "0.4.5" @@ -782,44 +764,38 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] -[[package]] -name = "matches" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" - [[package]] name = "memchr" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memoffset" -version = "0.6.4" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" dependencies = [ "autocfg", ] [[package]] name = "memoffset" -version = "0.7.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ "autocfg", ] [[package]] name = "mime" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" @@ -837,7 +813,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys", ] @@ -879,20 +855,20 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] [[package]] name = "num_cpus" -version = "1.13.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.1.19", + "hermit-abi", "libc", ] @@ -907,9 +883,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.14.0" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "option-ext" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "overload" @@ -942,9 +924,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.1.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "petgraph" @@ -953,7 +935,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 1.9.3", ] [[package]] @@ -970,9 +952,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "ppv-lite86" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "predicates" @@ -997,9 +979,9 @@ checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" [[package]] name = "predicates-tree" -version = "1.0.4" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "338c7be2905b732ae3984a2f40032b5e94fd8f52505b186c7d4d68d193445df7" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" dependencies = [ "predicates-core", "termtree", @@ -1012,7 +994,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" dependencies = [ "proc-macro2", - "syn 1.0.105", + "syn 1.0.109", ] [[package]] @@ -1051,7 +1033,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 1.0.105", + "syn 1.0.109", "tempfile", "which", ] @@ -1066,7 +1048,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn 1.0.105", + "syn 1.0.109", ] [[package]] @@ -1080,9 +1062,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -1108,7 +1090,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core 0.6.3", + "rand_core 0.6.4", ] [[package]] @@ -1118,7 +1100,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.3", + "rand_core 0.6.4", ] [[package]] @@ -1138,9 +1120,9 @@ checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" [[package]] name = "rand_core" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom", ] @@ -1156,9 +1138,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.10" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags 1.3.2", ] @@ -1174,23 +1156,25 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom", - "redox_syscall 0.2.10", + "redox_syscall 0.2.16", + "thiserror", ] [[package]] name = "regex" -version = "1.7.3" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" +checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-automata 0.3.6", + "regex-syntax 0.7.4", ] [[package]] @@ -1199,7 +1183,18 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "regex-syntax", + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.7.4", ] [[package]] @@ -1208,6 +1203,12 @@ version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +[[package]] +name = "regex-syntax" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" + [[package]] name = "remove_dir_all" version = "0.5.3" @@ -1257,20 +1258,6 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" -[[package]] -name = "rustix" -version = "0.37.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85597d61f83914ddeba6a47b3b8ffe7365107221c2e557ed94426489fefb5f77" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.1", - "windows-sys", -] - [[package]] name = "rustix" version = "0.38.8" @@ -1280,21 +1267,21 @@ dependencies = [ "bitflags 2.4.0", "errno", "libc", - "linux-raw-sys 0.4.5", + "linux-raw-sys", "windows-sys", ] [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" @@ -1313,7 +1300,7 @@ checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1322,16 +1309,16 @@ version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" dependencies = [ - "itoa 1.0.2", + "itoa", "ryu", "serde", ] [[package]] name = "serde_spanned" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" dependencies = [ "serde", ] @@ -1343,7 +1330,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 1.0.2", + "itoa", "ryu", "serde", ] @@ -1383,9 +1370,12 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.5" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +dependencies = [ + "autocfg", +] [[package]] name = "smallvec" @@ -1427,9 +1417,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.105" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -1438,9 +1428,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" dependencies = [ "proc-macro2", "quote", @@ -1459,31 +1449,31 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.7.1" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc02fddf48964c42031a0b3fe0428320ecf3a73c401040fc0096f97794310651" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.38.8", + "rustix", "windows-sys", ] [[package]] name = "termcolor" -version = "1.1.2" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ "winapi-util", ] [[package]] name = "termtree" -version = "0.2.3" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" @@ -1502,7 +1492,7 @@ checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1517,18 +1507,18 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83b2a3d4d9091d0abd7eba4dc2710b1718583bd4d8992e2190720ea38f391f7" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" dependencies = [ "tinyvec_macros", ] [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" @@ -1557,7 +1547,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1576,9 +1566,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.3" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b403acf6f2bb0859c93c7f0d967cb4a75a7ac552100f9322faf64dc047669b21" +checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" dependencies = [ "serde", "serde_spanned", @@ -1588,20 +1578,20 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.8" +version = "0.19.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" +checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" dependencies = [ - "indexmap", + "indexmap 2.0.0", "serde", "serde_spanned", "toml_datetime", @@ -1610,9 +1600,9 @@ dependencies = [ [[package]] name = "tower-service" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" @@ -1634,7 +1624,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1696,45 +1686,44 @@ checksum = "258bc1c4f8e2e73a977812ab339d503e6feeb92700f6d07a6de4d321522d5c08" dependencies = [ "lazy_static", "quote", - "syn 1.0.105", + "syn 1.0.109", ] [[package]] name = "try-lock" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "unicode-bidi" -version = "0.3.7" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.4" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-normalization" -version = "0.1.19" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" dependencies = [ "tinyvec", ] [[package]] name = "url" -version = "2.2.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" dependencies = [ "form_urlencoded", "idna", - "matches", "percent-encoding", ] @@ -1761,20 +1750,13 @@ dependencies = [ [[package]] name = "want" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" dependencies = [ - "log", "try-lock", ] -[[package]] -name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1783,9 +1765,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.78" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1793,24 +1775,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.78" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", - "lazy_static", "log", + "once_cell", "proc-macro2", "quote", - "syn 1.0.105", + "syn 2.0.29", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.28" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39" +checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" dependencies = [ "cfg-if", "js-sys", @@ -1820,9 +1802,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.78" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1830,28 +1812,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.78" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 1.0.105", + "syn 2.0.29", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.78" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "web-sys" -version = "0.3.55" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" dependencies = [ "js-sys", "wasm-bindgen", @@ -1910,9 +1892,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -1925,51 +1907,51 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.4.1" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28" +checksum = "d09770118a7eb1ccaf4a594a221334119a44a814fcb0d31c5b85e83e97227a97" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index d3aa42c..1c6420e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,46 +1,2 @@ -[package] -name = "horust" -version = "0.1.7" -authors = ["Federico Ponzi "] -description = "A complete supervisor and init system, designed for running in containers." -edition = "2021" -license = "MIT" -repository = "https://github.com/FedericoPonzi/horust" -homepage = "https://github.com/FedericoPonzi/horust" -readme = "README.md" -keywords = ["init", "container", "supervisor"] -categories = ["command-line-utilities"] -include = ["src/**/*", "Cargo.*", "LICENSE.txt", "README.md", "/example_services/**/*"] - -[dependencies] -clap = { version = "4.4.4", features = ["derive"] } -crossbeam = "~0.8" -env_logger = "0.10.0" -humantime-serde = "~1.1" -libc = "0.2.148" -log = "~0.4" -nix = "~0.26" -reqwest = { version = "0.11.20", features = ["blocking", "json"], optional = true, default-features = false } -serde = { version = "~1.0", features = ["derive"] } -shlex = "~1.1" -toml = "~0.7" -maplit = "~1.0" -shellexpand = "~3.1" -anyhow = "~1.0" -thiserror = "~1.0" - -[features] -default = ["http-healthcheck"] -http-healthcheck = ["reqwest"] - -[dev-dependencies] -assert_cmd = "2.0.12" -predicates = "~3.0" -tempdir = "~0.3" -rand = "~0.8" - -[profile.release] -strip = "symbols" - [workspace] -members = ["horustctl", "commands"] +members = ["horustctl", "commands", "horust"] diff --git a/commands/src/proto/tutorial.rs b/commands/src/proto/tutorial.rs deleted file mode 100644 index 28182cc..0000000 --- a/commands/src/proto/tutorial.rs +++ /dev/null @@ -1,70 +0,0 @@ -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Person { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - /// Unique ID number for this person. - #[prost(int32, tag = "2")] - pub id: i32, - #[prost(string, tag = "3")] - pub email: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "4")] - pub phones: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `Person`. -pub mod person { - #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct PhoneNumber { - #[prost(string, tag = "1")] - pub number: ::prost::alloc::string::String, - #[prost(enumeration = "PhoneType", tag = "2")] - pub r#type: i32, - } - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum PhoneType { - Mobile = 0, - Home = 1, - Work = 2, - } - impl PhoneType { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - PhoneType::Mobile => "MOBILE", - PhoneType::Home => "HOME", - PhoneType::Work => "WORK", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "MOBILE" => Some(Self::Mobile), - "HOME" => Some(Self::Home), - "WORK" => Some(Self::Work), - _ => None, - } - } - } -} -/// Our address book file is just one of these. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct AddressBook { - #[prost(message, repeated, tag = "1")] - pub people: ::prost::alloc::vec::Vec, -} diff --git a/horust/Cargo.lock b/horust/Cargo.lock new file mode 100644 index 0000000..eaa9b25 --- /dev/null +++ b/horust/Cargo.lock @@ -0,0 +1,1980 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" + +[[package]] +name = "anstyle-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" + +[[package]] +name = "assert_cmd" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88903cb14723e4d4003335bb7f8a14f27691649105346a0f0957466c096adfe6" +dependencies = [ + "anstyle", + "bstr", + "doc-comment", + "predicates", + "predicates-core", + "predicates-tree", + "wait-timeout", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + +[[package]] +name = "bstr" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45ea9b00a7b3f2988e9a65ad3917e62123c38dba709b666506207be96d1790b" +dependencies = [ + "memchr", + "once_cell", + "regex-automata", + "serde", +] + +[[package]] +name = "bumpalo" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" + +[[package]] +name = "bytes" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "4.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd" +dependencies = [ + "clap_builder", + "clap_derive", + "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.28", +] + +[[package]] +name = "clap_lex" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "crossbeam" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c" +dependencies = [ + "cfg-if", + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "lazy_static", + "memoffset 0.6.4", + "scopeguard", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b10ddc024425c88c2ad148c1b0fd53f4c6d38db9697c9f1588381212fa657c9" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "encoding_rs" +version = "0.8.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a74ea89a0a1b98f6332de42c95baff457ada66d1cb4030f9ff151b2041a1c746" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fastrand" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +dependencies = [ + "num-traits", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + +[[package]] +name = "futures-channel" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" + +[[package]] +name = "futures-io" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" + +[[package]] +name = "futures-sink" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" + +[[package]] +name = "futures-task" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" + +[[package]] +name = "futures-util" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" +dependencies = [ + "autocfg", + "futures-core", + "futures-io", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.10.2+wasi-snapshot-preview1", +] + +[[package]] +name = "gimli" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" + +[[package]] +name = "h2" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9de88456263e249e241fcd211d3954e2c9b0ef7ccfc235a444eb367cae3689" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + +[[package]] +name = "horust" +version = "0.1.7" +dependencies = [ + "anyhow", + "assert_cmd", + "clap", + "crossbeam", + "env_logger", + "humantime-serde", + "libc", + "log", + "maplit", + "nix", + "predicates", + "rand 0.8.5", + "reqwest", + "serde", + "shellexpand", + "shlex", + "tempdir", + "thiserror", + "toml", +] + +[[package]] +name = "horust-commands-lib" +version = "0.1.0" +dependencies = [ + "anyhow", + "prost", + "prost-build", + "serde", + "serde_json", + "tokio", + "tracing", + "tracing-test", +] + +[[package]] +name = "horustctl" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "crossbeam", + "env_logger", + "log", +] + +[[package]] +name = "http" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" +dependencies = [ + "bytes", + "fnv", + "itoa 0.4.8", +] + +[[package]] +name = "http-body" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "496ce29bb5a52785b44e0f7ca2847ae0bb839c9bd28f69acac9b99d461c0c04c" + +[[package]] +name = "httpdate" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "humantime-serde" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c" +dependencies = [ + "humantime", + "serde", +] + +[[package]] +name = "hyper" +version = "0.14.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42dc3c131584288d375f2d07f822b0cb012d8c6fb899a5b9fdb3cb7eb9b6004f" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa 1.0.2", + "pin-project-lite", + "socket2 0.4.2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys", +] + +[[package]] +name = "ipnet" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" + +[[package]] +name = "is-terminal" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix 0.37.11", + "windows-sys", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + +[[package]] +name = "itoa" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" + +[[package]] +name = "js-sys" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "linux-raw-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" + +[[package]] +name = "linux-raw-sys" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" + +[[package]] +name = "lock_api" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "matches" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" + +[[package]] +name = "memchr" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "memoffset" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +dependencies = [ + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys", +] + +[[package]] +name = "multimap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" + +[[package]] +name = "nix" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset 0.7.1", + "pin-utils", + "static_assertions", +] + +[[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi 0.1.19", + "libc", +] + +[[package]] +name = "object" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.3.5", + "smallvec", + "windows-targets", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "petgraph" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "ppv-lite86" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" + +[[package]] +name = "predicates" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09963355b9f467184c04017ced4a2ba2d75cbcb4e7462690d388233253d4b1a9" +dependencies = [ + "anstyle", + "difflib", + "float-cmp", + "itertools", + "normalize-line-endings", + "predicates-core", + "regex", +] + +[[package]] +name = "predicates-core" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" + +[[package]] +name = "predicates-tree" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "338c7be2905b732ae3984a2f40032b5e94fd8f52505b186c7d4d68d193445df7" +dependencies = [ + "predicates-core", + "termtree", +] + +[[package]] +name = "prettyplease" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +dependencies = [ + "proc-macro2", + "syn 1.0.105", +] + +[[package]] +name = "proc-macro2" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" +dependencies = [ + "bytes", + "heck", + "itertools", + "lazy_static", + "log", + "multimap", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn 1.0.105", + "tempfile", + "which", +] + +[[package]] +name = "prost-derive" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 1.0.105", +] + +[[package]] +name = "prost-types" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" +dependencies = [ + "prost", +] + +[[package]] +name = "quote" +version = "1.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +dependencies = [ + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "rdrand", + "winapi", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core 0.6.3", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.3", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "redox_syscall" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_users" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +dependencies = [ + "getrandom", + "redox_syscall 0.2.10", +] + +[[package]] +name = "regex" +version = "1.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "reqwest" +version = "0.11.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustix" +version = "0.37.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85597d61f83914ddeba6a47b3b8ffe7365107221c2e557ed94426489fefb5f77" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.3.1", + "windows-sys", +] + +[[package]] +name = "rustix" +version = "0.38.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys 0.4.5", + "windows-sys", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "serde" +version = "1.0.183" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.183" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] + +[[package]] +name = "serde_json" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +dependencies = [ + "itoa 1.0.2", + "ryu", + "serde", +] + +[[package]] +name = "serde_spanned" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4" +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 1.0.2", + "ryu", + "serde", +] + +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shellexpand" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b" +dependencies = [ + "dirs", +] + +[[package]] +name = "shlex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" + +[[package]] +name = "smallvec" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" + +[[package]] +name = "socket2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "socket2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempdir" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" +dependencies = [ + "rand 0.4.6", + "remove_dir_all", +] + +[[package]] +name = "tempfile" +version = "3.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc02fddf48964c42031a0b3fe0428320ecf3a73c401040fc0096f97794310651" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall 0.3.5", + "rustix 0.38.8", + "windows-sys", +] + +[[package]] +name = "termcolor" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "termtree" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16" + +[[package]] +name = "thiserror" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] + +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "tinyvec" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83b2a3d4d9091d0abd7eba4dc2710b1718583bd4d8992e2190720ea38f391f7" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40de3a2ba249dcb097e01be5e67a5ff53cf250397715a071a81543e8a832a920" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2 0.5.3", + "tokio-macros", + "windows-sys", +] + +[[package]] +name = "tokio-macros" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] + +[[package]] +name = "tokio-util" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b403acf6f2bb0859c93c7f0d967cb4a75a7ac552100f9322faf64dc047669b21" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.19.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tower-service" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] + +[[package]] +name = "tracing-core" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "tracing-test" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a2c0ff408fe918a94c428a3f2ad04e4afd5c95bbc08fcf868eff750c15728a4" +dependencies = [ + "lazy_static", + "tracing-core", + "tracing-subscriber", + "tracing-test-macro", +] + +[[package]] +name = "tracing-test-macro" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "258bc1c4f8e2e73a977812ab339d503e6feeb92700f6d07a6de4d321522d5c08" +dependencies = [ + "lazy_static", + "quote", + "syn 1.0.105", +] + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + +[[package]] +name = "unicode-bidi" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" + +[[package]] +name = "unicode-ident" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" + +[[package]] +name = "unicode-normalization" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[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.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn 1.0.105", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.105", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" + +[[package]] +name = "web-sys" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "which" +version = "4.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +dependencies = [ + "either", + "libc", + "once_cell", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +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", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "winnow" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] diff --git a/horust/Cargo.toml b/horust/Cargo.toml new file mode 100644 index 0000000..fb02f69 --- /dev/null +++ b/horust/Cargo.toml @@ -0,0 +1,43 @@ +[package] +name = "horust" +version = "0.1.7" +authors = ["Federico Ponzi "] +description = "A complete supervisor and init system, designed for running in containers." +edition = "2021" +license = "MIT" +repository = "https://github.com/FedericoPonzi/horust" +homepage = "https://github.com/FedericoPonzi/horust" +readme = "README.md" +keywords = ["init", "container", "supervisor"] +categories = ["command-line-utilities"] +include = ["src/**/*", "Cargo.*", "LICENSE.txt", "README.md", "/example_services/**/*"] + +[dependencies] +clap = { version = "4.3.21", features = ["derive"] } +crossbeam = "~0.8" +env_logger = "0.10.0" +humantime-serde = "~1.1" +libc = "0.2.147" +log = "~0.4" +nix = "~0.26" +reqwest = { version = "0.11.18", features = ["blocking", "json"], optional = true, default-features = false } +serde = { version = "~1.0", features = ["derive"] } +shlex = "~1.1" +toml = "~0.7" +maplit = "~1.0" +shellexpand = "~3.1" +anyhow = "~1.0" +thiserror = "~1.0" + +[features] +default = ["http-healthcheck"] +http-healthcheck = ["reqwest"] + +[dev-dependencies] +assert_cmd = "2.0.12" +predicates = "~3.0" +tempdir = "~0.3" +rand = "~0.8" + +[profile.release] +strip = "symbols" diff --git a/src/horust/bus.rs b/horust/src/horust/bus.rs similarity index 100% rename from src/horust/bus.rs rename to horust/src/horust/bus.rs diff --git a/src/horust/error.rs b/horust/src/horust/error.rs similarity index 100% rename from src/horust/error.rs rename to horust/src/horust/error.rs diff --git a/src/horust/formats/horust_config.rs b/horust/src/horust/formats/horust_config.rs similarity index 100% rename from src/horust/formats/horust_config.rs rename to horust/src/horust/formats/horust_config.rs diff --git a/src/horust/formats/mod.rs b/horust/src/horust/formats/mod.rs similarity index 100% rename from src/horust/formats/mod.rs rename to horust/src/horust/formats/mod.rs diff --git a/src/horust/formats/service.rs b/horust/src/horust/formats/service.rs similarity index 99% rename from src/horust/formats/service.rs rename to horust/src/horust/formats/service.rs index edda7af..0e74dd0 100644 --- a/src/horust/formats/service.rs +++ b/horust/src/horust/formats/service.rs @@ -15,7 +15,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; use crate::horust::error::{ValidationError, ValidationErrors}; pub fn get_sample_service() -> &'static str { - include_str!("../../../example_services/sample_service.toml") + include_str!("../../../../example_services/sample_service.toml") } pub type ServiceName = String; diff --git a/src/horust/healthcheck/checks.rs b/horust/src/horust/healthcheck/checks.rs similarity index 100% rename from src/horust/healthcheck/checks.rs rename to horust/src/horust/healthcheck/checks.rs diff --git a/src/horust/healthcheck/mod.rs b/horust/src/horust/healthcheck/mod.rs similarity index 100% rename from src/horust/healthcheck/mod.rs rename to horust/src/horust/healthcheck/mod.rs diff --git a/src/horust/mod.rs b/horust/src/horust/mod.rs similarity index 100% rename from src/horust/mod.rs rename to horust/src/horust/mod.rs diff --git a/src/horust/signal_safe.rs b/horust/src/horust/signal_safe.rs similarity index 100% rename from src/horust/signal_safe.rs rename to horust/src/horust/signal_safe.rs diff --git a/src/horust/supervisor/mod.rs b/horust/src/horust/supervisor/mod.rs similarity index 100% rename from src/horust/supervisor/mod.rs rename to horust/src/horust/supervisor/mod.rs diff --git a/src/horust/supervisor/process_spawner.rs b/horust/src/horust/supervisor/process_spawner.rs similarity index 100% rename from src/horust/supervisor/process_spawner.rs rename to horust/src/horust/supervisor/process_spawner.rs diff --git a/src/horust/supervisor/reaper.rs b/horust/src/horust/supervisor/reaper.rs similarity index 100% rename from src/horust/supervisor/reaper.rs rename to horust/src/horust/supervisor/reaper.rs diff --git a/src/horust/supervisor/repo.rs b/horust/src/horust/supervisor/repo.rs similarity index 100% rename from src/horust/supervisor/repo.rs rename to horust/src/horust/supervisor/repo.rs diff --git a/src/horust/supervisor/service_handler.rs b/horust/src/horust/supervisor/service_handler.rs similarity index 100% rename from src/horust/supervisor/service_handler.rs rename to horust/src/horust/supervisor/service_handler.rs diff --git a/src/horust/supervisor/signal_handling.rs b/horust/src/horust/supervisor/signal_handling.rs similarity index 100% rename from src/horust/supervisor/signal_handling.rs rename to horust/src/horust/supervisor/signal_handling.rs diff --git a/src/horust/uds_messages.rs b/horust/src/horust/uds_messages.rs similarity index 100% rename from src/horust/uds_messages.rs rename to horust/src/horust/uds_messages.rs diff --git a/src/lib.rs b/horust/src/lib.rs similarity index 100% rename from src/lib.rs rename to horust/src/lib.rs diff --git a/src/main.rs b/horust/src/main.rs similarity index 100% rename from src/main.rs rename to horust/src/main.rs diff --git a/tests/horust.rs b/horust/tests/horust.rs similarity index 100% rename from tests/horust.rs rename to horust/tests/horust.rs diff --git a/tests/section_environment.rs b/horust/tests/section_environment.rs similarity index 100% rename from tests/section_environment.rs rename to horust/tests/section_environment.rs diff --git a/tests/section_failure.rs b/horust/tests/section_failure.rs similarity index 100% rename from tests/section_failure.rs rename to horust/tests/section_failure.rs diff --git a/tests/section_general.rs b/horust/tests/section_general.rs similarity index 100% rename from tests/section_general.rs rename to horust/tests/section_general.rs diff --git a/tests/section_healthiness.rs b/horust/tests/section_healthiness.rs similarity index 100% rename from tests/section_healthiness.rs rename to horust/tests/section_healthiness.rs diff --git a/tests/section_restart.rs b/horust/tests/section_restart.rs similarity index 100% rename from tests/section_restart.rs rename to horust/tests/section_restart.rs diff --git a/tests/section_termination.rs b/horust/tests/section_termination.rs similarity index 100% rename from tests/section_termination.rs rename to horust/tests/section_termination.rs diff --git a/tests/service_deserialization.rs b/horust/tests/service_deserialization.rs similarity index 92% rename from tests/service_deserialization.rs rename to horust/tests/service_deserialization.rs index c8afad5..96e61cb 100644 --- a/tests/service_deserialization.rs +++ b/horust/tests/service_deserialization.rs @@ -23,7 +23,7 @@ mod tests { fn should_deserialize() { // TODO: this shouldn't be an integration test, but rather a unit test. let base = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - let services_path = base.join("example_services"); + let services_path = base.join("../../example_services"); let services = list_files(&services_path).unwrap().len(); let horust = Horust::from_services_dirs(&[services_path]).unwrap(); assert_eq!(horust.get_services().len(), services); diff --git a/tests/utils/mod.rs b/horust/tests/utils/mod.rs similarity index 100% rename from tests/utils/mod.rs rename to horust/tests/utils/mod.rs From 854c9b5c8d33688d1ad9ca2653d0c96aef2813db Mon Sep 17 00:00:00 2001 From: Federico Ponzi Date: Sun, 20 Aug 2023 19:37:33 +0100 Subject: [PATCH 04/11] Keep uds implementation sync to avoid pulling tokio runtime --- Cargo.lock | 206 +-------------------- commands/Cargo.toml | 5 +- commands/README.md | 1 + commands/src/commands.proto | 53 ++++-- commands/src/lib.rs | 198 +++++++++++--------- commands/src/proto/mod.rs | 2 +- commands/tests/simple.rs | 64 +++++-- horust/Cargo.toml | 3 +- horust/src/horust/commands_handler.rs | 41 ++++ horust/src/horust/formats/horust_config.rs | 52 ------ horust/src/horust/formats/mod.rs | 2 - horust/src/horust/mod.rs | 48 +++-- horust/src/main.rs | 45 +++-- horust/tests/service_deserialization.rs | 31 ---- 14 files changed, 307 insertions(+), 444 deletions(-) create mode 100644 horust/src/horust/commands_handler.rs delete mode 100644 horust/src/horust/formats/horust_config.rs delete mode 100644 horust/tests/service_deserialization.rs diff --git a/Cargo.lock b/Cargo.lock index 8ef0668..2a2af09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -141,7 +141,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" dependencies = [ "memchr", - "regex-automata 0.3.6", + "regex-automata", "serde", ] @@ -532,6 +532,7 @@ dependencies = [ "clap", "crossbeam", "env_logger", + "horust-commands-lib", "humantime-serde", "libc", "log", @@ -553,13 +554,12 @@ name = "horust-commands-lib" version = "0.1.0" dependencies = [ "anyhow", + "env_logger", + "log", "prost", "prost-build", "serde", "serde_json", - "tokio", - "tracing", - "tracing-test", ] [[package]] @@ -736,16 +736,6 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" -[[package]] -name = "lock_api" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.20" @@ -758,15 +748,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata 0.1.10", -] - [[package]] name = "memchr" version = "2.5.0" @@ -843,16 +824,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - [[package]] name = "num-traits" version = "0.2.16" @@ -893,35 +864,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.3.5", - "smallvec", - "windows-targets", -] - [[package]] name = "percent-encoding" version = "2.3.0" @@ -1173,17 +1115,8 @@ checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.6", - "regex-syntax 0.7.4", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", + "regex-automata", + "regex-syntax", ] [[package]] @@ -1194,15 +1127,9 @@ checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.4", + "regex-syntax", ] -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - [[package]] name = "regex-syntax" version = "0.7.4" @@ -1335,15 +1262,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sharded-slab" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" -dependencies = [ - "lazy_static", -] - [[package]] name = "shellexpand" version = "3.1.0" @@ -1359,15 +1277,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - [[package]] name = "slab" version = "0.4.8" @@ -1377,12 +1286,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "smallvec" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" - [[package]] name = "socket2" version = "0.4.9" @@ -1495,16 +1398,6 @@ dependencies = [ "syn 2.0.29", ] -[[package]] -name = "thread_local" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" -dependencies = [ - "cfg-if", - "once_cell", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -1531,25 +1424,11 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot", "pin-project-lite", - "signal-hook-registry", "socket2 0.5.3", - "tokio-macros", "windows-sys", ] -[[package]] -name = "tokio-macros" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.29", -] - [[package]] name = "tokio-util" version = "0.7.8" @@ -1612,21 +1491,9 @@ checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "pin-project-lite", - "tracing-attributes", "tracing-core", ] -[[package]] -name = "tracing-attributes" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.29", -] - [[package]] name = "tracing-core" version = "0.1.31" @@ -1634,59 +1501,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" -dependencies = [ - "lazy_static", - "log", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" -dependencies = [ - "matchers", - "nu-ansi-term", - "once_cell", - "regex", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", -] - -[[package]] -name = "tracing-test" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a2c0ff408fe918a94c428a3f2ad04e4afd5c95bbc08fcf868eff750c15728a4" -dependencies = [ - "lazy_static", - "tracing-core", - "tracing-subscriber", - "tracing-test-macro", -] - -[[package]] -name = "tracing-test-macro" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bc1c4f8e2e73a977812ab339d503e6feeb92700f6d07a6de4d321522d5c08" -dependencies = [ - "lazy_static", - "quote", - "syn 1.0.109", ] [[package]] @@ -1733,12 +1547,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - [[package]] name = "wait-timeout" version = "0.2.0" diff --git a/commands/Cargo.toml b/commands/Cargo.toml index 03cde72..700149a 100644 --- a/commands/Cargo.toml +++ b/commands/Cargo.toml @@ -10,11 +10,10 @@ serde = { version = "^1.0.183", features = ["derive"] } serde_json = "^1.0.104" prost = "^0.11.9" anyhow = "~1.0" -tokio = {version = "~1.31", features = ["full"]} -tracing = "0.1" +log = "~0.4" [dev-dependencies] -tracing-test = { version = "0.2", features = ["no-env-filter"] } +env_logger = "~0.10" [build-dependencies] prost-build = { version = "^0.11.9" } \ No newline at end of file diff --git a/commands/README.md b/commands/README.md index c4456ae..1be48d8 100644 --- a/commands/README.md +++ b/commands/README.md @@ -10,3 +10,4 @@ apt-get install protobuf-compiler https://docs.rs/tokio/latest/tokio/net/struct.UnixListener.html#method.accept +https://crates.io/crates/prost-reflect \ No newline at end of file diff --git a/commands/src/commands.proto b/commands/src/commands.proto index cb5149e..9b4b9de 100644 --- a/commands/src/commands.proto +++ b/commands/src/commands.proto @@ -1,26 +1,41 @@ syntax = "proto3"; -package tutorial; +package messages; -message Person { - string name = 1; - int32 id = 2; // Unique ID number for this person. - string email = 3; - - enum PhoneType { - MOBILE = 0; - HOME = 1; - WORK = 2; +message HorustMsgMessage { + oneof request_type { + HorustMsgServiceStatusRequest status_request = 1; + HorustMsgServiceStatusResponse status_response = 2; + HorustMsgServiceChangeRequest change_request = 3; } +} +message HorustMsgError { - message PhoneNumber { - string number = 1; - PhoneType type = 2; - } +} + +message HorustMsgServiceStatusRequest { + string service_name = 1; +} - repeated PhoneNumber phones = 4; +message HorustMsgServiceStatusResponse { + string service_name = 1; + HorustMsgServiceStatus service_status = 2; } -// Our address book file is just one of these. -message AddressBook { - repeated Person people = 1; -} \ No newline at end of file +message HorustMsgServiceChangeRequest { + string service_name = 1; + HorustMsgServiceStatus service_status = 2; +} + +// return the current status - similar to HorustServiceStatusReponse. +message HorustMsgServiceChangeResponse { + string service_name = 1; + HorustMsgServiceStatus service_status = 2; +} + +enum HorustMsgServiceStatus { + STOPPED = 0; + STARTED = 1; + KILLED = 2; + SHUTTING_DOWN = 3; + RUNNING = 4; +} diff --git a/commands/src/lib.rs b/commands/src/lib.rs index 21cff63..4d6974a 100644 --- a/commands/src/lib.rs +++ b/commands/src/lib.rs @@ -1,108 +1,132 @@ +extern crate core; + mod proto; -use anyhow::{bail, Context, Result}; -use proto::tutorial::*; +use crate::proto::messages::horust_msg_message::RequestType; +pub use crate::proto::messages::HorustMsgServiceStatus; +use crate::proto::messages::{ + HorustMsgMessage, HorustMsgServiceStatusRequest, HorustMsgServiceStatusResponse, +}; +use anyhow::{anyhow, Context, Result}; +use log::{error, info}; +use prost::Message; +use std::io::{Read, Write}; +use std::net::Shutdown; +use std::os::unix::net::{UnixListener, UnixStream}; use std::path::{Path, PathBuf}; -use tokio::io::{AsyncReadExt, AsyncWriteExt}; -use tokio::net::{UnixListener, UnixStream}; -use tracing::info; -pub struct CommandsUdsConnectionHandler { - socket: UnixStream, -} -impl CommandsUdsConnectionHandler { - fn get_path(socket_folder: &Path, socket_name: u32) -> PathBuf { - socket_folder.join(format!("hourst-{socket_name}.sock")) - } - fn new(socket: UnixStream) -> Self { - Self { socket } +pub trait CommandsHandlerTrait { + // "blocking" - execute in its own tokio task. + fn start(&mut self) -> Result<()> { + // put the server logic in a loop to accept several connections + loop { + self.accept().expect("TODO: panic message"); + } } - pub async fn new_client(socket_path: PathBuf) -> Result { - Ok(Self { - socket: UnixStream::connect(socket_path) - .await - .context("Could not create stream")?, - }) + fn get_unix_listener(&mut self) -> &mut UnixListener; + fn accept(&mut self) -> Result<()> { + match self.get_unix_listener().accept() { + Ok((stream, _addr)) => { + let conn_handler = UdsConnectionHandler::new(stream); + if let Err(err) = self.handle_connection(conn_handler) { + error!("Error handling connection: {}", err); + } + } + Err(e) => { + error!("Error accepting connction: {e} - you might need to restart Horust."); + } + }; + Ok(()) } - - pub async fn client(mut self) -> Result<()> { - info!("client: sending data"); - self.socket - .write_all(b"Hello?") - .await // we write bytes, &[u8] - .context("Failed at writing onto the unix stream")?; - info!("client: Completed."); - // server is waiting for EOF. - self.socket.shutdown().await?; - - let mut buf = String::new(); - info!("client: reading back:"); - //Reads all bytes until EOF in this source, appending them to buf. - self.socket - .read_to_string(&mut buf) - .await // we write bytes, &[u8] - .context("Failed at writing onto the unix stream")?; - info!("Client received: {}", buf); + fn handle_connection(&self, mut uds_conn_handler: UdsConnectionHandler) -> Result<()> { + let received = uds_conn_handler + .receive_message()? + .request_type + .ok_or(anyhow!("No request found in message sent from client."))?; + match received { + RequestType::StatusRequest(status_request) => { + info!("Requested status for {}", status_request.service_name); + let service_status = self.get_service_status(status_request.service_name.clone()); + uds_conn_handler.send_message(new_horust_msg_service_status_response( + status_request.service_name, + service_status, + ))?; + } + RequestType::StatusResponse(_) => {} + RequestType::ChangeRequest(_) => {} + }; Ok(()) } - pub async fn server(mut self) -> Result<()> { - let mut message = String::new(); - info!("Server: receving data"); - // Reads all bytes until EOF in this source, appending them to buf. - self.socket - .read_to_string(&mut message) - .await - .context("Failed at reading the unix stream")?; - info!("Server: Received data: {message}"); - self.socket - .write_all(message.as_bytes()) - .await - .context("Failed at reading the unix stream")?; + fn get_service_status(&self, service_name: String) -> HorustMsgServiceStatus; +} - info!("Server: has written back {}", message); - Ok(()) +pub fn new_horust_msg_service_status_response( + service_name: String, + status: HorustMsgServiceStatus, +) -> HorustMsgMessage { + HorustMsgMessage { + request_type: Some(RequestType::StatusResponse( + HorustMsgServiceStatusResponse { + service_name, + service_status: status.into(), + }, + )), } } -pub struct CommandsUdsServer { - unix_listener: UnixListener, + +pub struct ClientHandler { + uds_connection_handler: UdsConnectionHandler, } -impl CommandsUdsServer { - pub async fn new(socket_path: &Path) -> Result { +impl ClientHandler { + pub fn new_client(socket_path: PathBuf) -> Result { Ok(Self { - unix_listener: UnixListener::bind(socket_path) - .context("Could not create the unix socket")?, + uds_connection_handler: UdsConnectionHandler::new( + UnixStream::connect(socket_path).context("Could not create stream")?, + ), }) } - pub async fn start(&mut self) -> Result<()> { - // put the server logic in a loop to accept several connections - loop { - self.accept().await?; - } - Ok(()) - } - pub async fn accept(&mut self) -> Result<()> { - match self.unix_listener.accept().await { - Ok((stream, _addr)) => { - tokio::spawn(async move { - CommandsUdsConnectionHandler::new(stream) - .server() - .await - .unwrap(); - }) - .await? - } - Err(e) => { - bail!("error accepting connction: {e}") - } + + pub fn client(mut self, service_name: String) -> Result<()> { + let status = HorustMsgMessage { + request_type: Some(RequestType::StatusRequest(HorustMsgServiceStatusRequest { + service_name, + })), }; + self.uds_connection_handler.send_message(status)?; + // server is waiting for EOF. + self.uds_connection_handler + .socket + .shutdown(Shutdown::Write)?; + //Reads all bytes until EOF in this source, appending them to buf. + let received = self.uds_connection_handler.receive_message()?; + info!("Client: received: {received:?}"); Ok(()) } } -fn create_uds() {} - -fn listen_uds() {} - -fn send_message() {} -fn receive_message() {} +pub struct UdsConnectionHandler { + socket: UnixStream, +} +impl UdsConnectionHandler { + fn get_path(socket_folder: &Path, socket_name: u32) -> PathBuf { + socket_folder.join(format!("hourst-{socket_name}.sock")) + } + fn new(socket: UnixStream) -> Self { + Self { socket } + } + pub fn send_message(&mut self, message: HorustMsgMessage) -> Result<()> { + let mut buf = Vec::new(); + // Serialize the message into a byte array. + message.encode(&mut buf)?; + self.socket + .write_all(&buf) + .context("Failed at writing onto the unix stream")?; + Ok(()) + } + pub fn receive_message(&mut self) -> Result { + let mut buf = Vec::new(); + self.socket.read_to_end(&mut buf)?; + Ok(HorustMsgMessage::decode(buf.as_slice())?) + } +} diff --git a/commands/src/proto/mod.rs b/commands/src/proto/mod.rs index 0559c4b..ba63992 100644 --- a/commands/src/proto/mod.rs +++ b/commands/src/proto/mod.rs @@ -1 +1 @@ -pub mod tutorial; +pub mod messages; diff --git a/commands/tests/simple.rs b/commands/tests/simple.rs index f228a5a..afaf654 100644 --- a/commands/tests/simple.rs +++ b/commands/tests/simple.rs @@ -1,31 +1,63 @@ use anyhow::Result; -use horust_commands_lib::{CommandsUdsConnectionHandler, CommandsUdsServer}; +use std::os::unix::net::UnixListener; + +use horust_commands_lib::{ClientHandler, CommandsHandlerTrait, HorustMsgServiceStatus}; +use log::info; use std::path::PathBuf; -use tracing::info; -use tracing_test::traced_test; +use std::sync::{Arc, Barrier}; +use std::thread; + +struct MockCommandsHandler { + unix_listener: UnixListener, +} +impl MockCommandsHandler { + // full socket path (not the folder). + pub fn new(socket_path: PathBuf) -> Self { + Self { + unix_listener: UnixListener::bind(socket_path).unwrap(), + } + } +} +impl CommandsHandlerTrait for MockCommandsHandler { + fn get_unix_listener(&mut self) -> &mut UnixListener { + &mut self.unix_listener + } -#[tokio::test] -#[traced_test] -async fn test_simple() -> Result<()> { + fn get_service_status(&self, service_name: String) -> HorustMsgServiceStatus { + match service_name.as_str() { + "Running" => HorustMsgServiceStatus::Running, + _ => unimplemented!(), + } + } +} +fn init() { + let _ = env_logger::builder().is_test(true).try_init(); +} +#[test] +fn test_simple() -> Result<()> { info!("Starting"); + init(); let socket_path: PathBuf = "/tmp/simple.sock".into(); if socket_path.exists() { std::fs::remove_file(&socket_path)?; } let socket_path2 = socket_path.clone(); - let s_handle = tokio::spawn(async move { - let mut uds = CommandsUdsServer::new(&socket_path2).await.unwrap(); + let barrier_server = Arc::new(Barrier::new(2)); + let barrier_client = Arc::clone(&barrier_server); + let s_handle = thread::spawn(move || { + let mut uds = MockCommandsHandler::new(socket_path2); info!("uds created"); - uds.accept().await.unwrap(); + barrier_server.wait(); + uds.accept().unwrap(); }); - let c_handle = tokio::spawn(async { - let client = CommandsUdsConnectionHandler::new_client(socket_path) - .await - .unwrap(); - client.client().await.unwrap(); + + let c_handle = thread::spawn(move || { + barrier_client.wait(); + let client = ClientHandler::new_client(socket_path).unwrap(); + client.client("Running".into()).unwrap(); }); - s_handle.await?; - c_handle.await?; + s_handle.join().unwrap(); + c_handle.join().unwrap(); Ok(()) } diff --git a/horust/Cargo.toml b/horust/Cargo.toml index fb02f69..752a02f 100644 --- a/horust/Cargo.toml +++ b/horust/Cargo.toml @@ -13,7 +13,7 @@ categories = ["command-line-utilities"] include = ["src/**/*", "Cargo.*", "LICENSE.txt", "README.md", "/example_services/**/*"] [dependencies] -clap = { version = "4.3.21", features = ["derive"] } +clap = { version = "~4.3", features = ["derive"] } crossbeam = "~0.8" env_logger = "0.10.0" humantime-serde = "~1.1" @@ -28,6 +28,7 @@ maplit = "~1.0" shellexpand = "~3.1" anyhow = "~1.0" thiserror = "~1.0" +horust-commands-lib = {path = "../commands"} [features] default = ["http-healthcheck"] diff --git a/horust/src/horust/commands_handler.rs b/horust/src/horust/commands_handler.rs new file mode 100644 index 0000000..371791c --- /dev/null +++ b/horust/src/horust/commands_handler.rs @@ -0,0 +1,41 @@ +use crate::horust::bus::BusConnector; +use crate::horust::Event; +use horust_commands_lib::{CommandsHandlerTrait, HorustMsgServiceStatus}; +use std::os::unix::net::UnixListener; +use std::path::PathBuf; +use std::thread; +use std::thread::JoinHandle; + +pub fn spawn(bus: BusConnector, uds_folder_path: PathBuf) -> JoinHandle<()> { + thread::spawn(move || { + run(bus, uds_folder_path); + }) +} + +fn run(bus: BusConnector, uds_folder_path: PathBuf) { + let mut commands_handler = CommandsHandler::new(bus, uds_folder_path); + commands_handler.start(); +} + +struct CommandsHandler { + bus: BusConnector, + uds_listener: UnixListener, +} +impl CommandsHandler { + fn new(bus: BusConnector, uds_folder_path: PathBuf) -> Self { + Self { + bus, + uds_listener: UnixListener::bind(uds_folder_path).unwrap(), + } + } +} + +impl CommandsHandlerTrait for CommandsHandler { + fn get_unix_listener(&mut self) -> &mut UnixListener { + &mut self.uds_listener + } + + fn get_service_status(&self, service_name: String) -> HorustMsgServiceStatus { + todo!() + } +} diff --git a/horust/src/horust/formats/horust_config.rs b/horust/src/horust/formats/horust_config.rs deleted file mode 100644 index 13ad913..0000000 --- a/horust/src/horust/formats/horust_config.rs +++ /dev/null @@ -1,52 +0,0 @@ -use std::path::Path; - -use anyhow::Result; -use serde::{Deserialize, Serialize}; - -// TODO: this should be an optional -// otherwise we wouldn't know if it was set to false on the commandline. Maybe. Because it's a flag. - -#[derive(Debug, clap::Parser, Serialize, Deserialize, Default)] -pub struct HorustConfig { - #[clap(long)] - /// Exits with an unsuccessful exit code if any process is in FinishedFailed state - pub unsuccessful_exit_finished_failed: bool, -} - -impl HorustConfig { - /// Load the config file, and handles the merge with the options defined in the cmdline. - /// Cmdline defined values have precedence over config based values. - pub fn load_and_merge(cmd_line: &HorustConfig, path: &Path) -> Result { - let config_file: HorustConfig = if path.exists() { - let content = std::fs::read_to_string(path)?; - toml::from_str(&content)? - } else { - Default::default() - }; - - let unsuccessful_exit_finished_failed = cmd_line.unsuccessful_exit_finished_failed - || config_file.unsuccessful_exit_finished_failed; - - Ok(HorustConfig { - unsuccessful_exit_finished_failed, - }) - } -} - -#[cfg(test)] -mod test { - use anyhow::Result; - - use crate::horust::HorustConfig; - #[test] - fn test_load_and_merge() -> Result<()> { - let tempdir = tempdir::TempDir::new("load-and-merge")?; - let config_path = tempdir.path().join("config.toml"); - std::fs::write(&config_path, "Not a toml file :( ")?; - let config = HorustConfig { - unsuccessful_exit_finished_failed: true, - }; - HorustConfig::load_and_merge(&config, &config_path).unwrap_err(); - Ok(()) - } -} diff --git a/horust/src/horust/formats/mod.rs b/horust/src/horust/formats/mod.rs index 751ebd5..043b691 100644 --- a/horust/src/horust/formats/mod.rs +++ b/horust/src/horust/formats/mod.rs @@ -1,9 +1,7 @@ use nix::unistd::Pid; -pub use horust_config::HorustConfig; pub use service::*; -mod horust_config; mod service; #[derive(Clone, Debug, Copy, PartialEq, Eq)] diff --git a/horust/src/horust/mod.rs b/horust/src/horust/mod.rs index c1b0fa6..7cad9e0 100644 --- a/horust/src/horust/mod.rs +++ b/horust/src/horust/mod.rs @@ -12,9 +12,10 @@ pub use formats::Event; use crate::horust::bus::Bus; use crate::horust::formats::{validate, Service}; -pub use self::formats::{get_sample_service, ExitStatus, HorustConfig}; +pub use self::formats::{get_sample_service, ExitStatus}; mod bus; +mod commands_handler; mod error; mod formats; mod healthcheck; @@ -25,35 +26,38 @@ mod uds_messages; #[derive(Debug)] pub struct Horust { services: Vec, + uds_folder_path: PathBuf, } impl Horust { - fn new(services: Vec) -> Self { - Horust { services } + fn new(services: Vec, uds_folder_path: PathBuf) -> Self { + Horust { + services, + uds_folder_path, + } } - pub fn get_services(&self) -> &[Service] { - &self.services - } /// Creates a new Horust instance from a command. /// The command will be wrapped in a service and run with sane defaults - pub fn from_command(command: String) -> Self { - Self::new(vec![Service::from_command(command)]) + pub fn from_command(command: String, uds_folder_path: PathBuf) -> Self { + Self::new(vec![Service::from_command(command)], uds_folder_path) } - /// Create a new horust instance from multiple paths of services. - pub fn from_services_dirs(paths: &[PathBuf]) -> Result { - let services = paths + fn load_services_from_folders(paths: &[PathBuf]) -> Result> { + paths .iter() .map(|path| fetch_services(path)) .flat_map(|result| match result { Ok(vec) => vec.into_iter().map(Ok).collect(), Err(err) => vec![Err(err)], }) - .collect::>>()?; - + .collect::>>() + } + /// Create a new horust instance from multiple paths of services. + pub fn from_services_dirs(paths: &[PathBuf], uds_folder_path: PathBuf) -> Result { + let services = Self::load_services_from_folders(paths)?; let services = validate(services)?; - Ok(Horust::new(services)) + Ok(Horust::new(services, uds_folder_path)) } /// Blocking call, will setup the event loop and the threads and run all the available services. @@ -79,6 +83,11 @@ impl Horust { debug!("Services: {:?}", self.services); // Spawn helper threads: healthcheck::spawn(dispatcher.join_bus(), self.services.clone()); + commands_handler::spawn( + self.uds_folder_path.clone(), + dispatcher.join_bus(), + self.services.clone(), + ); let handle = supervisor::spawn(dispatcher.join_bus(), self.services.clone()); dispatcher.run(); handle.join().unwrap() @@ -153,6 +162,7 @@ mod test { use std::io; use std::path::{Path, PathBuf}; + use crate::Horust; use tempdir::TempDir; use crate::horust::fetch_services; @@ -234,4 +244,14 @@ mod test { Ok(()) } + + #[test] + fn test_should_deserialize() { + let base = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + let services_path = base.join("../example_services/"); + let services = list_files(&services_path).unwrap().len(); + let horust = + Horust::from_services_dirs(&[services_path], "/tmp/horust-test-uds".into()).unwrap(); + assert_eq!(horust.services.len(), services); + } } diff --git a/horust/src/main.rs b/horust/src/main.rs index b1582f6..404afc8 100644 --- a/horust/src/main.rs +++ b/horust/src/main.rs @@ -3,7 +3,6 @@ use std::path::PathBuf; use anyhow::{Context, Result}; use clap::Parser; use horust::horust::ExitStatus; -use horust::horust::HorustConfig; use horust::Horust; use log::{error, info}; @@ -11,22 +10,27 @@ use log::{error, info}; #[clap(author, about)] /// Horust is a complete supervisor and init system, designed for running in containers. struct Opts { - #[clap(long, default_value = "/etc/horust/horust.toml")] + #[arg(long, default_value = "/etc/horust/horust.toml")] /// Horust's path to config. config_path: PathBuf, - #[clap(flatten)] - horust_config: HorustConfig, - #[clap(long)] + /// Exits with an unsuccessful exit code if any process is in FinishedFailed state + pub unsuccessful_exit_finished_failed: bool, + + #[arg(long)] /// Print a sample service file with all the possible options sample_service: bool, - #[clap(long = "services-path", default_value = "/etc/horust/services")] + #[arg(long = "services-path", default_value = "/etc/horust/services")] /// Path to service file or a directory containing services to run. You can provide more than one argument to load multiple directories / services. services_paths: Vec, - #[clap(required = false, last = true)] + #[arg(required = false, default_value = "/var/run/horust")] + /// Path to the folder that contains the Unix Domain Socket, used to communicate with horustctl + uds_folder_path: PathBuf, + + #[arg(required = false, last = true)] /// Specify a command to run instead of load services path. Useful if you just want to use the reaping capability. Prefix your command with -- command: Vec, } @@ -45,18 +49,17 @@ fn main() -> Result<()> { return Ok(()); } - let config = HorustConfig::load_and_merge(&opts.horust_config, &opts.config_path) - .with_context(|| { - format!( - "Failed loading configuration: {}", - &opts.config_path.display() - ) - })?; + if !opts.uds_folder_path.exists() { + std::fs::create_dir_all(opts.uds_folder_path)?; + } - let mut horust = if !opts.command.is_empty() { - info!("Running command: {:?}", opts.command); - Horust::from_command(opts.command.join(" ")) - } else { + if !opts.uds_folder_path.is_dir() { + panic!( + "'{:?}' is not a directory. Use --uds-folder-path to select a different folder.", + opts.uds_folder_path + ); + } + let mut horust = if opts.command.is_empty() { info!( "Loading services from {}", display_directories(&opts.services_paths) @@ -67,10 +70,14 @@ fn main() -> Result<()> { display_directories(&opts.services_paths) ) })? + } else { + info!("Running command: {:?}", opts.command); + Horust::from_command(opts.command.join(" ")) }; + horust.set_uds_folder_path(); if let ExitStatus::SomeServiceFailed = horust.run() { - if config.unsuccessful_exit_finished_failed { + if opts.unsuccessful_exit_finished_failed { error!("Some processes have failed."); std::process::exit(101); } diff --git a/horust/tests/service_deserialization.rs b/horust/tests/service_deserialization.rs deleted file mode 100644 index 96e61cb..0000000 --- a/horust/tests/service_deserialization.rs +++ /dev/null @@ -1,31 +0,0 @@ -use std::path::PathBuf; - -pub fn list_files>(path: P) -> std::io::Result> { - let mut paths = std::fs::read_dir(path)?; - paths.try_fold(vec![], |mut ret, p| match p { - Ok(entry) => { - ret.push(entry.path()); - Ok(ret) - } - Err(err) => Err(err), - }) -} - -#[cfg(test)] -mod tests { - use std::path::PathBuf; - - use horust::Horust; - - use crate::list_files; - - #[test] - fn should_deserialize() { - // TODO: this shouldn't be an integration test, but rather a unit test. - let base = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - let services_path = base.join("../../example_services"); - let services = list_files(&services_path).unwrap().len(); - let horust = Horust::from_services_dirs(&[services_path]).unwrap(); - assert_eq!(horust.get_services().len(), services); - } -} From c6f2fe9697b824b5259d58a7977af0a70c0ef2de Mon Sep 17 00:00:00 2001 From: Federico Ponzi Date: Sun, 20 Aug 2023 22:38:57 +0100 Subject: [PATCH 05/11] horust compiling and tests passing --- Cargo.lock | 1 + commands/src/lib.rs | 47 ++++++++++++++++++++---- commands/tests/simple.rs | 7 +++- horust/src/horust/commands_handler.rs | 53 ++++++++++++++++++++++----- horust/src/horust/healthcheck/mod.rs | 18 ++++----- horust/src/horust/mod.rs | 22 +++++------ horust/src/horust/uds_messages.rs | 6 --- horust/src/main.rs | 10 +++-- horustctl/Cargo.toml | 2 + horustctl/src/main.rs | 21 +++++++++-- 10 files changed, 133 insertions(+), 54 deletions(-) delete mode 100644 horust/src/horust/uds_messages.rs diff --git a/Cargo.lock b/Cargo.lock index 2a2af09..50726d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -570,6 +570,7 @@ dependencies = [ "clap", "crossbeam", "env_logger", + "horust-commands-lib", "log", ] diff --git a/commands/src/lib.rs b/commands/src/lib.rs index 4d6974a..af56afa 100644 --- a/commands/src/lib.rs +++ b/commands/src/lib.rs @@ -10,7 +10,7 @@ use crate::proto::messages::{ use anyhow::{anyhow, Context, Result}; use log::{error, info}; use prost::Message; -use std::io::{Read, Write}; +use std::io::{ErrorKind, Read, Write}; use std::net::Shutdown; use std::os::unix::net::{UnixListener, UnixStream}; use std::path::{Path, PathBuf}; @@ -33,7 +33,10 @@ pub trait CommandsHandlerTrait { } } Err(e) => { - error!("Error accepting connction: {e} - you might need to restart Horust."); + let kind = e.kind(); + if !matches!(ErrorKind::WouldBlock, kind) { + error!("Error accepting connction: {e} - you might need to restart Horust."); + } } }; Ok(()) @@ -79,13 +82,41 @@ pub struct ClientHandler { uds_connection_handler: UdsConnectionHandler, } impl ClientHandler { - pub fn new_client(socket_path: PathBuf) -> Result { + pub fn new_client(socket_path: &Path) -> Result { Ok(Self { uds_connection_handler: UdsConnectionHandler::new( UnixStream::connect(socket_path).context("Could not create stream")?, ), }) } + pub fn send_status_request( + &mut self, + service_name: String, + ) -> Result<(String, HorustMsgServiceStatus)> { + let status = HorustMsgMessage { + request_type: Some(RequestType::StatusRequest(HorustMsgServiceStatusRequest { + service_name, + })), + }; + self.uds_connection_handler.send_message(status)?; + // server is waiting for EOF. + self.uds_connection_handler + .socket + .shutdown(Shutdown::Write)?; + //Reads all bytes until EOF in this source, appending them to buf. + let received = self.uds_connection_handler.receive_message()?; + info!("Client: received: {received:?}"); + match received + .request_type + .ok_or(anyhow!("Error receiving message"))? + { + RequestType::StatusResponse(resp) => Ok(( + resp.service_name, + HorustMsgServiceStatus::from_i32(resp.service_status).unwrap(), + )), + _ => unreachable!(), + } + } pub fn client(mut self, service_name: String) -> Result<()> { let status = HorustMsgMessage { @@ -105,14 +136,16 @@ impl ClientHandler { } } +/// socket_name should be the pid of the horust process. +pub fn get_path(socket_folder: &Path, socket_name: i32) -> PathBuf { + socket_folder.join(format!("hourst-{socket_name}.sock")) +} + pub struct UdsConnectionHandler { socket: UnixStream, } impl UdsConnectionHandler { - fn get_path(socket_folder: &Path, socket_name: u32) -> PathBuf { - socket_folder.join(format!("hourst-{socket_name}.sock")) - } - fn new(socket: UnixStream) -> Self { + pub fn new(socket: UnixStream) -> Self { Self { socket } } pub fn send_message(&mut self, message: HorustMsgMessage) -> Result<()> { diff --git a/commands/tests/simple.rs b/commands/tests/simple.rs index afaf654..cfb7ffc 100644 --- a/commands/tests/simple.rs +++ b/commands/tests/simple.rs @@ -26,6 +26,7 @@ impl CommandsHandlerTrait for MockCommandsHandler { fn get_service_status(&self, service_name: String) -> HorustMsgServiceStatus { match service_name.as_str() { "Running" => HorustMsgServiceStatus::Running, + "Started" => HorustMsgServiceStatus::Started, _ => unimplemented!(), } } @@ -50,12 +51,16 @@ fn test_simple() -> Result<()> { info!("uds created"); barrier_server.wait(); uds.accept().unwrap(); + uds.accept().unwrap(); }); let c_handle = thread::spawn(move || { barrier_client.wait(); - let client = ClientHandler::new_client(socket_path).unwrap(); + let client = ClientHandler::new_client(&socket_path).unwrap(); client.client("Running".into()).unwrap(); + + let client = ClientHandler::new_client(&socket_path).unwrap(); + client.client("Started".into()).unwrap(); }); s_handle.join().unwrap(); c_handle.join().unwrap(); diff --git a/horust/src/horust/commands_handler.rs b/horust/src/horust/commands_handler.rs index 371791c..6a88b2d 100644 --- a/horust/src/horust/commands_handler.rs +++ b/horust/src/horust/commands_handler.rs @@ -1,31 +1,64 @@ use crate::horust::bus::BusConnector; +use crate::horust::formats::{ServiceName, ServiceStatus}; use crate::horust::Event; use horust_commands_lib::{CommandsHandlerTrait, HorustMsgServiceStatus}; +use std::collections::HashMap; use std::os::unix::net::UnixListener; use std::path::PathBuf; -use std::thread; use std::thread::JoinHandle; +use std::time::Duration; +use std::{fs, thread}; -pub fn spawn(bus: BusConnector, uds_folder_path: PathBuf) -> JoinHandle<()> { +pub fn spawn( + bus: BusConnector, + uds_path: PathBuf, + services: Vec, +) -> JoinHandle<()> { thread::spawn(move || { - run(bus, uds_folder_path); + let mut commands_handler = CommandsHandler::new(bus, uds_path, services); + commands_handler.run(); }) } -fn run(bus: BusConnector, uds_folder_path: PathBuf) { - let mut commands_handler = CommandsHandler::new(bus, uds_folder_path); - commands_handler.start(); -} - struct CommandsHandler { bus: BusConnector, + services: HashMap, uds_listener: UnixListener, + uds_path: PathBuf, } + impl CommandsHandler { - fn new(bus: BusConnector, uds_folder_path: PathBuf) -> Self { + fn new(bus: BusConnector, uds_path: PathBuf, services: Vec) -> Self { + let mut uds_listener = UnixListener::bind(&uds_path).unwrap(); + uds_listener.set_nonblocking(true).unwrap(); Self { bus, - uds_listener: UnixListener::bind(uds_folder_path).unwrap(), + uds_path, + uds_listener, + services: services + .into_iter() + .map(|s| (s, ServiceStatus::Initial)) + .collect(), + } + } + fn run(&mut self) { + loop { + let evs = self.bus.try_get_events(); + for ev in evs { + match ev { + Event::StatusChanged(name, status) => { + let k = self.services.get_mut(&name).unwrap(); + *k = status; + } + Event::ShuttingDownInitiated(_) => { + fs::remove_file(&self.uds_path).unwrap(); + return; + } + _ => {} + } + } + self.accept().unwrap(); + thread::sleep(Duration::from_millis(300)); } } } diff --git a/horust/src/horust/healthcheck/mod.rs b/horust/src/horust/healthcheck/mod.rs index 9310a7b..3ae8121 100644 --- a/horust/src/horust/healthcheck/mod.rs +++ b/horust/src/horust/healthcheck/mod.rs @@ -1,6 +1,8 @@ //! If a service has defined an healthchecker, this module will spawn a worker to making sure that //! the service is working as supposed to. +use std::net::{SocketAddrV4, TcpListener}; +use std::sync::mpsc; use std::thread; use std::thread::JoinHandle; use std::time::Duration; @@ -141,10 +143,6 @@ mod test { use crate::horust::formats::{Healthiness, HealthinessStatus}; use crate::horust::healthcheck::check_health; - fn check_health_w(healthiness: &Healthiness) -> bool { - check_health(healthiness) == HealthinessStatus::Healthy - } - #[test] fn test_healthiness_check_file() -> Result<()> { let tempdir = TempDir::new("health")?; @@ -154,11 +152,11 @@ mod test { http_endpoint: None, ..Default::default() }; - assert!(!check_health_w(&healthiness)); + assert_ne!(check_health(&healthiness), HealthinessStatus::Healthy); std::fs::write(file_path, "Hello world!")?; - assert!(check_health_w(&healthiness)); + assert_eq!(check_health(&healthiness), HealthinessStatus::Healthy); let healthiness: Healthiness = Default::default(); - assert!(check_health_w(&healthiness)); + assert_eq!(check_health(&healthiness), HealthinessStatus::Healthy); Ok(()) } @@ -182,7 +180,7 @@ mod test { http_endpoint: Some("http://localhost:123/".into()), ..Default::default() }; - assert!(!check_health_w(&healthiness)); + assert_ne!(check_health(&healthiness), HealthinessStatus::Healthy); let loopback = Ipv4Addr::new(127, 0, 0, 1); let socket = SocketAddrV4::new(loopback, 0); let listener = TcpListener::bind(socket)?; @@ -198,11 +196,11 @@ mod test { handle_request(listener).unwrap(); sender.send(()).expect("Chan closed"); }); - assert!(check_health_w(&healthiness)); + assert_eq!(check_health(&healthiness), HealthinessStatus::Healthy); receiver .recv_timeout(Duration::from_millis(2000)) .expect("Failed to received response from handle_request"); - assert!(!check_health_w(&healthiness)); + assert_ne!(check_health(&healthiness), HealthinessStatus::Healthy); Ok(()) } } diff --git a/horust/src/horust/mod.rs b/horust/src/horust/mod.rs index 7cad9e0..bb24a1f 100644 --- a/horust/src/horust/mod.rs +++ b/horust/src/horust/mod.rs @@ -21,26 +21,22 @@ mod formats; mod healthcheck; mod signal_safe; mod supervisor; -mod uds_messages; #[derive(Debug)] pub struct Horust { services: Vec, - uds_folder_path: PathBuf, + uds_path: PathBuf, } impl Horust { - fn new(services: Vec, uds_folder_path: PathBuf) -> Self { - Horust { - services, - uds_folder_path, - } + fn new(services: Vec, uds_path: PathBuf) -> Self { + Horust { services, uds_path } } /// Creates a new Horust instance from a command. /// The command will be wrapped in a service and run with sane defaults - pub fn from_command(command: String, uds_folder_path: PathBuf) -> Self { - Self::new(vec![Service::from_command(command)], uds_folder_path) + pub fn from_command(command: String, uds_path: PathBuf) -> Self { + Self::new(vec![Service::from_command(command)], uds_path) } fn load_services_from_folders(paths: &[PathBuf]) -> Result> { @@ -54,10 +50,10 @@ impl Horust { .collect::>>() } /// Create a new horust instance from multiple paths of services. - pub fn from_services_dirs(paths: &[PathBuf], uds_folder_path: PathBuf) -> Result { + pub fn from_services_dirs(paths: &[PathBuf], uds_path: PathBuf) -> Result { let services = Self::load_services_from_folders(paths)?; let services = validate(services)?; - Ok(Horust::new(services, uds_folder_path)) + Ok(Horust::new(services, uds_path)) } /// Blocking call, will setup the event loop and the threads and run all the available services. @@ -84,9 +80,9 @@ impl Horust { // Spawn helper threads: healthcheck::spawn(dispatcher.join_bus(), self.services.clone()); commands_handler::spawn( - self.uds_folder_path.clone(), dispatcher.join_bus(), - self.services.clone(), + self.uds_path.clone(), + self.services.iter().map(|s| s.name.clone()).collect(), ); let handle = supervisor::spawn(dispatcher.join_bus(), self.services.clone()); dispatcher.run(); diff --git a/horust/src/horust/uds_messages.rs b/horust/src/horust/uds_messages.rs deleted file mode 100644 index 8032f5f..0000000 --- a/horust/src/horust/uds_messages.rs +++ /dev/null @@ -1,6 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Deserialize, Serialize)] -enum Messages { - Status(Option), -} diff --git a/horust/src/main.rs b/horust/src/main.rs index 404afc8..c64784b 100644 --- a/horust/src/main.rs +++ b/horust/src/main.rs @@ -5,6 +5,7 @@ use clap::Parser; use horust::horust::ExitStatus; use horust::Horust; use log::{error, info}; +use nix::unistd::getpid; #[derive(clap::Parser, Debug)] #[clap(author, about)] @@ -50,7 +51,7 @@ fn main() -> Result<()> { } if !opts.uds_folder_path.exists() { - std::fs::create_dir_all(opts.uds_folder_path)?; + std::fs::create_dir_all(&opts.uds_folder_path)?; } if !opts.uds_folder_path.is_dir() { @@ -59,12 +60,14 @@ fn main() -> Result<()> { opts.uds_folder_path ); } + let uds_path = horust_commands_lib::get_path(&opts.uds_folder_path, getpid().into()); + let mut horust = if opts.command.is_empty() { info!( "Loading services from {}", display_directories(&opts.services_paths) ); - Horust::from_services_dirs(&opts.services_paths).with_context(|| { + Horust::from_services_dirs(&opts.services_paths, uds_path).with_context(|| { format!( "Failed loading services from {}", display_directories(&opts.services_paths) @@ -72,9 +75,8 @@ fn main() -> Result<()> { })? } else { info!("Running command: {:?}", opts.command); - Horust::from_command(opts.command.join(" ")) + Horust::from_command(opts.command.join(" "), uds_path) }; - horust.set_uds_folder_path(); if let ExitStatus::SomeServiceFailed = horust.run() { if opts.unsuccessful_exit_finished_failed { diff --git a/horustctl/Cargo.toml b/horustctl/Cargo.toml index bb2b37f..58cc3e5 100644 --- a/horustctl/Cargo.toml +++ b/horustctl/Cargo.toml @@ -10,3 +10,5 @@ log = "~0.4" env_logger = "0.10.0" crossbeam = "~0.8" clap = {version = "~4.3", features = ["derive"]} +horust-commands-lib = {path = "../commands"} + diff --git a/horustctl/src/main.rs b/horustctl/src/main.rs index b11b77f..16d19b4 100644 --- a/horustctl/src/main.rs +++ b/horustctl/src/main.rs @@ -1,10 +1,12 @@ use anyhow::{bail, Result}; use clap::{Args, Parser, Subcommand}; use env_logger::Env; +use horust_commands_lib::{ClientHandler, UdsConnectionHandler}; use log::{debug, error}; use std::env; use std::fs::{read, read_dir}; use std::io::Write; +use std::os::linux::raw::stat; use std::os::unix::net::UnixStream; use std::path::{Path, PathBuf}; @@ -12,13 +14,17 @@ use std::path::{Path, PathBuf}; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] struct HourstctlArgs { - /// Optional if only one horust is running in the system. + /// The pid of the horust process you want to query. Optional if only one horust is running in the system. #[arg(short, long)] pid: Option, #[arg(short, long, default_value = "/var/run/horust/")] sockets_folder_path: PathBuf, + // Specify the full path of the socket. It takes precedence other over arguments. + #[arg(long)] + socket_path: Option, + #[command(subcommand)] commands: Commands, } @@ -38,11 +44,20 @@ fn main() -> Result<()> { let args = HourstctlArgs::parse(); debug!("args: {args:?}"); - let uds_path = get_uds_path(args.pid, args.sockets_folder_path)?; + let uds_path = args.socket_path.unwrap_or_else(|| { + get_uds_path(args.pid, args.sockets_folder_path).expect("Failed to get uds_path.") + }); + let mut uds_handler = ClientHandler::new_client(&uds_path)?; match &args.commands { Commands::Status(status_args) => { debug!("Status command received: {status_args:?}"); - debug!("uds path : {uds_path:?}") + debug!("uds path : {uds_path:?}"); + let (service_name, service_status) = + uds_handler.send_status_request(status_args.service_name.clone().unwrap())?; + println!( + "Current status for '{service_name}' is: '{}'.", + service_status.as_str_name() + ); } } Ok(()) From ec7334420a08e1dc9e95d0caa403d7bbda8ccc3c Mon Sep 17 00:00:00 2001 From: Federico Ponzi Date: Wed, 23 Aug 2023 09:06:03 +0100 Subject: [PATCH 06/11] Refactor commands lib and add response errors handling --- commands/src/client.rs | 79 ++++++++++++++ commands/src/commands.proto | 30 ++++-- commands/src/lib.rs | 149 +++----------------------- commands/src/server.rs | 105 ++++++++++++++++++ commands/tests/simple.rs | 6 +- horust/src/horust/commands_handler.rs | 14 ++- horustctl/src/main.rs | 61 ++++------- 7 files changed, 259 insertions(+), 185 deletions(-) create mode 100644 commands/src/client.rs create mode 100644 commands/src/server.rs diff --git a/commands/src/client.rs b/commands/src/client.rs new file mode 100644 index 0000000..c77cdcf --- /dev/null +++ b/commands/src/client.rs @@ -0,0 +1,79 @@ +use crate::proto::messages::horust_msg_message::MessageType; +use crate::proto::messages::{ + horust_msg_request, horust_msg_response, HorustMsgMessage, HorustMsgRequest, + HorustMsgServiceStatusRequest, +}; +use crate::{HorustMsgServiceStatus, UdsConnectionHandler}; +use anyhow::{anyhow, Context}; +use anyhow::{bail, Result}; +use log::info; +use std::net::Shutdown; +use std::os::unix::net::UnixStream; +use std::path::Path; + +fn new_request(request_type: horust_msg_request::Request) -> HorustMsgMessage { + HorustMsgMessage { + message_type: Some(MessageType::Request(HorustMsgRequest { + request: Some(request_type), + })), + } +} + +// if anything is none it will return none +// if the response was an error it will return Some(Err). +fn unwrap_response(response: HorustMsgMessage) -> Option> { + if let MessageType::Response(resp) = response.message_type? { + let v = resp.response?; + return match &v { + horust_msg_response::Response::Error(error) => { + Some(Err(anyhow!("Error: {}", error.error_string))) + } + horust_msg_response::Response::StatusResponse(status) => Some(Ok(v)), + }; + } + None +} + +pub struct ClientHandler { + uds_connection_handler: UdsConnectionHandler, +} +impl ClientHandler { + pub fn new_client(socket_path: &Path) -> Result { + Ok(Self { + uds_connection_handler: UdsConnectionHandler::new( + UnixStream::connect(socket_path).context("Could not create stream")?, + ), + }) + } + pub fn send_status_request( + &mut self, + service_name: String, + ) -> Result<(String, HorustMsgServiceStatus)> { + let status = new_request(horust_msg_request::Request::StatusRequest( + HorustMsgServiceStatusRequest { service_name }, + )); + self.uds_connection_handler.send_message(status)?; + // server is waiting for EOF. + self.uds_connection_handler + .socket + .shutdown(Shutdown::Write)?; + //Reads all bytes until EOF in this source, appending them to buf. + let received = self.uds_connection_handler.receive_message()?; + info!("Client: received: {received:?}"); + let response = unwrap_response(received).unwrap()?; + if let horust_msg_response::Response::StatusResponse(resp) = response { + return Ok(( + resp.service_name, + HorustMsgServiceStatus::from_i32(resp.service_status).unwrap(), + )); + } else { + bail!("Invalid response received: {:?}", response); + } + } + + pub fn client(mut self, service_name: String) -> Result<()> { + let received = self.send_status_request(service_name)?; + info!("Client: received: {received:?}"); + Ok(()) + } +} diff --git a/commands/src/commands.proto b/commands/src/commands.proto index 9b4b9de..544646e 100644 --- a/commands/src/commands.proto +++ b/commands/src/commands.proto @@ -2,14 +2,26 @@ syntax = "proto3"; package messages; message HorustMsgMessage { - oneof request_type { + oneof message_type { + HorustMsgRequest request = 1; + HorustMsgResponse response = 2; + } +} +message HorustMsgRequest { + oneof request { HorustMsgServiceStatusRequest status_request = 1; + HorustMsgServiceChangeRequest change_request = 2; + } +} +message HorustMsgResponse { + oneof response { + HorustMsgError error = 1; HorustMsgServiceStatusResponse status_response = 2; - HorustMsgServiceChangeRequest change_request = 3; } } -message HorustMsgError { +message HorustMsgError { + string error_string = 1; } message HorustMsgServiceStatusRequest { @@ -33,9 +45,13 @@ message HorustMsgServiceChangeResponse { } enum HorustMsgServiceStatus { - STOPPED = 0; + STARTING = 0; STARTED = 1; - KILLED = 2; - SHUTTING_DOWN = 3; - RUNNING = 4; + RUNNING = 2; + INKILLING = 3; + SUCCESS = 4; + FINISHED = 5; + FINISHEDFAILED = 6; + FAILED = 7; + INITIAL = 8; } diff --git a/commands/src/lib.rs b/commands/src/lib.rs index af56afa..3464c20 100644 --- a/commands/src/lib.rs +++ b/commands/src/lib.rs @@ -1,144 +1,22 @@ extern crate core; +mod client; mod proto; - -use crate::proto::messages::horust_msg_message::RequestType; +mod server; +use crate::proto::messages::HorustMsgMessage; pub use crate::proto::messages::HorustMsgServiceStatus; -use crate::proto::messages::{ - HorustMsgMessage, HorustMsgServiceStatusRequest, HorustMsgServiceStatusResponse, -}; -use anyhow::{anyhow, Context, Result}; -use log::{error, info}; +use anyhow::{Context, Result}; +pub use client::ClientHandler; +use log::debug; use prost::Message; -use std::io::{ErrorKind, Read, Write}; -use std::net::Shutdown; -use std::os::unix::net::{UnixListener, UnixStream}; +pub use server::CommandsHandlerTrait; +use std::io::{Read, Write}; +use std::os::unix::net::UnixStream; use std::path::{Path, PathBuf}; -pub trait CommandsHandlerTrait { - // "blocking" - execute in its own tokio task. - fn start(&mut self) -> Result<()> { - // put the server logic in a loop to accept several connections - loop { - self.accept().expect("TODO: panic message"); - } - } - fn get_unix_listener(&mut self) -> &mut UnixListener; - fn accept(&mut self) -> Result<()> { - match self.get_unix_listener().accept() { - Ok((stream, _addr)) => { - let conn_handler = UdsConnectionHandler::new(stream); - if let Err(err) = self.handle_connection(conn_handler) { - error!("Error handling connection: {}", err); - } - } - Err(e) => { - let kind = e.kind(); - if !matches!(ErrorKind::WouldBlock, kind) { - error!("Error accepting connction: {e} - you might need to restart Horust."); - } - } - }; - Ok(()) - } - fn handle_connection(&self, mut uds_conn_handler: UdsConnectionHandler) -> Result<()> { - let received = uds_conn_handler - .receive_message()? - .request_type - .ok_or(anyhow!("No request found in message sent from client."))?; - match received { - RequestType::StatusRequest(status_request) => { - info!("Requested status for {}", status_request.service_name); - let service_status = self.get_service_status(status_request.service_name.clone()); - uds_conn_handler.send_message(new_horust_msg_service_status_response( - status_request.service_name, - service_status, - ))?; - } - RequestType::StatusResponse(_) => {} - RequestType::ChangeRequest(_) => {} - }; - Ok(()) - } - - fn get_service_status(&self, service_name: String) -> HorustMsgServiceStatus; -} - -pub fn new_horust_msg_service_status_response( - service_name: String, - status: HorustMsgServiceStatus, -) -> HorustMsgMessage { - HorustMsgMessage { - request_type: Some(RequestType::StatusResponse( - HorustMsgServiceStatusResponse { - service_name, - service_status: status.into(), - }, - )), - } -} - -pub struct ClientHandler { - uds_connection_handler: UdsConnectionHandler, -} -impl ClientHandler { - pub fn new_client(socket_path: &Path) -> Result { - Ok(Self { - uds_connection_handler: UdsConnectionHandler::new( - UnixStream::connect(socket_path).context("Could not create stream")?, - ), - }) - } - pub fn send_status_request( - &mut self, - service_name: String, - ) -> Result<(String, HorustMsgServiceStatus)> { - let status = HorustMsgMessage { - request_type: Some(RequestType::StatusRequest(HorustMsgServiceStatusRequest { - service_name, - })), - }; - self.uds_connection_handler.send_message(status)?; - // server is waiting for EOF. - self.uds_connection_handler - .socket - .shutdown(Shutdown::Write)?; - //Reads all bytes until EOF in this source, appending them to buf. - let received = self.uds_connection_handler.receive_message()?; - info!("Client: received: {received:?}"); - match received - .request_type - .ok_or(anyhow!("Error receiving message"))? - { - RequestType::StatusResponse(resp) => Ok(( - resp.service_name, - HorustMsgServiceStatus::from_i32(resp.service_status).unwrap(), - )), - _ => unreachable!(), - } - } - - pub fn client(mut self, service_name: String) -> Result<()> { - let status = HorustMsgMessage { - request_type: Some(RequestType::StatusRequest(HorustMsgServiceStatusRequest { - service_name, - })), - }; - self.uds_connection_handler.send_message(status)?; - // server is waiting for EOF. - self.uds_connection_handler - .socket - .shutdown(Shutdown::Write)?; - //Reads all bytes until EOF in this source, appending them to buf. - let received = self.uds_connection_handler.receive_message()?; - info!("Client: received: {received:?}"); - Ok(()) - } -} - /// socket_name should be the pid of the horust process. -pub fn get_path(socket_folder: &Path, socket_name: i32) -> PathBuf { - socket_folder.join(format!("hourst-{socket_name}.sock")) +pub fn get_path(socket_folder_path: &Path, horust_pid: i32) -> PathBuf { + socket_folder_path.join(format!("hourst-{horust_pid}.sock")) } pub struct UdsConnectionHandler { @@ -149,6 +27,7 @@ impl UdsConnectionHandler { Self { socket } } pub fn send_message(&mut self, message: HorustMsgMessage) -> Result<()> { + debug!("Sending message: {:?}", message); let mut buf = Vec::new(); // Serialize the message into a byte array. message.encode(&mut buf)?; @@ -160,6 +39,8 @@ impl UdsConnectionHandler { pub fn receive_message(&mut self) -> Result { let mut buf = Vec::new(); self.socket.read_to_end(&mut buf)?; - Ok(HorustMsgMessage::decode(buf.as_slice())?) + let received = HorustMsgMessage::decode(buf.as_slice())?; + debug!("Received message: {:?}", received); + Ok(received) } } diff --git a/commands/src/server.rs b/commands/src/server.rs new file mode 100644 index 0000000..40e9e11 --- /dev/null +++ b/commands/src/server.rs @@ -0,0 +1,105 @@ +use crate::proto::messages::horust_msg_message::MessageType::Request; +use crate::proto::messages::{ + horust_msg_message, horust_msg_request, horust_msg_response, HorustMsgError, HorustMsgMessage, + HorustMsgRequest, HorustMsgResponse, HorustMsgServiceStatusResponse, +}; +use crate::{HorustMsgServiceStatus, UdsConnectionHandler}; +use anyhow::{anyhow, Result}; +use log::{error, info}; +use std::io::ErrorKind; +use std::os::unix::net::UnixListener; + +pub trait CommandsHandlerTrait { + fn start(&mut self) -> Result<()> { + // put the server logic in a loop to accept several connections + loop { + self.accept().expect("TODO: panic message"); + } + } + fn get_unix_listener(&mut self) -> &mut UnixListener; + fn accept(&mut self) -> Result<()> { + match self.get_unix_listener().accept() { + Ok((stream, _addr)) => { + let conn_handler = UdsConnectionHandler::new(stream); + if let Err(err) = self.handle_connection(conn_handler) { + error!("Error handling connection: {}", err); + } + } + Err(e) => { + let kind = e.kind(); + if !matches!(ErrorKind::WouldBlock, kind) { + error!("Error accepting connction: {e} - you might need to restart Horust."); + } + } + }; + Ok(()) + } + fn handle_connection(&self, mut uds_conn_handler: UdsConnectionHandler) -> Result<()> { + let received = uds_conn_handler + .receive_message()? + .message_type + .ok_or(anyhow!("No request found in message sent from client."))?; + if let Request(HorustMsgRequest { + request: Some(request), + }) = received + { + match request { + horust_msg_request::Request::StatusRequest(status_request) => { + info!("Requested status for {}", status_request.service_name); + let service_name = status_request.service_name.clone(); + + let service_status = + self.get_service_status(status_request.service_name.clone()); + let response = service_status + .map(|status| { + new_horust_msg_service_status_response( + status_request.service_name, + status, + ) + }) + .unwrap_or_else(|| { + new_horust_msg_error_response(format!( + "Service {} not found.", + service_name + )) + }); + uds_conn_handler.send_message(response)?; + } + horust_msg_request::Request::ChangeRequest(_) => {} + }; + } + Ok(()) + } + + fn get_service_status(&self, service_name: String) -> Option; +} + +pub fn new_horust_msg_error_response(error: String) -> HorustMsgMessage { + HorustMsgMessage { + message_type: Some(horust_msg_message::MessageType::Response( + HorustMsgResponse { + response: Some(horust_msg_response::Response::Error(HorustMsgError { + error_string: error, + })), + }, + )), + } +} + +pub fn new_horust_msg_service_status_response( + service_name: String, + status: HorustMsgServiceStatus, +) -> HorustMsgMessage { + HorustMsgMessage { + message_type: Some(horust_msg_message::MessageType::Response( + HorustMsgResponse { + response: Some(horust_msg_response::Response::StatusResponse( + HorustMsgServiceStatusResponse { + service_name, + service_status: status.into(), + }, + )), + }, + )), + } +} diff --git a/commands/tests/simple.rs b/commands/tests/simple.rs index cfb7ffc..1dcff94 100644 --- a/commands/tests/simple.rs +++ b/commands/tests/simple.rs @@ -23,12 +23,12 @@ impl CommandsHandlerTrait for MockCommandsHandler { &mut self.unix_listener } - fn get_service_status(&self, service_name: String) -> HorustMsgServiceStatus { - match service_name.as_str() { + fn get_service_status(&self, service_name: String) -> Option { + Some(match service_name.as_str() { "Running" => HorustMsgServiceStatus::Running, "Started" => HorustMsgServiceStatus::Started, _ => unimplemented!(), - } + }) } } fn init() { diff --git a/horust/src/horust/commands_handler.rs b/horust/src/horust/commands_handler.rs index 6a88b2d..30eb650 100644 --- a/horust/src/horust/commands_handler.rs +++ b/horust/src/horust/commands_handler.rs @@ -68,7 +68,17 @@ impl CommandsHandlerTrait for CommandsHandler { &mut self.uds_listener } - fn get_service_status(&self, service_name: String) -> HorustMsgServiceStatus { - todo!() + fn get_service_status(&self, service_name: String) -> Option { + self.services.get(&service_name).map(|status| match status { + ServiceStatus::Starting => HorustMsgServiceStatus::Starting, + ServiceStatus::Started => HorustMsgServiceStatus::Started, + ServiceStatus::Running => HorustMsgServiceStatus::Running, + ServiceStatus::InKilling => HorustMsgServiceStatus::Inkilling, + ServiceStatus::Success => HorustMsgServiceStatus::Success, + ServiceStatus::Finished => HorustMsgServiceStatus::Finished, + ServiceStatus::FinishedFailed => HorustMsgServiceStatus::Finishedfailed, + ServiceStatus::Failed => HorustMsgServiceStatus::Failed, + ServiceStatus::Initial => HorustMsgServiceStatus::Initial, + }) } } diff --git a/horustctl/src/main.rs b/horustctl/src/main.rs index 16d19b4..dcde6e4 100644 --- a/horustctl/src/main.rs +++ b/horustctl/src/main.rs @@ -1,14 +1,13 @@ use anyhow::{bail, Result}; use clap::{Args, Parser, Subcommand}; use env_logger::Env; -use horust_commands_lib::{ClientHandler, UdsConnectionHandler}; -use log::{debug, error}; +use horust_commands_lib::{get_path, ClientHandler}; +use log::debug; use std::env; -use std::fs::{read, read_dir}; +use std::fs::read_dir; use std::io::Write; -use std::os::linux::raw::stat; use std::os::unix::net::UnixStream; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; /// Simple program to greet a person #[derive(Parser, Debug)] @@ -16,7 +15,7 @@ use std::path::{Path, PathBuf}; struct HourstctlArgs { /// The pid of the horust process you want to query. Optional if only one horust is running in the system. #[arg(short, long)] - pid: Option, + pid: Option, #[arg(short, long, default_value = "/var/run/horust/")] sockets_folder_path: PathBuf, @@ -63,7 +62,7 @@ fn main() -> Result<()> { Ok(()) } -fn get_uds_path(pid: Option, sockets_folder_path: PathBuf) -> Result { +fn get_uds_path(pid: Option, sockets_folder_path: PathBuf) -> Result { if !sockets_folder_path.exists() { bail!("the specified sockets folder path '{sockets_folder_path:?}' does not exists."); } @@ -71,38 +70,22 @@ fn get_uds_path(pid: Option, sockets_folder_path: PathBuf) -> Result 0 { - bail!("There is more than one socket in {sockets_folder_path:?}.Please use --pid to specify the pid of the horust process you want to talk to."); + let socket_path = match pid { + None => { + let mut readdir_iter = read_dir(&sockets_folder_path)?; + let ret = readdir_iter + .next() + .unwrap()? // check if it's there. + .file_name() + .to_string_lossy() + .to_string(); + if readdir_iter.count() > 0 { + bail!("There is more than one socket in {sockets_folder_path:?}.Please use --pid to specify the pid of the horust process you want to talk to."); + } + sockets_folder_path.join(ret) } - ret - } else { - pid.map(|p| format!("{p}.uds")).unwrap() + Some(pid) => get_path(&sockets_folder_path, pid), }; - debug!("Socket filename: {socket_file_name}"); - Ok(sockets_folder_path.join(socket_file_name)) -} - -fn handle_status(socket_path: PathBuf) -> Result<()> { - // `args` returns the arguments passed to the program - let args: Vec = env::args().map(|x| x.to_string()).collect(); - - // Connect to socket - let mut stream = match UnixStream::connect(&socket_path) { - Err(_) => panic!("server is not running"), - Ok(stream) => stream, - }; - - // Send message - if let Err(_) = stream.write(b"hello") { - panic!("couldn't send message") - } - Ok(()) + debug!("Socket filename: {socket_path:?}"); + Ok(socket_path) } From c343759241689ac9f583437ea01ff6417bf8a061 Mon Sep 17 00:00:00 2001 From: Federico Ponzi Date: Wed, 23 Aug 2023 09:24:13 +0100 Subject: [PATCH 07/11] cargo fmt happy --- commands/src/proto/messages.rs | 135 +++++++++++++++++++++++++++++++++ horustctl/tests/cli.rs | 1 + 2 files changed, 136 insertions(+) create mode 100644 commands/src/proto/messages.rs diff --git a/commands/src/proto/messages.rs b/commands/src/proto/messages.rs new file mode 100644 index 0000000..56ae9ec --- /dev/null +++ b/commands/src/proto/messages.rs @@ -0,0 +1,135 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HorustMsgMessage { + #[prost(oneof = "horust_msg_message::MessageType", tags = "1, 2")] + pub message_type: ::core::option::Option, +} +/// Nested message and enum types in `HorustMsgMessage`. +pub mod horust_msg_message { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum MessageType { + #[prost(message, tag = "1")] + Request(super::HorustMsgRequest), + #[prost(message, tag = "2")] + Response(super::HorustMsgResponse), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HorustMsgRequest { + #[prost(oneof = "horust_msg_request::Request", tags = "1, 2")] + pub request: ::core::option::Option, +} +/// Nested message and enum types in `HorustMsgRequest`. +pub mod horust_msg_request { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Request { + #[prost(message, tag = "1")] + StatusRequest(super::HorustMsgServiceStatusRequest), + #[prost(message, tag = "2")] + ChangeRequest(super::HorustMsgServiceChangeRequest), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HorustMsgResponse { + #[prost(oneof = "horust_msg_response::Response", tags = "1, 2")] + pub response: ::core::option::Option, +} +/// Nested message and enum types in `HorustMsgResponse`. +pub mod horust_msg_response { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Response { + #[prost(message, tag = "1")] + Error(super::HorustMsgError), + #[prost(message, tag = "2")] + StatusResponse(super::HorustMsgServiceStatusResponse), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HorustMsgError { + #[prost(string, tag = "1")] + pub error_string: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HorustMsgServiceStatusRequest { + #[prost(string, tag = "1")] + pub service_name: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HorustMsgServiceStatusResponse { + #[prost(string, tag = "1")] + pub service_name: ::prost::alloc::string::String, + #[prost(enumeration = "HorustMsgServiceStatus", tag = "2")] + pub service_status: i32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HorustMsgServiceChangeRequest { + #[prost(string, tag = "1")] + pub service_name: ::prost::alloc::string::String, + #[prost(enumeration = "HorustMsgServiceStatus", tag = "2")] + pub service_status: i32, +} +/// return the current status - similar to HorustServiceStatusReponse. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HorustMsgServiceChangeResponse { + #[prost(string, tag = "1")] + pub service_name: ::prost::alloc::string::String, + #[prost(enumeration = "HorustMsgServiceStatus", tag = "2")] + pub service_status: i32, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum HorustMsgServiceStatus { + Starting = 0, + Started = 1, + Running = 2, + Inkilling = 3, + Success = 4, + Finished = 5, + Finishedfailed = 6, + Failed = 7, + Initial = 8, +} +impl HorustMsgServiceStatus { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + HorustMsgServiceStatus::Starting => "STARTING", + HorustMsgServiceStatus::Started => "STARTED", + HorustMsgServiceStatus::Running => "RUNNING", + HorustMsgServiceStatus::Inkilling => "INKILLING", + HorustMsgServiceStatus::Success => "SUCCESS", + HorustMsgServiceStatus::Finished => "FINISHED", + HorustMsgServiceStatus::Finishedfailed => "FINISHEDFAILED", + HorustMsgServiceStatus::Failed => "FAILED", + HorustMsgServiceStatus::Initial => "INITIAL", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "STARTING" => Some(Self::Starting), + "STARTED" => Some(Self::Started), + "RUNNING" => Some(Self::Running), + "INKILLING" => Some(Self::Inkilling), + "SUCCESS" => Some(Self::Success), + "FINISHED" => Some(Self::Finished), + "FINISHEDFAILED" => Some(Self::Finishedfailed), + "FAILED" => Some(Self::Failed), + "INITIAL" => Some(Self::Initial), + _ => None, + } + } +} diff --git a/horustctl/tests/cli.rs b/horustctl/tests/cli.rs index e69de29..8b13789 100644 --- a/horustctl/tests/cli.rs +++ b/horustctl/tests/cli.rs @@ -0,0 +1 @@ + From 1ee2ebdcab01f561f1753c1983de10c7400a8e2b Mon Sep 17 00:00:00 2001 From: Federico Ponzi Date: Wed, 23 Aug 2023 09:27:58 +0100 Subject: [PATCH 08/11] Install protoc --- .github/workflows/CI.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0288103..546fb4c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -23,7 +23,6 @@ jobs: components: rustfmt profile: minimal override: true - - name: cargo fmt -- --check uses: actions-rs/cargo@v1 with: @@ -38,13 +37,10 @@ jobs: strategy: matrix: - build: [stable, beta, nightly] + build: [stable, beta] include: - build: beta rust: beta - - build: nightly - rust: nightly - benches: true steps: - name: Checkout @@ -57,12 +53,16 @@ jobs: profile: minimal override: true + - name: Install protoc + run: sudo apt-get install -y protobuf-compiler + - name: Build debug uses: actions-rs/cargo@v1 with: command: build args: ${{ matrix.features }} - + - name: Create /var/run/horust directory + run: sudo mkdir -p /var/run/horust && sudo chmod 777 /var/run/horust - name: Test uses: actions-rs/cargo@v1 with: @@ -120,6 +120,9 @@ jobs: override: true target: ${{ matrix.target }} + - name: Install protoc + run: sudo apt-get install -y protobuf-compiler + - name: Build target uses: actions-rs/cargo@v1 with: From ca0f7eda1936c9352d823bb1aba1d5c5d6b61bbb Mon Sep 17 00:00:00 2001 From: Federico Ponzi Date: Mon, 28 Aug 2023 21:36:25 +0100 Subject: [PATCH 09/11] Some refactorings, docs and initial work for updating service status --- commands/src/client.rs | 8 ++--- commands/src/server.rs | 47 +++++++++++++++++++------- commands/tests/simple.rs | 4 +-- horust/src/horust/commands_handler.rs | 48 +++++++++++++++++++-------- horust/src/horust/formats/mod.rs | 3 -- horustctl/README.md | 11 ++++++ horustctl/src/main.rs | 3 -- 7 files changed, 87 insertions(+), 37 deletions(-) diff --git a/commands/src/client.rs b/commands/src/client.rs index c77cdcf..693ab69 100644 --- a/commands/src/client.rs +++ b/commands/src/client.rs @@ -6,7 +6,7 @@ use crate::proto::messages::{ use crate::{HorustMsgServiceStatus, UdsConnectionHandler}; use anyhow::{anyhow, Context}; use anyhow::{bail, Result}; -use log::info; +use log::{debug, info}; use std::net::Shutdown; use std::os::unix::net::UnixStream; use std::path::Path; @@ -59,13 +59,13 @@ impl ClientHandler { .shutdown(Shutdown::Write)?; //Reads all bytes until EOF in this source, appending them to buf. let received = self.uds_connection_handler.receive_message()?; - info!("Client: received: {received:?}"); + debug!("Client: received: {received:?}"); let response = unwrap_response(received).unwrap()?; if let horust_msg_response::Response::StatusResponse(resp) = response { - return Ok(( + Ok(( resp.service_name, HorustMsgServiceStatus::from_i32(resp.service_status).unwrap(), - )); + )) } else { bail!("Invalid response received: {:?}", response); } diff --git a/commands/src/server.rs b/commands/src/server.rs index 40e9e11..5db56dc 100644 --- a/commands/src/server.rs +++ b/commands/src/server.rs @@ -22,6 +22,7 @@ pub trait CommandsHandlerTrait { Ok((stream, _addr)) => { let conn_handler = UdsConnectionHandler::new(stream); if let Err(err) = self.handle_connection(conn_handler) { + //todo: send response back. error!("Error handling connection: {}", err); } } @@ -39,39 +40,61 @@ pub trait CommandsHandlerTrait { .receive_message()? .message_type .ok_or(anyhow!("No request found in message sent from client."))?; + if let Request(HorustMsgRequest { request: Some(request), }) = received { - match request { + let response = match request { horust_msg_request::Request::StatusRequest(status_request) => { info!("Requested status for {}", status_request.service_name); - let service_name = status_request.service_name.clone(); - let service_status = - self.get_service_status(status_request.service_name.clone()); - let response = service_status + let service_status = self.get_service_status(&status_request.service_name); + service_status .map(|status| { new_horust_msg_service_status_response( status_request.service_name, status, ) }) - .unwrap_or_else(|| { + .unwrap_or_else(|err| { new_horust_msg_error_response(format!( - "Service {} not found.", - service_name + "Error from status handler: {err}", )) - }); - uds_conn_handler.send_message(response)?; + }) + } + horust_msg_request::Request::ChangeRequest(change_request) => { + info!( + "Requested service update for {} to {}", + change_request.service_name, change_request.service_status + ); + self.update_service_status( + &change_request.service_name, + HorustMsgServiceStatus::from_i32(change_request.service_status).unwrap(), + ) + .map(|new_status| { + // TODO: + new_horust_msg_service_status_response( + change_request.service_name, + new_status, + ) + }) + .unwrap_or_else(|err| { + new_horust_msg_error_response(format!("Error from change handler: {err}")) + }) } - horust_msg_request::Request::ChangeRequest(_) => {} }; + uds_conn_handler.send_message(response)?; } Ok(()) } - fn get_service_status(&self, service_name: String) -> Option; + fn get_service_status(&self, service_name: &str) -> Result; + fn update_service_status( + &self, + service_name: &str, + new_status: HorustMsgServiceStatus, + ) -> Result<()>; } pub fn new_horust_msg_error_response(error: String) -> HorustMsgMessage { diff --git a/commands/tests/simple.rs b/commands/tests/simple.rs index 1dcff94..e618a6a 100644 --- a/commands/tests/simple.rs +++ b/commands/tests/simple.rs @@ -23,8 +23,8 @@ impl CommandsHandlerTrait for MockCommandsHandler { &mut self.unix_listener } - fn get_service_status(&self, service_name: String) -> Option { - Some(match service_name.as_str() { + fn get_service_status(&self, service_name: &str) -> Result { + Ok(match service_name { "Running" => HorustMsgServiceStatus::Running, "Started" => HorustMsgServiceStatus::Started, _ => unimplemented!(), diff --git a/horust/src/horust/commands_handler.rs b/horust/src/horust/commands_handler.rs index 30eb650..908282a 100644 --- a/horust/src/horust/commands_handler.rs +++ b/horust/src/horust/commands_handler.rs @@ -1,6 +1,7 @@ use crate::horust::bus::BusConnector; use crate::horust::formats::{ServiceName, ServiceStatus}; use crate::horust::Event; +use anyhow::{anyhow, bail, Result}; use horust_commands_lib::{CommandsHandlerTrait, HorustMsgServiceStatus}; use std::collections::HashMap; use std::os::unix::net::UnixListener; @@ -29,7 +30,7 @@ struct CommandsHandler { impl CommandsHandler { fn new(bus: BusConnector, uds_path: PathBuf, services: Vec) -> Self { - let mut uds_listener = UnixListener::bind(&uds_path).unwrap(); + let uds_listener = UnixListener::bind(&uds_path).unwrap(); uds_listener.set_nonblocking(true).unwrap(); Self { bus, @@ -68,17 +69,38 @@ impl CommandsHandlerTrait for CommandsHandler { &mut self.uds_listener } - fn get_service_status(&self, service_name: String) -> Option { - self.services.get(&service_name).map(|status| match status { - ServiceStatus::Starting => HorustMsgServiceStatus::Starting, - ServiceStatus::Started => HorustMsgServiceStatus::Started, - ServiceStatus::Running => HorustMsgServiceStatus::Running, - ServiceStatus::InKilling => HorustMsgServiceStatus::Inkilling, - ServiceStatus::Success => HorustMsgServiceStatus::Success, - ServiceStatus::Finished => HorustMsgServiceStatus::Finished, - ServiceStatus::FinishedFailed => HorustMsgServiceStatus::Finishedfailed, - ServiceStatus::Failed => HorustMsgServiceStatus::Failed, - ServiceStatus::Initial => HorustMsgServiceStatus::Initial, - }) + fn get_service_status(&self, service_name: &str) -> anyhow::Result { + self.services + .get(service_name) + .map(from_service_status) + .ok_or_else(|| anyhow!("Error: service {service_name} not found.")) + } + fn update_service_status( + &self, + service_name: &str, + new_status: HorustMsgServiceStatus, + ) -> Result<()> { + match self.services.get(&service_name) { + None => bail!("Service {service_name} not found."), + Some(service_status) if from_service_status(service_status) != new_status => { + //self.bus.send_event(Event::Kill()) + } + _ => Ok(()), + } + todo!(); + } +} + +fn from_service_status(status: &ServiceStatus) -> HorustMsgServiceStatus { + match status { + ServiceStatus::Starting => HorustMsgServiceStatus::Starting, + ServiceStatus::Started => HorustMsgServiceStatus::Started, + ServiceStatus::Running => HorustMsgServiceStatus::Running, + ServiceStatus::InKilling => HorustMsgServiceStatus::Inkilling, + ServiceStatus::Success => HorustMsgServiceStatus::Success, + ServiceStatus::Finished => HorustMsgServiceStatus::Finished, + ServiceStatus::FinishedFailed => HorustMsgServiceStatus::Finishedfailed, + ServiceStatus::Failed => HorustMsgServiceStatus::Failed, + ServiceStatus::Initial => HorustMsgServiceStatus::Initial, } } diff --git a/horust/src/horust/formats/mod.rs b/horust/src/horust/formats/mod.rs index 043b691..f792b6f 100644 --- a/horust/src/horust/formats/mod.rs +++ b/horust/src/horust/formats/mod.rs @@ -13,7 +13,6 @@ pub enum ShuttingDown { #[derive(Debug, Clone, PartialEq, Eq)] pub enum Event { PidChanged(ServiceName, Pid), - ServiceStarted(ServiceName), // This command updates the service status. StatusUpdate(ServiceName, ServiceStatus), // This event represents a status change. @@ -25,8 +24,6 @@ pub enum Event { Run(ServiceName), ShuttingDownInitiated(ShuttingDown), HealthCheck(ServiceName, HealthinessStatus), - // TODO: to allow changes of service at supervisor: - //ServiceCreated(ServiceHandler) } impl Event { diff --git a/horustctl/README.md b/horustctl/README.md index e69de29..5bf4958 100644 --- a/horustctl/README.md +++ b/horustctl/README.md @@ -0,0 +1,11 @@ +## Hourstctl +A command line interface to interact with an horust process. It works using Unix Domain Sockets. +Each horust process will create a new uds socket inside /var/run/horust/horust-.sock folder (can be configured). + +You can use horustctl to interact with your horust process. The communication is handled by the `commands` crate. They +exchange protobuf messages. + +Supported commands: +* status [servicename]: get the status of your service `servicename`. If not specified, it will return the status for all services. +* change : can be used to change the status of `servicename`. + Supported `newstatus` options are start, stop. diff --git a/horustctl/src/main.rs b/horustctl/src/main.rs index dcde6e4..40b80d2 100644 --- a/horustctl/src/main.rs +++ b/horustctl/src/main.rs @@ -3,10 +3,7 @@ use clap::{Args, Parser, Subcommand}; use env_logger::Env; use horust_commands_lib::{get_path, ClientHandler}; use log::debug; -use std::env; use std::fs::read_dir; -use std::io::Write; -use std::os::unix::net::UnixStream; use std::path::PathBuf; /// Simple program to greet a person From 5d5bf1b6336925b5592860fd20f243f9b80bf5eb Mon Sep 17 00:00:00 2001 From: Federico Ponzi Date: Tue, 5 Sep 2023 22:38:15 +0100 Subject: [PATCH 10/11] add a test for status command --- Cargo.lock | 39 +++------ Cargo.toml | 1 + commands/src/lib.rs | 2 +- commands/src/server.rs | 5 +- horust/Cargo.toml | 5 +- horust/src/horust/commands_handler.rs | 4 +- horust/src/main.rs | 2 +- horust/tests/utils/mod.rs | 7 +- horustctl/Cargo.toml | 8 +- horustctl/README.md | 2 +- horustctl/src/main.rs | 30 ++++--- horustctl/tests/cli.rs | 116 ++++++++++++++++++++++++++ 12 files changed, 170 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 50726d6..fc68ffc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -174,9 +174,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.3.23" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03aef18ddf7d879c15ce20f04826ef8418101c7e528014c3eeea13321047dca3" +checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" dependencies = [ "clap_builder", "clap_derive", @@ -184,9 +184,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.23" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ce6fffb678c9b80a70b6b6de0aad31df727623a70fd9a842c30cd573e2fa98" +checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" dependencies = [ "anstream", "anstyle", @@ -262,7 +262,7 @@ dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset 0.9.0", + "memoffset", "scopeguard", ] @@ -534,7 +534,6 @@ dependencies = [ "env_logger", "horust-commands-lib", "humantime-serde", - "libc", "log", "maplit", "nix", @@ -567,11 +566,15 @@ name = "horustctl" version = "0.1.0" dependencies = [ "anyhow", + "assert_cmd", "clap", "crossbeam", "env_logger", "horust-commands-lib", "log", + "predicates", + "rand 0.8.5", + "tempdir", ] [[package]] @@ -755,15 +758,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.9.0" @@ -807,16 +801,13 @@ checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" [[package]] name = "nix" -version = "0.26.2" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.0", "cfg-if", "libc", - "memoffset 0.7.1", - "pin-utils", - "static_assertions", ] [[package]] @@ -1307,12 +1298,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "strsim" version = "0.10.0" diff --git a/Cargo.toml b/Cargo.toml index 1c6420e..73c968e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,2 +1,3 @@ [workspace] +resolver = "2" members = ["horustctl", "commands", "horust"] diff --git a/commands/src/lib.rs b/commands/src/lib.rs index 3464c20..ca4e80c 100644 --- a/commands/src/lib.rs +++ b/commands/src/lib.rs @@ -16,7 +16,7 @@ use std::path::{Path, PathBuf}; /// socket_name should be the pid of the horust process. pub fn get_path(socket_folder_path: &Path, horust_pid: i32) -> PathBuf { - socket_folder_path.join(format!("hourst-{horust_pid}.sock")) + socket_folder_path.join(format!("horust-{horust_pid}.sock")) } pub struct UdsConnectionHandler { diff --git a/commands/src/server.rs b/commands/src/server.rs index 5db56dc..762448d 100644 --- a/commands/src/server.rs +++ b/commands/src/server.rs @@ -68,7 +68,8 @@ pub trait CommandsHandlerTrait { "Requested service update for {} to {}", change_request.service_name, change_request.service_status ); - self.update_service_status( + new_horust_msg_error_response(format!("Unimplemented!")) + /*self.update_service_status( &change_request.service_name, HorustMsgServiceStatus::from_i32(change_request.service_status).unwrap(), ) @@ -81,7 +82,7 @@ pub trait CommandsHandlerTrait { }) .unwrap_or_else(|err| { new_horust_msg_error_response(format!("Error from change handler: {err}")) - }) + })*/ } }; uds_conn_handler.send_message(response)?; diff --git a/horust/Cargo.toml b/horust/Cargo.toml index 752a02f..6c119dd 100644 --- a/horust/Cargo.toml +++ b/horust/Cargo.toml @@ -13,13 +13,12 @@ categories = ["command-line-utilities"] include = ["src/**/*", "Cargo.*", "LICENSE.txt", "README.md", "/example_services/**/*"] [dependencies] -clap = { version = "~4.3", features = ["derive"] } +clap = { version = "~4.4", features = ["derive"] } crossbeam = "~0.8" env_logger = "0.10.0" humantime-serde = "~1.1" -libc = "0.2.147" log = "~0.4" -nix = "~0.26" +nix = "~0.27" reqwest = { version = "0.11.18", features = ["blocking", "json"], optional = true, default-features = false } serde = { version = "~1.0", features = ["derive"] } shlex = "~1.1" diff --git a/horust/src/horust/commands_handler.rs b/horust/src/horust/commands_handler.rs index 908282a..5bbf8c5 100644 --- a/horust/src/horust/commands_handler.rs +++ b/horust/src/horust/commands_handler.rs @@ -80,13 +80,13 @@ impl CommandsHandlerTrait for CommandsHandler { service_name: &str, new_status: HorustMsgServiceStatus, ) -> Result<()> { - match self.services.get(&service_name) { + /* match self.services.get(&service_name) { None => bail!("Service {service_name} not found."), Some(service_status) if from_service_status(service_status) != new_status => { //self.bus.send_event(Event::Kill()) } _ => Ok(()), - } + }*/ todo!(); } } diff --git a/horust/src/main.rs b/horust/src/main.rs index c64784b..3d517f7 100644 --- a/horust/src/main.rs +++ b/horust/src/main.rs @@ -27,7 +27,7 @@ struct Opts { /// Path to service file or a directory containing services to run. You can provide more than one argument to load multiple directories / services. services_paths: Vec, - #[arg(required = false, default_value = "/var/run/horust")] + #[arg(required = false, long, default_value = "/var/run/horust")] /// Path to the folder that contains the Unix Domain Socket, used to communicate with horustctl uds_folder_path: PathBuf, diff --git a/horust/tests/utils/mod.rs b/horust/tests/utils/mod.rs index d78cd37..7212cc3 100644 --- a/horust/tests/utils/mod.rs +++ b/horust/tests/utils/mod.rs @@ -32,10 +32,11 @@ pub fn store_service(dir: &Path, service: &str, service_name: Option<&str>) -> S /// Creates script and service file, and stores them in dir. /// It will append a `command` at the top of the service, with a reference to script. /// Returns the service name. -pub fn store_service_script( +/// if service_name is None a random name will be used. +pub fn store_service( dir: &Path, script: &str, - service: Option<&str>, + service_content: Option<&str>, service_name: Option<&str>, ) -> String { let rnd_name = create_random_name(); @@ -47,7 +48,7 @@ pub fn store_service_script( r#"command = "/usr/bin/env bash {}" {}"#, script_path.display(), - service.unwrap_or("") + service_content.unwrap_or("") ); store_service(dir, &service, Some(&service_name)) } diff --git a/horustctl/Cargo.toml b/horustctl/Cargo.toml index 58cc3e5..f676326 100644 --- a/horustctl/Cargo.toml +++ b/horustctl/Cargo.toml @@ -9,6 +9,12 @@ anyhow = "~1.0" log = "~0.4" env_logger = "0.10.0" crossbeam = "~0.8" -clap = {version = "~4.3", features = ["derive"]} +clap = {version = "~4.4", features = ["derive"]} horust-commands-lib = {path = "../commands"} + +[dev-dependencies] +assert_cmd = "2.0.12" +predicates = "~3.0" +tempdir = "~0.3" +rand = "~0.8" \ No newline at end of file diff --git a/horustctl/README.md b/horustctl/README.md index 5bf4958..fc39906 100644 --- a/horustctl/README.md +++ b/horustctl/README.md @@ -1,4 +1,4 @@ -## Hourstctl +## Horustctl A command line interface to interact with an horust process. It works using Unix Domain Sockets. Each horust process will create a new uds socket inside /var/run/horust/horust-.sock folder (can be configured). diff --git a/horustctl/src/main.rs b/horustctl/src/main.rs index 40b80d2..8f6cf92 100644 --- a/horustctl/src/main.rs +++ b/horustctl/src/main.rs @@ -1,21 +1,22 @@ -use anyhow::{bail, Result}; +use anyhow::{anyhow, bail, Result}; use clap::{Args, Parser, Subcommand}; use env_logger::Env; use horust_commands_lib::{get_path, ClientHandler}; use log::debug; use std::fs::read_dir; +use std::os::unix::fs::FileTypeExt; use std::path::PathBuf; /// Simple program to greet a person #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] -struct HourstctlArgs { +struct HorustctlArgs { /// The pid of the horust process you want to query. Optional if only one horust is running in the system. #[arg(short, long)] pid: Option, #[arg(short, long, default_value = "/var/run/horust/")] - sockets_folder_path: PathBuf, + uds_folder_path: PathBuf, // Specify the full path of the socket. It takes precedence other over arguments. #[arg(long)] @@ -37,11 +38,11 @@ struct StatusArgs { fn main() -> Result<()> { env_logger::Builder::from_env(Env::default().default_filter_or("debug")).init(); - let args = HourstctlArgs::parse(); + let args = HorustctlArgs::parse(); debug!("args: {args:?}"); let uds_path = args.socket_path.unwrap_or_else(|| { - get_uds_path(args.pid, args.sockets_folder_path).expect("Failed to get uds_path.") + get_uds_path(args.pid, args.uds_folder_path).expect("Failed to get uds_path.") }); let mut uds_handler = ClientHandler::new_client(&uds_path)?; match &args.commands { @@ -69,13 +70,22 @@ fn get_uds_path(pid: Option, sockets_folder_path: PathBuf) -> Result { - let mut readdir_iter = read_dir(&sockets_folder_path)?; + let mut readdir_iter = read_dir(&sockets_folder_path)? + .filter_map(|d| d.ok()) // unwrap results + .filter_map(|d| -> Option { + let is_socket = d.file_type().ok()?.is_socket(); + let name = d.file_name(); + let name = name.to_string_lossy(); + if is_socket && name.starts_with("horust-") && name.ends_with(".sock") { + Some(name.to_string()) + } else { + None + } + }); + let ret = readdir_iter .next() - .unwrap()? // check if it's there. - .file_name() - .to_string_lossy() - .to_string(); + .ok_or_else(|| anyhow!("No socket found in {sockets_folder_path:?}"))?; if readdir_iter.count() > 0 { bail!("There is more than one socket in {sockets_folder_path:?}.Please use --pid to specify the pid of the horust process you want to talk to."); } diff --git a/horustctl/tests/cli.rs b/horustctl/tests/cli.rs index 8b13789..9c2ce84 100644 --- a/horustctl/tests/cli.rs +++ b/horustctl/tests/cli.rs @@ -1 +1,117 @@ +use assert_cmd::Command; +use predicates::boolean::PredicateBooleanExt; +use predicates::str::contains; +use rand::distributions::Alphanumeric; +use rand::{thread_rng, Rng}; +use std::path::Path; +use std::thread; +use std::time::Duration; +use tempdir::TempDir; +/// Creates script and service file, and stores them in dir. +/// It will append a `command` at the top of the service, with a reference to script. +/// Returns the service name. +/// if service_name is None a random name will be used. +pub fn store_service( + dir: &Path, + script: &str, + service_content: Option<&str>, + filename: Option<&str>, +) -> String { + let rnd_name = thread_rng() + .sample_iter(&Alphanumeric) + .take(5) + .map(|x| x as char) + .collect::(); + let service_name = format!("{}.toml", filename.unwrap_or(rnd_name.as_str())); + let script_name = format!("{}.sh", rnd_name); + let script_path = dir.join(script_name); + std::fs::write(&script_path, script).unwrap(); + let service = format!( + r#"command = "/usr/bin/env bash {}" +{}"#, + script_path.display(), + service_content.unwrap_or("") + ); + std::fs::write(dir.join(&service_name), service).unwrap(); + service_name +} + +#[test] +fn test_cli_help() { + let mut cmd = Command::cargo_bin("horustctl").unwrap(); + cmd.args(vec!["--help"]).assert().success(); +} + +static ENVIRONMENT_SCRIPT: &str = r#"#!/usr/bin/env bash +printenv"#; + +#[test] +fn test_cli_status() { + let temp_dir = TempDir::new("horustctl").unwrap(); + let mut horust_cmd = Command::cargo_bin("horust").unwrap(); + + horust_cmd.current_dir(&temp_dir).args(vec![ + "--services-path", + temp_dir.path().display().to_string().as_str(), + "--uds-folder-path", + temp_dir.path().display().to_string().as_str(), + ]); + + store_service( + temp_dir.path(), + ENVIRONMENT_SCRIPT, + None, + Some("terminated"), + ); + horust_cmd.assert().success().stdout(contains("bar").not()); + // Exit after 5 seconds. + store_service( + temp_dir.path(), + r#"#!/usr/bin/env bash + trap 'quit=1' USR1 + touch file +i=0; +while [ "$i" -lt 5 ]; do + sleep 1 +done"#, + None, + Some("running"), + ); + + thread::spawn(move || { + horust_cmd.assert().success().stdout(contains("bar")); + }); + let mut total_wait = 0; + const MAX_WAIT_TIME: u32 = 1000; + // created by running script + while !temp_dir.path().join("file").exists() && total_wait < MAX_WAIT_TIME { + total_wait += 50; + thread::sleep(Duration::from_millis(50)); + } + let mut horustctl_cmd = Command::cargo_bin("horustctl").unwrap(); + let horustctl_cmd = horustctl_cmd + .current_dir(&temp_dir) + .args(vec![ + "--uds-folder-path", + temp_dir.path().display().to_string().as_str(), + "status", + "terminated.toml", + ]) + .assert() + .success() + .stdout(contains("terminated")); + + let mut horustctl_cmd = Command::cargo_bin("horustctl").unwrap(); + horustctl_cmd + .current_dir(&temp_dir) + .args(vec![ + "--uds-folder-path", + temp_dir.path().display().to_string().as_str(), + "status", + "running.toml", + ]) + .assert() + .success() + .stdout(contains("running")); +} From 31839f5121d84f792b88d40df65d2794dd406f27 Mon Sep 17 00:00:00 2001 From: Federico Ponzi Date: Thu, 28 Sep 2023 08:46:17 +0100 Subject: [PATCH 11/11] fixes after rebase --- Cargo.lock | 20 ++++++++++++++++---- commands/tests/simple.rs | 8 ++++++++ horust/Cargo.toml | 3 ++- horust/src/main.rs | 5 ++++- horust/tests/horust.rs | 2 +- horust/tests/section_failure.rs | 2 +- horust/tests/utils/mod.rs | 13 +++++++++---- horustctl/tests/cli.rs | 6 +++--- 8 files changed, 44 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fc68ffc..e104e95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -262,7 +262,7 @@ dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset", + "memoffset 0.9.0", "scopeguard", ] @@ -534,6 +534,7 @@ dependencies = [ "env_logger", "horust-commands-lib", "humantime-serde", + "libc", "log", "maplit", "nix", @@ -758,6 +759,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + [[package]] name = "memoffset" version = "0.9.0" @@ -801,13 +811,15 @@ checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" [[package]] name = "nix" -version = "0.27.1" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" dependencies = [ - "bitflags 2.4.0", + "bitflags 1.3.2", "cfg-if", "libc", + "memoffset 0.7.1", + "pin-utils", ] [[package]] diff --git a/commands/tests/simple.rs b/commands/tests/simple.rs index e618a6a..fa5bf89 100644 --- a/commands/tests/simple.rs +++ b/commands/tests/simple.rs @@ -30,6 +30,14 @@ impl CommandsHandlerTrait for MockCommandsHandler { _ => unimplemented!(), }) } + + fn update_service_status( + &self, + service_name: &str, + new_status: HorustMsgServiceStatus, + ) -> Result<()> { + todo!() + } } fn init() { let _ = env_logger::builder().is_test(true).try_init(); diff --git a/horust/Cargo.toml b/horust/Cargo.toml index 6c119dd..2a7b9f9 100644 --- a/horust/Cargo.toml +++ b/horust/Cargo.toml @@ -18,7 +18,8 @@ crossbeam = "~0.8" env_logger = "0.10.0" humantime-serde = "~1.1" log = "~0.4" -nix = "~0.27" +nix = "~0.26" +libc = "~0.2" reqwest = { version = "0.11.18", features = ["blocking", "json"], optional = true, default-features = false } serde = { version = "~1.0", features = ["derive"] } shlex = "~1.1" diff --git a/horust/src/main.rs b/horust/src/main.rs index 3d517f7..01d7107 100644 --- a/horust/src/main.rs +++ b/horust/src/main.rs @@ -51,7 +51,10 @@ fn main() -> Result<()> { } if !opts.uds_folder_path.exists() { - std::fs::create_dir_all(&opts.uds_folder_path)?; + std::fs::create_dir_all(&opts.uds_folder_path).context(format!( + "Failed to create the uds folder to path '{:?}'", + opts.uds_folder_path + ))?; } if !opts.uds_folder_path.is_dir() { diff --git a/horust/tests/horust.rs b/horust/tests/horust.rs index ef62cf1..8210ffc 100644 --- a/horust/tests/horust.rs +++ b/horust/tests/horust.rs @@ -42,7 +42,7 @@ fn test_command_not_found() { .collect::(); let service_name = format!("{}.toml", rnd_name.as_str()); let service = format!(r#"command = ",sorry_not_found{}""#, rnd_name); - std::fs::write(dir.join(&service_name), service).unwrap(); + std::fs::write(dir.join(service_name), service).unwrap(); let recv = run_async(&mut cmd, true); // Error spawning process: NixError: ENOENT: No such file or directory // It's fine diff --git a/horust/tests/section_failure.rs b/horust/tests/section_failure.rs index f865bce..109a4f6 100644 --- a/horust/tests/section_failure.rs +++ b/horust/tests/section_failure.rs @@ -31,7 +31,7 @@ wait = "500millis" let sleep_script = r#"#!/usr/bin/env bash sleep 30"#; - //store_service(temp_dir.path(), sleep_script, None, None); + //store_service_script(temp_dir.path(), sleep_script, None, None); store_service_script(temp_dir.path(), sleep_script, Some(sleep_service), None); let recv = run_async(&mut cmd, true); recv.recv_or_kill(Duration::from_secs(15)); diff --git a/horust/tests/utils/mod.rs b/horust/tests/utils/mod.rs index 7212cc3..9cc2342 100644 --- a/horust/tests/utils/mod.rs +++ b/horust/tests/utils/mod.rs @@ -33,7 +33,7 @@ pub fn store_service(dir: &Path, service: &str, service_name: Option<&str>) -> S /// It will append a `command` at the top of the service, with a reference to script. /// Returns the service name. /// if service_name is None a random name will be used. -pub fn store_service( +pub fn store_service_script( dir: &Path, script: &str, service_content: Option<&str>, @@ -50,7 +50,8 @@ pub fn store_service( script_path.display(), service_content.unwrap_or("") ); - store_service(dir, &service, Some(&service_name)) + std::fs::write(dir.join(&service_name), service).unwrap(); + service_name } #[allow(dead_code)] @@ -59,6 +60,8 @@ pub fn get_cli_multiple() -> (Command, TempDir, TempDir) { let temp_dir_2 = TempDir::new("horust_2").unwrap(); let mut cmd = Command::cargo_bin("horust").unwrap(); cmd.current_dir(&temp_dir).args(vec![ + "--uds-folder-path", + temp_dir.path().display().to_string().as_str(), "--services-path", temp_dir.path().display().to_string().as_str(), "--services-path", @@ -69,9 +72,11 @@ pub fn get_cli_multiple() -> (Command, TempDir, TempDir) { } pub fn get_cli() -> (Command, TempDir) { - let temp_dir = TempDir::new("horust").unwrap(); - let mut cmd = Command::cargo_bin("horust").unwrap(); + let temp_dir = TempDir::new("horust").expect("Tmp dir"); + let mut cmd = Command::cargo_bin("horust").expect("Cargo bin"); cmd.current_dir(&temp_dir).args(vec![ + "--uds-folder-path", + temp_dir.path().display().to_string().as_str(), "--services-path", temp_dir.path().display().to_string().as_str(), ]); diff --git a/horustctl/tests/cli.rs b/horustctl/tests/cli.rs index 9c2ce84..dfa422d 100644 --- a/horustctl/tests/cli.rs +++ b/horustctl/tests/cli.rs @@ -12,7 +12,7 @@ use tempdir::TempDir; /// It will append a `command` at the top of the service, with a reference to script. /// Returns the service name. /// if service_name is None a random name will be used. -pub fn store_service( +pub fn store_service_script( dir: &Path, script: &str, service_content: Option<&str>, @@ -58,7 +58,7 @@ fn test_cli_status() { temp_dir.path().display().to_string().as_str(), ]); - store_service( + store_service_script( temp_dir.path(), ENVIRONMENT_SCRIPT, None, @@ -66,7 +66,7 @@ fn test_cli_status() { ); horust_cmd.assert().success().stdout(contains("bar").not()); // Exit after 5 seconds. - store_service( + store_service_script( temp_dir.path(), r#"#!/usr/bin/env bash trap 'quit=1' USR1