diff --git a/Cargo.lock b/Cargo.lock index 53793ad..57a2945 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -128,6 +128,7 @@ dependencies = [ "tonic", "tonic-build", "tower", + "uuid", ] [[package]] @@ -938,6 +939,28 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +[[package]] +name = "uuid" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c" +dependencies = [ + "getrandom", + "rand", + "uuid-macro-internal", +] + +[[package]] +name = "uuid-macro-internal" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73bc89f2894593e665241e0052c3791999e6787b7c4831daa0a5c2e637e276d8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "want" version = "0.3.0" diff --git a/Cargo.toml b/Cargo.toml index f2567f3..de2a621 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,11 @@ path = "src/client/main.rs" [dependencies] serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" +uuid = { version = "1.2.2", features = [ + "v4", # Lets you generate random UUIDs + "fast-rng", # Use a faster (but still sufficiently random) RNG + "macro-diagnostics", # Enable better diagnostics for compile-time UUIDs +] } tokio = { version = "1.0", features = ["rt-multi-thread", "macros"] } # Required for tonic tokio-stream = { version = "0.1", features = ["net"] } # Required for tonic with unix socket tower = "0.4" # Required for tonic with unix socket diff --git a/src/daemon/server.rs b/src/daemon/server.rs index b82e54a..bdd51ae 100644 --- a/src/daemon/server.rs +++ b/src/daemon/server.rs @@ -1,7 +1,5 @@ #![cfg_attr(not(unix), allow(unused_imports))] -#[cfg(unix)] -use tonic::transport::server::UdsConnectInfo; use tonic::{Request, Response, Status}; use libcommand::internal::{ @@ -17,31 +15,19 @@ pub struct DaemonServer {} impl Unix for DaemonServer { async fn authorize( &self, - request: Request, + _request: Request, ) -> Result, Status> { - #[cfg(unix)] - { - let conn_info = request.extensions().get::().unwrap(); - println!("Got a request {:?} with info {:?}", request, conn_info); - } - let reply = AuthorizeResponse { status: AuthorizationStatus::Authorized.into(), - session_uuid: "".into() + session_uuid: uuid::Uuid::new_v4().to_string() }; Ok(Response::new(reply)) } async fn terminate( &self, - request: Request, + _request: Request, ) -> Result, Status> { - #[cfg(unix)] - { - let conn_info = request.extensions().get::().unwrap(); - println!("Got a request {:?} with info {:?}", request, conn_info); - } - let reply = TerminateResponse { status: TerminateStatus::Ok.into() };