From c422d6d38c413ae7de35d3a671addeb3ff3696c6 Mon Sep 17 00:00:00 2001 From: "Alexander V. Nikolaev" Date: Sun, 1 Sep 2024 15:49:35 +0300 Subject: [PATCH 1/7] Cleanup Signed-off-by: Alexander V. Nikolaev --- src/systemd_api/server.rs | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/systemd_api/server.rs b/src/systemd_api/server.rs index e9877a3..1bccce9 100644 --- a/src/systemd_api/server.rs +++ b/src/systemd_api/server.rs @@ -1,6 +1,6 @@ use crate::pb; use std::pin::Pin; -use tonic::Status; +use tonic::{Request, Response, Status}; pub use pb::systemd::unit_control_service_server::UnitControlServiceServer; @@ -13,66 +13,65 @@ impl SystemdService { } } -type Stream = - Pin> + Send + 'static>>; +type Stream = Pin> + Send + 'static>>; #[tonic::async_trait] impl pb::systemd::unit_control_service_server::UnitControlService for SystemdService { async fn get_unit_status( &self, - _request: tonic::Request, - ) -> std::result::Result, tonic::Status> { + _request: Request, + ) -> Result, Status> { unimplemented!() } async fn start_unit( &self, - _request: tonic::Request, - ) -> std::result::Result, tonic::Status> { + _request: Request, + ) -> Result, Status> { unimplemented!() } async fn stop_unit( &self, - _request: tonic::Request, - ) -> std::result::Result, tonic::Status> { + _request: Request, + ) -> Result, Status> { unimplemented!() } async fn kill_unit( &self, - _request: tonic::Request, - ) -> std::result::Result, tonic::Status> { + _request: Request, + ) -> Result, Status> { unimplemented!() } async fn freeze_unit( &self, - _request: tonic::Request, - ) -> std::result::Result, tonic::Status> { + _request: Request, + ) -> Result, Status> { unimplemented!() } async fn unfreeze_unit( &self, - _request: tonic::Request, - ) -> std::result::Result, tonic::Status> { + _request: Request, + ) -> Result, Status> { unimplemented!() } /// Server streaming response type for the MonitorUnit method. type MonitorUnitStream = Stream; async fn monitor_unit( &self, - _request: tonic::Request, - ) -> std::result::Result, tonic::Status> { + _request: Request, + ) -> Result, Status> { unimplemented!() } // FIXME: removed from proto? // async fn dbus_method( // &self, // request: tonic::Request, - // ) -> std::result::Result, tonic::Status>{ + // ) -> std::result::Result, Status>{ // unimplemented!() // } async fn start_application( &self, - _request: tonic::Request, - ) -> std::result::Result, tonic::Status> { + _request: Request, + ) -> Result, Status> { unimplemented!() } } From c5d6a4cc9271d4f1092027a94120577fa681cbd0 Mon Sep 17 00:00:00 2001 From: "Alexander V. Nikolaev" Date: Sun, 1 Sep 2024 16:26:43 +0300 Subject: [PATCH 2/7] Bump tonic to 0.12.x Signed-off-by: Alexander V. Nikolaev --- Cargo.lock | 263 +++++++++++++++++++++++++++++++--------------- Cargo.toml | 7 +- client/Cargo.toml | 5 +- common/Cargo.toml | 6 +- src/utils/auth.rs | 4 +- src/utils/x509.rs | 2 +- 6 files changed, 193 insertions(+), 94 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5d5462d..cf6ab87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -165,6 +165,12 @@ dependencies = [ "syn", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.3.0" @@ -173,18 +179,17 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "axum" -version = "0.6.20" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", "axum-core", - "bitflags 1.3.2", "bytes", "futures-util", - "http", - "http-body", - "hyper", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", "itoa", "matchit", "memchr", @@ -193,7 +198,7 @@ dependencies = [ "pin-project-lite", "rustversion", "serde", - "sync_wrapper", + "sync_wrapper 1.0.1", "tower", "tower-layer", "tower-service", @@ -201,17 +206,20 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.3.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", ] @@ -231,24 +239,12 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - [[package]] name = "base64" version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.5.0" @@ -521,10 +517,9 @@ dependencies = [ "console", "givc-client", "givc-common", - "http", - "http-body", - "hyper", - "prost", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", "serde", "serde_json", "strum 0.25.0", @@ -548,9 +543,8 @@ dependencies = [ "async-channel", "async-stream", "givc-common", - "http", - "http-body", - "prost", + "http 0.2.12", + "http-body 0.4.6", "serde", "tokio", "tokio-stream", @@ -565,9 +559,9 @@ version = "0.0.1" dependencies = [ "anyhow", "async-stream", - "http", - "http-body", - "prost", + "http 0.2.12", + "http-body 0.4.6", + "prost 0.13.2", "serde", "strum 0.26.3", "tokio", @@ -581,16 +575,16 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.26" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" dependencies = [ + "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", - "futures-util", - "http", + "http 1.1.0", "indexmap 2.2.6", "slab", "tokio", @@ -639,6 +633,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -646,7 +651,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", "pin-project-lite", ] @@ -672,30 +700,70 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "http 0.2.12", + "http-body 0.4.6", "httparse", "httpdate", "itoa", "pin-project-lite", - "socket2", "tokio", "tower-service", "tracing", "want", ] +[[package]] +name = "hyper" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2", + "http 1.1.0", + "http-body 1.0.1", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + [[package]] name = "hyper-timeout" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" dependencies = [ - "hyper", + "hyper 1.4.1", + "hyper-util", "pin-project-lite", "tokio", - "tokio-io-timeout", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "hyper 1.4.1", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", ] [[package]] @@ -1017,7 +1085,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.12.5", +] + +[[package]] +name = "prost" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2ecbe40f08db5c006b5764a2645f7f3f141ce756412ac9e1dd6087e6d32995" +dependencies = [ + "bytes", + "prost-derive 0.13.2", ] [[package]] @@ -1034,8 +1112,8 @@ dependencies = [ "once_cell", "petgraph", "prettyplease", - "prost", - "prost-types", + "prost 0.12.4", + "prost-types 0.12.4", "regex", "syn", "tempfile", @@ -1054,13 +1132,35 @@ dependencies = [ "syn", ] +[[package]] +name = "prost-derive" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acf0c195eebb4af52c752bec4f52f645da98b6e92077a04110c7f349477ae5ac" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "prost-types" version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" dependencies = [ - "prost", + "prost 0.12.4", +] + +[[package]] +name = "prost-types" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60caa6738c7369b940c3d49246a8d1749323674c65cb13010134f5c9bad5b519" +dependencies = [ + "prost 0.13.2", ] [[package]] @@ -1182,7 +1282,7 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.5.0", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -1191,11 +1291,12 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.4" +version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +checksum = "ebbbdb961df0ad3f2652da8f3fdc4b36122f568f968f45ad3316f26c025c677b" dependencies = [ "log", + "once_cell", "ring", "rustls-pki-types", "rustls-webpki", @@ -1209,7 +1310,7 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64 0.22.1", + "base64", "rustls-pki-types", ] @@ -1386,6 +1487,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "synstructure" version = "0.13.1" @@ -1489,16 +1596,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "tokio-io-timeout" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" -dependencies = [ - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-macros" version = "2.2.0" @@ -1512,9 +1609,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ "rustls", "rustls-pki-types", @@ -1547,25 +1644,27 @@ dependencies = [ [[package]] name = "tonic" -version = "0.11.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" +checksum = "c6f6ba989e4b2c58ae83d862d3a3e27690b6e3ae630d0deb59f3697f32aa88ad" dependencies = [ "async-stream", "async-trait", "axum", - "base64 0.21.7", + "base64", "bytes", "h2", - "http", - "http-body", - "hyper", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.4.1", "hyper-timeout", + "hyper-util", "percent-encoding", "pin-project", - "prost", + "prost 0.13.2", "rustls-pemfile", - "rustls-pki-types", + "socket2", "tokio", "tokio-rustls", "tokio-stream", @@ -1590,12 +1689,12 @@ dependencies = [ [[package]] name = "tonic-reflection" -version = "0.11.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "548c227bd5c0fae5925812c4ec6c66ffcfced23ea370cb823f4d18f0fc1cb6a7" +checksum = "7b56b874eedb04f89907573b408eab1e87c1c1dce43aac6ad63742f57faa99ff" dependencies = [ - "prost", - "prost-types", + "prost 0.13.2", + "prost-types 0.13.2", "tokio", "tokio-stream", "tonic", @@ -1603,12 +1702,12 @@ dependencies = [ [[package]] name = "tonic-types" -version = "0.11.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4aa089471d8d4c60ec3aef047739713a4695f0b309d4cea0073bc55201064f4" +checksum = "9d967793411bc1a5392accf4731114295f0fd122865d22cde46a8584b03402b2" dependencies = [ - "prost", - "prost-types", + "prost 0.13.2", + "prost-types 0.13.2", "tonic", ] diff --git a/Cargo.toml b/Cargo.toml index 335d00d..1bf388f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,12 +23,11 @@ console = "0.15" http = "0.2" http-body = "0.4.2" hyper = "0.14" -prost = "0.12" tokio = {version = "1.0", features = ["rt-multi-thread", "time", "macros"]} tokio-stream = "0.1" -tonic = {version="0.11.0", features = ["tls"]} -tonic-types = {version="0.11.0"} -tonic-reflection = {version="0.11.0"} +tonic = {version="0.12.2", features = ["tls"]} +tonic-types = {version="0.12.2"} +tonic-reflection = {version="0.12.2"} tower = {version = "0.4"} tracing = "0.1" tracing-subscriber = {version = "0.3", features = ["env-filter", "tracing-log", "time", "local-time"]} diff --git a/client/Cargo.toml b/client/Cargo.toml index b57ee4f..1482e19 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -12,11 +12,10 @@ async-channel = "2.3.1" async-stream = "0.3" http = "0.2" http-body = "0.4.2" -prost = "0.12" tokio = {version = "1.0", features = ["rt-multi-thread", "time", "macros"]} tokio-stream = "0.1" -tonic = {version="0.11.0", features = ["tls"]} -tonic-types = {version="0.11.0"} +tonic = {version="0.12.2", features = ["tls"]} +tonic-types = {version="0.12.2"} tracing = "0.1" serde = { version = "1.0.202", features = ["derive"]} diff --git a/common/Cargo.toml b/common/Cargo.toml index 10171fc..bf6f4f5 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -11,11 +11,11 @@ anyhow = "1.0.86" async-stream = "0.3" http = "0.2" http-body = "0.4.2" -prost = "0.12" +prost = "0.13" tokio = {version = "1.0", features = ["rt-multi-thread", "time", "macros"]} tokio-stream = "0.1" -tonic = {version="0.11.0", features = ["tls"]} -tonic-types = {version="0.11.0"} +tonic = {version="0.12.2", features = ["tls"]} +tonic-types = {version="0.12.2"} tracing = "0.1" tracing-subscriber = {version = "0.3"} serde = { version = "1.0.202", features = ["derive"]} diff --git a/src/utils/auth.rs b/src/utils/auth.rs index 25284a5..f4439ec 100644 --- a/src/utils/auth.rs +++ b/src/utils/auth.rs @@ -5,7 +5,9 @@ fn security_info_from_request(req: &Request<()>) -> Result if let Some(certs) = req.peer_certs() { certs .iter() - .find_map(|cert| SecurityInfo::try_from(cert.get_ref()).ok()) + .find_map(|cert| { + SecurityInfo::try_from(cert.as_ref()).ok() + }) .ok_or(Status::unauthenticated("Can't determinate certificace")) } else { Err(Status::unauthenticated("No valid certificate")) diff --git a/src/utils/x509.rs b/src/utils/x509.rs index c1ecd77..cb18c71 100644 --- a/src/utils/x509.rs +++ b/src/utils/x509.rs @@ -2,7 +2,7 @@ use std::convert::TryFrom; use std::net::IpAddr; use x509_parser::prelude::*; -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct SecurityInfo { enabled: bool, dns_names: Vec, From c0f31b2a17c8eee68d799ac2a65b7c7ba13c8bb7 Mon Sep 17 00:00:00 2001 From: "Alexander V. Nikolaev" Date: Wed, 18 Sep 2024 14:18:39 +0300 Subject: [PATCH 3/7] Bump all versions Signed-off-by: Alexander V. Nikolaev --- Cargo.lock | 505 ++++++++++++++++++++++++++--------------------------- 1 file changed, 244 insertions(+), 261 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cf6ab87..3157a84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,18 +4,18 @@ version = 3 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aho-corasick" @@ -28,9 +28,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.14" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", @@ -43,33 +43,33 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.3" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -77,15 +77,15 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "asn1-rs" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ad1373757efa0f70ec53939aabc7152e1591cb485208052993070ac8d2429d" +checksum = "5493c3bedbacf7fd7382c6346bbd66687d12bbaad3a89a2d2c303ee6cf20b048" dependencies = [ "asn1-rs-derive", "asn1-rs-impl", @@ -99,9 +99,9 @@ dependencies = [ [[package]] name = "asn1-rs-derive" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" +checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" dependencies = [ "proc-macro2", "quote", @@ -156,9 +156,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.80" +version = "0.1.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" dependencies = [ "proc-macro2", "quote", @@ -226,17 +226,17 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.71" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets", ] [[package]] @@ -247,21 +247,30 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "byteorder" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "cc" -version = "1.0.97" +version = "1.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" +checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -271,9 +280,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.4" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" dependencies = [ "clap_builder", "clap_derive", @@ -281,9 +290,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" dependencies = [ "anstream", "anstyle", @@ -293,9 +302,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -305,15 +314,15 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "colorchoice" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "concurrent-queue" @@ -385,9 +394,9 @@ dependencies = [ [[package]] name = "either" -version = "1.11.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "encode_unicode" @@ -434,9 +443,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fixedbitset" @@ -502,9 +511,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] name = "givc" @@ -519,7 +528,7 @@ dependencies = [ "givc-common", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", + "hyper 0.14.30", "serde", "serde_json", "strum 0.25.0", @@ -585,7 +594,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.1.0", - "indexmap 2.2.6", + "indexmap 2.5.0", "slab", "tokio", "tokio-util", @@ -680,9 +689,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -692,9 +701,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", @@ -748,9 +757,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" dependencies = [ "bytes", "futures-channel", @@ -778,9 +787,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -788,9 +797,9 @@ dependencies = [ [[package]] name = "is_terminal_polyfill" -version = "1.70.0" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itertools" @@ -801,6 +810,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -809,27 +827,27 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.154" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "matchers" @@ -848,9 +866,9 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "mime" @@ -866,22 +884,23 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] name = "mio" -version = "0.8.11" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ + "hermit-abi", "libc", "wasi", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -944,16 +963,6 @@ dependencies = [ "autocfg", ] -[[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 = "num_threads" version = "0.1.7" @@ -965,18 +974,18 @@ dependencies = [ [[package]] name = "object" -version = "0.32.2" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] [[package]] name = "oid-registry" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c958dd45046245b9c3c2547369bb634eb461670b2e7e0de552905801a648d1d" +checksum = "a8d8034d9489cdaf79228eb9f6a3b8d7bb32ba00d6645ebd48eef4077ceb5bd9" dependencies = [ "asn1-rs", ] @@ -995,9 +1004,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "parking" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" [[package]] name = "percent-encoding" @@ -1012,7 +1021,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.2.6", + "indexmap 2.5.0", ] [[package]] @@ -1055,15 +1064,18 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "prettyplease" -version = "0.2.20" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2", "syn", @@ -1071,21 +1083,21 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "prost" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", - "prost-derive 0.12.5", + "prost-derive 0.12.6", ] [[package]] @@ -1100,20 +1112,20 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80b776a1b2dc779f5ee0641f8ade0125bc1298dd41a9a0c16d8bd57b42d222b1" +checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes", "heck 0.5.0", - "itertools", + "itertools 0.12.1", "log", "multimap", "once_cell", "petgraph", "prettyplease", - "prost 0.12.4", - "prost-types 0.12.4", + "prost 0.12.6", + "prost-types 0.12.6", "regex", "syn", "tempfile", @@ -1121,12 +1133,12 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.5" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9554e3ab233f0a932403704f1a1d08c30d5ccd931adfdfa1e8b5a19b52c1d55a" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools", + "itertools 0.12.1", "proc-macro2", "quote", "syn", @@ -1139,7 +1151,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acf0c195eebb4af52c752bec4f52f645da98b6e92077a04110c7f349477ae5ac" dependencies = [ "anyhow", - "itertools", + "itertools 0.13.0", "proc-macro2", "quote", "syn", @@ -1147,11 +1159,11 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ - "prost 0.12.4", + "prost 0.12.6", ] [[package]] @@ -1165,9 +1177,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -1204,14 +1216,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.6", - "regex-syntax 0.8.3", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", ] [[package]] @@ -1225,13 +1237,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.3", + "regex-syntax 0.8.4", ] [[package]] @@ -1242,9 +1254,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "ring" @@ -1278,9 +1290,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags", "errno", @@ -1291,9 +1303,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.7" +version = "0.23.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebbbdb961df0ad3f2652da8f3fdc4b36122f568f968f45ad3316f26c025c677b" +checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" dependencies = [ "log", "once_cell", @@ -1306,9 +1318,9 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" dependencies = [ "base64", "rustls-pki-types", @@ -1316,15 +1328,15 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" [[package]] name = "rustls-webpki" -version = "0.102.3" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3bce581c0dd41bce533ce695a1437fa16a7ab5ac3ccfa99fe1a620a7885eabf" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "ring", "rustls-pki-types", @@ -1345,18 +1357,18 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "serde" -version = "1.0.202" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.202" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -1365,11 +1377,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -1383,6 +1396,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "slab" version = "0.4.9" @@ -1466,15 +1485,15 @@ dependencies = [ [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.63" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -1506,30 +1525,31 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.1" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", @@ -1581,26 +1601,25 @@ dependencies = [ [[package]] name = "tokio" -version = "1.37.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", @@ -1620,9 +1639,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -1631,9 +1650,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -1733,15 +1752,15 @@ dependencies = [ [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -1825,15 +1844,15 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "untrusted" @@ -1843,9 +1862,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "valuable" @@ -1890,144 +1909,87 @@ 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 0.48.5", -] - [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets", ] [[package]] -name = "windows-targets" -version = "0.48.5" +name = "windows-sys" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "x509-parser" @@ -2046,8 +2008,29 @@ dependencies = [ "time", ] +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" From ce34b0220d9769447ef3923d7db91e184d12bd83 Mon Sep 17 00:00:00 2001 From: "Alexander V. Nikolaev" Date: Mon, 2 Sep 2024 12:54:25 +0300 Subject: [PATCH 4/7] Add ability to listen on UNIX socket Signed-off-by: Alexander V. Nikolaev --- Cargo.lock | 66 ++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 2 ++ src/bin/givc-admin.rs | 18 +++++++++++- src/utils/auth.rs | 4 +-- 4 files changed, 85 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3157a84..57ab57f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -245,6 +245,12 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.6.0" @@ -392,6 +398,15 @@ dependencies = [ "syn", ] +[[package]] +name = "document-features" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb6969eaabd2421f8a2775cfd2471a2b634372b4a25d41e3bd647b79912850a0" +dependencies = [ + "litrs", +] + [[package]] name = "either" version = "1.13.0" @@ -474,6 +489,17 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "futures-sink" version = "0.3.30" @@ -493,9 +519,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", + "futures-macro", "futures-task", "pin-project-lite", "pin-utils", + "slab", ] [[package]] @@ -533,6 +561,7 @@ dependencies = [ "serde_json", "strum 0.25.0", "tokio", + "tokio-listener", "tokio-stream", "tonic", "tonic-reflection", @@ -843,6 +872,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litrs" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" + [[package]] name = "log" version = "0.4.22" @@ -909,6 +944,17 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", +] + [[package]] name = "nom" version = "7.1.3" @@ -1294,7 +1340,7 @@ version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ - "bitflags", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -1615,6 +1661,24 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "tokio-listener" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914a439d123292125bc806649c396d23e1aac5da4052f0d97b23137b38782f46" +dependencies = [ + "document-features", + "futures-core", + "futures-util", + "nix", + "pin-project", + "socket2", + "tokio", + "tokio-util", + "tonic", + "tracing", +] + [[package]] name = "tokio-macros" version = "2.4.0" diff --git a/Cargo.toml b/Cargo.toml index 1bf388f..b2cffa8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,8 @@ serde = { version = "1.0.202", features = ["derive"]} serde_json = "1.0.120" x509-parser = { version = "0.16" } +tokio-listener = {version = "0.4.3", features = ["multi-listener", "tonic012"]} + # GIVC subparts givc-common = { path="common" } givc-client = { path="client" } diff --git a/src/bin/givc-admin.rs b/src/bin/givc-admin.rs index fb19945..0b58bb3 100644 --- a/src/bin/givc-admin.rs +++ b/src/bin/givc-admin.rs @@ -16,6 +16,9 @@ struct Cli { #[arg(long, env = "PORT", default_missing_value = "9000", value_parser = clap::value_parser!(u16).range(1..))] port: u16, + #[arg(long, help = "Additionally listen UNIX socket")] + unix: Option, + #[arg(long, env = "TLS", default_missing_value = "false")] use_tls: bool, @@ -70,10 +73,23 @@ async fn main() -> std::result::Result<(), Box> { let admin_service_svc = admin::server::AdminServiceServer::new(admin::server::AdminService::new(tls)); + let sys_opts = tokio_listener::SystemOptions::default(); + let user_opts = tokio_listener::UserOptions::default(); + let tcp_addr = tokio_listener::ListenerAddress::Tcp(addr); + + let mut addrs = vec![tcp_addr]; + + if let Some(unix_sock) = cli.unix { + let unix_sock_addr = tokio_listener::ListenerAddress::Path(unix_sock.into()); + addrs.push(unix_sock_addr) + } + + let listener = tokio_listener::Listener::bind_multiple(&addrs, &sys_opts, &user_opts).await?; + builder .add_service(reflect) .add_service(admin_service_svc) - .serve(addr) + .serve_with_incoming(listener) .await?; Ok(()) diff --git a/src/utils/auth.rs b/src/utils/auth.rs index f4439ec..4472352 100644 --- a/src/utils/auth.rs +++ b/src/utils/auth.rs @@ -5,9 +5,7 @@ fn security_info_from_request(req: &Request<()>) -> Result if let Some(certs) = req.peer_certs() { certs .iter() - .find_map(|cert| { - SecurityInfo::try_from(cert.as_ref()).ok() - }) + .find_map(|cert| SecurityInfo::try_from(cert.as_ref()).ok()) .ok_or(Status::unauthenticated("Can't determinate certificace")) } else { Err(Status::unauthenticated("No valid certificate")) From b5ab6d8c1b1a394854eb6a74e8aecef4df3af0d8 Mon Sep 17 00:00:00 2001 From: "Alexander V. Nikolaev" Date: Thu, 5 Sep 2024 16:26:30 +0300 Subject: [PATCH 5/7] Implement connection for both unix and tcp sockets Signed-off-by: Alexander V. Nikolaev --- Cargo.lock | 2 ++ client/Cargo.toml | 2 ++ client/src/client.rs | 20 ++++++++++++----- client/src/endpoint.rs | 50 +++++++++++++++++++++++++++++++++++------- common/src/address.rs | 19 ++++++++++++++++ common/src/lib.rs | 1 + common/src/types.rs | 49 +++++++++++++++++++++++++++++++---------- src/admin/entry.rs | 8 ++++--- src/bin/givc-agent.rs | 8 ++++--- 9 files changed, 128 insertions(+), 31 deletions(-) create mode 100644 common/src/address.rs diff --git a/Cargo.lock b/Cargo.lock index 57ab57f..5e286ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -583,11 +583,13 @@ dependencies = [ "givc-common", "http 0.2.12", "http-body 0.4.6", + "hyper-util", "serde", "tokio", "tokio-stream", "tonic", "tonic-types", + "tower", "tracing", ] diff --git a/client/Cargo.toml b/client/Cargo.toml index 1482e19..b36cdc9 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -12,10 +12,12 @@ async-channel = "2.3.1" async-stream = "0.3" http = "0.2" http-body = "0.4.2" +hyper-util = { version = "0.1.4"} tokio = {version = "1.0", features = ["rt-multi-thread", "time", "macros"]} tokio-stream = "0.1" tonic = {version="0.12.2", features = ["tls"]} tonic-types = {version="0.12.2"} +tower = {version = "0.4"} tracing = "0.1" serde = { version = "1.0.202", features = ["derive"]} diff --git a/client/src/client.rs b/client/src/client.rs index 3a773ee..fe63205 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -1,13 +1,16 @@ -use crate::endpoint::{EndpointConfig, TlsConfig}; use anyhow::bail; use async_channel::Receiver; -use givc_common::pb; -pub use givc_common::query::{Event, QueryResult}; -use givc_common::types::*; use tokio_stream::StreamExt; use tonic::transport::Channel; use tracing::debug; +use givc_common::address::EndpointAddress; +use givc_common::pb; +pub use givc_common::query::{Event, QueryResult}; +use givc_common::types::*; + +use crate::endpoint::{EndpointConfig, TlsConfig}; + type Client = pb::admin_service_client::AdminServiceClient; #[derive(Debug)] @@ -40,6 +43,13 @@ impl AdminClient { // New style api, not yet implemented, stub atm to make current code happy // FIXME: Still doubt if constructor should be sync or async pub fn new(addr: String, port: u16, tls_info: Option<(String, TlsConfig)>) -> Self { + Self::from_endpoint_address(EndpointAddress::Tcp { addr, port }, tls_info) + } + + pub fn from_endpoint_address( + addr: EndpointAddress, + tls_info: Option<(String, TlsConfig)>, + ) -> Self { let (name, tls) = match tls_info { Some((name, tls)) => (name, Some(tls)), None => (String::from("bogus(no tls)"), None), @@ -48,8 +58,6 @@ impl AdminClient { endpoint: EndpointConfig { transport: TransportConfig { address: addr, - port: port, - protocol: String::from("bogus"), tls_name: name, }, tls: tls, diff --git a/client/src/endpoint.rs b/client/src/endpoint.rs index e22c9c3..210d36d 100644 --- a/client/src/endpoint.rs +++ b/client/src/endpoint.rs @@ -1,11 +1,17 @@ -use anyhow::anyhow; -use givc_common::types::TransportConfig; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::time::Duration; -use tonic::transport::Endpoint; + +use anyhow::anyhow; +use hyper_util::rt::TokioIo; +use tokio::net::UnixStream; use tonic::transport::{Certificate, Channel, ClientTlsConfig, Identity, ServerTlsConfig}; +use tonic::transport::{Endpoint, Uri}; +use tower::service_fn; use tracing::info; +use givc_common::address::EndpointAddress; +use givc_common::types::TransportConfig; + #[derive(Debug, Clone)] pub struct TlsConfig { pub ca_cert_file_path: PathBuf, @@ -50,17 +56,41 @@ impl TlsConfig { } } -fn transport_config_to_url(tc: &TransportConfig, with_tls: bool) -> String { +fn transport_config_to_url(ea: &EndpointAddress, with_tls: bool) -> String { let scheme = match with_tls { true => "https", false => "http", }; - format!("{}://{}:{}", scheme, tc.address, tc.port) + match ea { + EndpointAddress::Tcp { addr, port } => format!("{}://{}:{}", scheme, addr, port), + _ => format!("{}://[::]:443", scheme), // Bogus url, to make tonic connector happy + } +} + +async fn connect_unix_socket(endpoint: Endpoint, path: &String) -> anyhow::Result { + let mut path = Some(path.to_owned()); + let ch = endpoint + .connect_with_connector(service_fn(move |_: Uri| { + let path = path.take(); + async move { + if let Some(path) = path { + // Connect to a Uds socket + Ok::<_, std::io::Error>(TokioIo::new(UnixStream::connect(path).await?)) + } else { + Err(std::io::Error::new( + std::io::ErrorKind::Other, + "Path already taken", + )) + } + } + })) + .await?; + Ok(ch) } impl EndpointConfig { pub async fn connect(&self) -> anyhow::Result { - let url = transport_config_to_url(&self.transport, self.tls.is_some()); + let url = transport_config_to_url(&self.transport.address, self.tls.is_some()); info!("Connecting to {url}, TLS name {:?}", &self.tls); let mut endpoint = Endpoint::try_from(url)? .timeout(Duration::from_secs(5)) @@ -68,7 +98,11 @@ impl EndpointConfig { if let Some(tls) = &self.tls { endpoint = endpoint.tls_config(tls.client_config()?)?; }; - let channel = endpoint.connect().await?; + let channel = match &self.transport.address { + EndpointAddress::Tcp { .. } => endpoint.connect().await?, + EndpointAddress::Unix(unix) => connect_unix_socket(endpoint, unix).await?, + EndpointAddress::Abstract(abs) => connect_unix_socket(endpoint, abs).await?, + }; Ok(channel) } } diff --git a/common/src/address.rs b/common/src/address.rs new file mode 100644 index 0000000..2a46825 --- /dev/null +++ b/common/src/address.rs @@ -0,0 +1,19 @@ +use std::convert::{Into, TryFrom}; +//use std::net::SocketAddr; +use std::path::PathBuf; + +// use tokio_vsock::VsockAddr; + +use crate::pb; + +#[derive(Clone, Debug, PartialEq)] +pub enum EndpointAddress { + Tcp { + // IP + port (FIXME: should be SocketAddres) + addr: String, + port: u16, + }, + Unix(String), // "/path/to/sock" (same host only) + Abstract(String), // "@abstract-socket-name" (same host only) + // VSock(VsockAddr), // cid+port. FIXME: cid have two magic numbers for host and local +} diff --git a/common/src/lib.rs b/common/src/lib.rs index d66f3a1..9209e20 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -1,3 +1,4 @@ +pub mod address; pub mod query; pub mod types; diff --git a/common/src/types.rs b/common/src/types.rs index 84ccdae..83a81fd 100644 --- a/common/src/types.rs +++ b/common/src/types.rs @@ -1,5 +1,6 @@ // This module contain literal translations of types from internal/pkgs/types/types.go // Some of them would be rewritten, replaced, or even removed +use super::address::EndpointAddress; use crate::pb; use anyhow::{anyhow, bail}; use std::convert::{Into, TryFrom}; @@ -186,9 +187,7 @@ impl Into for UnitStatus { #[derive(Debug, Clone, PartialEq)] pub struct EndpointEntry { - pub protocol: String, // Bogus, should we drop it? - pub address: String, - pub port: u16, + pub address: EndpointAddress, pub tls_name: String, } @@ -197,10 +196,18 @@ pub type TransportConfig = EndpointEntry; impl TryFrom for EndpointEntry { type Error = anyhow::Error; fn try_from(tc: pb::TransportConfig) -> Result { + let endpoint = match tc.protocol.as_str() { + "tcp" => EndpointAddress::Tcp { + addr: tc.address, + port: tc.port.parse()?, + }, + "unix" => EndpointAddress::Unix(tc.address), + "abstract" => EndpointAddress::Abstract(tc.address), + // "vsock" => unimplemented!(), + unknown => bail!("Unknown protocol: {unknown}"), + }; Ok(Self { - protocol: tc.protocol, - address: tc.address, - port: tc.port.parse()?, + address: endpoint, tls_name: tc.name, }) } @@ -208,11 +215,31 @@ impl TryFrom for EndpointEntry { impl Into for EndpointEntry { fn into(self) -> pb::TransportConfig { - pb::TransportConfig { - protocol: self.protocol, - address: self.address, - port: self.port.to_string(), - name: self.tls_name, + match self.address { + EndpointAddress::Tcp { addr, port } => pb::TransportConfig { + protocol: "tcp".into(), + address: addr, + port: port.to_string(), + name: self.tls_name, + }, + EndpointAddress::Unix(unix) => pb::TransportConfig { + protocol: "unix".into(), + address: unix, + port: "".into(), + name: self.tls_name, + }, + EndpointAddress::Abstract(abstr) => pb::TransportConfig { + protocol: "abstract".into(), + address: abstr, + port: "".into(), + name: self.tls_name, + }, + // EndpointAddress::Vsock(vs) => pb::TransportConfig { + // protocol: "vsock".into(), + // address: vs.cid().to_string(), + // port: vs.port().to_string(), + // name: self.tls_name, + // } } } } diff --git a/src/admin/entry.rs b/src/admin/entry.rs index e8dcb70..1f4cec8 100644 --- a/src/admin/entry.rs +++ b/src/admin/entry.rs @@ -41,6 +41,7 @@ impl RegistryEntry { #[cfg(test)] impl RegistryEntry { pub fn dummy(n: String) -> Self { + use givc_common::address::EndpointAddress; Self { name: n, r#type: UnitType { @@ -56,9 +57,10 @@ impl RegistryEntry { path: "bogus".to_string(), }, placement: Placement::Endpoint(EndpointEntry { - protocol: "bogus".to_string(), - address: "127.0.0.1".to_string(), - port: 42, + address: EndpointAddress::Tcp { + addr: "127.0.0.1".to_string(), + port: 42, + }, tls_name: "bogus".to_string(), }), watch: true, diff --git a/src/bin/givc-agent.rs b/src/bin/givc-agent.rs index 1b565f7..36a4cdc 100644 --- a/src/bin/givc-agent.rs +++ b/src/bin/givc-agent.rs @@ -4,6 +4,7 @@ use givc::systemd_api::server::SystemdService; use givc::types::*; use givc::utils::naming::*; use givc_client::AdminClient; +use givc_common::address::EndpointAddress; use givc_common::pb; use givc_common::pb::reflection::SYSTEMD_DESCRIPTOR; use std::net::SocketAddr; @@ -88,9 +89,10 @@ async fn main() -> std::result::Result<(), Box> { // Perfect example of bad designed code, admin.register_service(entry) should hide structure filling let endpoint = EndpointEntry { - address: cli.addr, - port: cli.port, - protocol: String::from("bogus"), + address: EndpointAddress::Tcp { + addr: cli.addr, + port: cli.port, + }, tls_name: cli.name, }; // We can't use just one name field like in "go" code From 36c8eb920b3f9f2f363373af7f8f1fb4336342d6 Mon Sep 17 00:00:00 2001 From: "Alexander V. Nikolaev" Date: Wed, 18 Sep 2024 16:01:32 +0300 Subject: [PATCH 6/7] Implement Vsock connection Signed-off-by: Alexander V. Nikolaev --- Cargo.lock | 87 ++++++++++++++++++++++++++++++++++++++++-- Cargo.toml | 3 +- client/Cargo.toml | 1 + client/src/endpoint.rs | 13 +++++++ common/Cargo.toml | 1 + common/src/address.rs | 6 +-- common/src/types.rs | 20 ++++++---- 7 files changed, 116 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e286ba..2960b30 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,6 +474,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.30" @@ -481,6 +496,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -489,6 +505,23 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + [[package]] name = "futures-macro" version = "0.3.30" @@ -518,9 +551,13 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ + "futures-channel", "futures-core", + "futures-io", "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", "slab", @@ -907,6 +944,15 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + [[package]] name = "mime" version = "0.3.17" @@ -957,6 +1003,18 @@ dependencies = [ "libc", ] +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "libc", + "memoffset", +] + [[package]] name = "nom" version = "7.1.3" @@ -1666,17 +1724,17 @@ dependencies = [ [[package]] name = "tokio-listener" version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914a439d123292125bc806649c396d23e1aac5da4052f0d97b23137b38782f46" +source = "git+https://github.com/avnik/tokio-listener?branch=avnik/vsock-ghaf#569b673d84e4cfc177616ffc3ff07cb0c9da6429" dependencies = [ "document-features", "futures-core", "futures-util", - "nix", + "nix 0.26.4", "pin-project", "socket2", "tokio", "tokio-util", + "tokio-vsock", "tonic", "tracing", ] @@ -1727,6 +1785,19 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-vsock" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e336ac4b36df625d5429a735dd5847732fe5f62010e3ce0c50f3705d44730f8" +dependencies = [ + "bytes", + "futures", + "libc", + "tokio", + "vsock", +] + [[package]] name = "tonic" version = "0.12.2" @@ -1938,6 +2009,16 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vsock" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfb6e7a74830912f1f4a7655227c9ded1ea4e9136676311fedf54bedb412f35" +dependencies = [ + "libc", + "nix 0.27.1", +] + [[package]] name = "want" version = "0.3.1" diff --git a/Cargo.toml b/Cargo.toml index b2cffa8..a52bac8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ http-body = "0.4.2" hyper = "0.14" tokio = {version = "1.0", features = ["rt-multi-thread", "time", "macros"]} tokio-stream = "0.1" +tokio-vsock = "0.5" tonic = {version="0.12.2", features = ["tls"]} tonic-types = {version="0.12.2"} tonic-reflection = {version="0.12.2"} @@ -36,7 +37,7 @@ serde = { version = "1.0.202", features = ["derive"]} serde_json = "1.0.120" x509-parser = { version = "0.16" } -tokio-listener = {version = "0.4.3", features = ["multi-listener", "tonic012"]} +tokio-listener = { features = ["multi-listener", "tonic012", "vsock"], git = "https://github.com/avnik/tokio-listener", branch = "avnik/vsock-ghaf" } # GIVC subparts givc-common = { path="common" } diff --git a/client/Cargo.toml b/client/Cargo.toml index b36cdc9..2e3a520 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -15,6 +15,7 @@ http-body = "0.4.2" hyper-util = { version = "0.1.4"} tokio = {version = "1.0", features = ["rt-multi-thread", "time", "macros"]} tokio-stream = "0.1" +tokio-vsock = "*" tonic = {version="0.12.2", features = ["tls"]} tonic-types = {version="0.12.2"} tower = {version = "0.4"} diff --git a/client/src/endpoint.rs b/client/src/endpoint.rs index 210d36d..95c63ff 100644 --- a/client/src/endpoint.rs +++ b/client/src/endpoint.rs @@ -4,6 +4,7 @@ use std::time::Duration; use anyhow::anyhow; use hyper_util::rt::TokioIo; use tokio::net::UnixStream; +use tokio_vsock::{VsockAddr, VsockStream}; use tonic::transport::{Certificate, Channel, ClientTlsConfig, Identity, ServerTlsConfig}; use tonic::transport::{Endpoint, Uri}; use tower::service_fn; @@ -88,6 +89,17 @@ async fn connect_unix_socket(endpoint: Endpoint, path: &String) -> anyhow::Resul Ok(ch) } +async fn connect_vsock_socket(endpoint: Endpoint, vs: &VsockAddr) -> anyhow::Result { + let vs = vs.to_owned(); + let ch = endpoint + .connect_with_connector(service_fn(move |_: Uri| async move { + let stream = VsockStream::connect(vs).await?; + Ok::<_, std::io::Error>(TokioIo::new(stream)) + })) + .await?; + Ok(ch) +} + impl EndpointConfig { pub async fn connect(&self) -> anyhow::Result { let url = transport_config_to_url(&self.transport.address, self.tls.is_some()); @@ -102,6 +114,7 @@ impl EndpointConfig { EndpointAddress::Tcp { .. } => endpoint.connect().await?, EndpointAddress::Unix(unix) => connect_unix_socket(endpoint, unix).await?, EndpointAddress::Abstract(abs) => connect_unix_socket(endpoint, abs).await?, + EndpointAddress::Vsock(vs) => connect_vsock_socket(endpoint, vs).await?, }; Ok(channel) } diff --git a/common/Cargo.toml b/common/Cargo.toml index bf6f4f5..5c176c3 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -14,6 +14,7 @@ http-body = "0.4.2" prost = "0.13" tokio = {version = "1.0", features = ["rt-multi-thread", "time", "macros"]} tokio-stream = "0.1" +tokio-vsock = "*" tonic = {version="0.12.2", features = ["tls"]} tonic-types = {version="0.12.2"} tracing = "0.1" diff --git a/common/src/address.rs b/common/src/address.rs index 2a46825..f7189c7 100644 --- a/common/src/address.rs +++ b/common/src/address.rs @@ -2,7 +2,7 @@ use std::convert::{Into, TryFrom}; //use std::net::SocketAddr; use std::path::PathBuf; -// use tokio_vsock::VsockAddr; +use tokio_vsock::VsockAddr; use crate::pb; @@ -13,7 +13,7 @@ pub enum EndpointAddress { addr: String, port: u16, }, - Unix(String), // "/path/to/sock" (same host only) + Unix(String), // "/path/to/sock" (same host only) Abstract(String), // "@abstract-socket-name" (same host only) - // VSock(VsockAddr), // cid+port. FIXME: cid have two magic numbers for host and local + Vsock(VsockAddr), // cid+port. FIXME: cid have two magic numbers for host and local } diff --git a/common/src/types.rs b/common/src/types.rs index 83a81fd..fc8afec 100644 --- a/common/src/types.rs +++ b/common/src/types.rs @@ -2,9 +2,11 @@ // Some of them would be rewritten, replaced, or even removed use super::address::EndpointAddress; use crate::pb; -use anyhow::{anyhow, bail}; use std::convert::{Into, TryFrom}; +use anyhow::{anyhow, bail}; +use tokio_vsock::VsockAddr; + #[derive(Debug, Copy, Clone, PartialEq)] pub struct UnitType { pub vm: VmType, @@ -203,7 +205,9 @@ impl TryFrom for EndpointEntry { }, "unix" => EndpointAddress::Unix(tc.address), "abstract" => EndpointAddress::Abstract(tc.address), - // "vsock" => unimplemented!(), + "vsock" => { + EndpointAddress::Vsock(VsockAddr::new(tc.address.parse()?, tc.port.parse()?)) + } unknown => bail!("Unknown protocol: {unknown}"), }; Ok(Self { @@ -234,12 +238,12 @@ impl Into for EndpointEntry { port: "".into(), name: self.tls_name, }, - // EndpointAddress::Vsock(vs) => pb::TransportConfig { - // protocol: "vsock".into(), - // address: vs.cid().to_string(), - // port: vs.port().to_string(), - // name: self.tls_name, - // } + EndpointAddress::Vsock(vs) => pb::TransportConfig { + protocol: "vsock".into(), + address: vs.cid().to_string(), + port: vs.port().to_string(), + name: self.tls_name, + }, } } } From d760e69c5edc2e28d3d89417e36b8698a25c948b Mon Sep 17 00:00:00 2001 From: "Alexander V. Nikolaev" Date: Tue, 10 Sep 2024 14:17:49 +0300 Subject: [PATCH 7/7] Add option to test vsock Signed-off-by: Alexander V. Nikolaev --- Cargo.lock | 3 +++ src/bin/givc-admin.rs | 11 ++++++++++- src/bin/givc-cli.rs | 14 +++++++++++++- src/utils/mod.rs | 1 + src/utils/vsock.rs | 14 ++++++++++++++ 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 src/utils/vsock.rs diff --git a/Cargo.lock b/Cargo.lock index 2960b30..f6d1959 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -600,6 +600,7 @@ dependencies = [ "tokio", "tokio-listener", "tokio-stream", + "tokio-vsock", "tonic", "tonic-reflection", "tonic-types", @@ -624,6 +625,7 @@ dependencies = [ "serde", "tokio", "tokio-stream", + "tokio-vsock", "tonic", "tonic-types", "tower", @@ -643,6 +645,7 @@ dependencies = [ "strum 0.26.3", "tokio", "tokio-stream", + "tokio-vsock", "tonic", "tonic-build", "tonic-types", diff --git a/src/bin/givc-admin.rs b/src/bin/givc-admin.rs index 0b58bb3..3731671 100644 --- a/src/bin/givc-admin.rs +++ b/src/bin/givc-admin.rs @@ -1,6 +1,7 @@ use clap::Parser; use givc::admin; use givc::endpoint::TlsConfig; +use givc::utils::vsock::parse_vsock_addr; use givc_common::pb::reflection::ADMIN_DESCRIPTOR; use std::net::SocketAddr; use std::path::PathBuf; @@ -16,9 +17,12 @@ struct Cli { #[arg(long, env = "PORT", default_missing_value = "9000", value_parser = clap::value_parser!(u16).range(1..))] port: u16, - #[arg(long, help = "Additionally listen UNIX socket")] + #[arg(long, help = "Additionally listen UNIX socket (path)")] unix: Option, + #[arg(long, help = "Additionally listen Vsock socket (cid:port format)")] + vsock: Option, + #[arg(long, env = "TLS", default_missing_value = "false")] use_tls: bool, @@ -84,6 +88,11 @@ async fn main() -> std::result::Result<(), Box> { addrs.push(unix_sock_addr) } + if let Some(vsock) = cli.vsock { + let vsock_addr = parse_vsock_addr(&vsock)?.into(); + addrs.push(vsock_addr) + } + let listener = tokio_listener::Listener::bind_multiple(&addrs, &sys_opts, &user_opts).await?; builder diff --git a/src/bin/givc-cli.rs b/src/bin/givc-cli.rs index 2892e67..93a847f 100644 --- a/src/bin/givc-cli.rs +++ b/src/bin/givc-cli.rs @@ -1,7 +1,9 @@ use clap::{Parser, Subcommand}; use givc::endpoint::TlsConfig; use givc::types::*; +use givc::utils::vsock::parse_vsock_addr; use givc_client::AdminClient; +use givc_common::address::EndpointAddress; use serde::ser::Serialize; use std::path::PathBuf; use std::time; @@ -23,6 +25,9 @@ struct Cli { #[arg(long, env = "NAME", default_missing_value = "admin.ghaf")] name: String, // for TLS service name + #[arg(long)] + vsock: Option, + #[arg(long, env = "CA_CERT")] cacert: Option, @@ -130,7 +135,14 @@ async fn main() -> std::result::Result<(), Box> { }, )) }; - let admin = AdminClient::new(cli.addr, cli.port, tls); + + // FIXME; big kludge, but allow to test vsock connection + let admin = if let Some(vsock) = cli.vsock { + info!("Connection diverted to VSock"); + AdminClient::from_endpoint_address(EndpointAddress::Vsock(parse_vsock_addr(&vsock)?), tls) + } else { + AdminClient::new(cli.addr, cli.port, tls) + }; match cli.command { Commands::Test { test } => test_subcommands(test, admin).await?, diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 02918bc..26e9481 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,4 +1,5 @@ pub mod auth; pub mod naming; pub mod tonic; +pub mod vsock; pub mod x509; diff --git a/src/utils/vsock.rs b/src/utils/vsock.rs new file mode 100644 index 0000000..c949072 --- /dev/null +++ b/src/utils/vsock.rs @@ -0,0 +1,14 @@ +use anyhow::bail; +use tokio_vsock::{VsockAddr, VMADDR_CID_HOST, VMADDR_CID_LOCAL}; + +pub fn parse_vsock_addr(addr: &str) -> anyhow::Result { + if let Some((cid, port)) = addr.split_once(":") { + let cid = match cid { + "local" => VMADDR_CID_LOCAL, + "host" => VMADDR_CID_HOST, + cid => cid.parse()?, + }; + return Ok(VsockAddr::new(cid, port.parse()?)); + }; + bail!("Address {addr} should be in CID:PORT format") +}