Add uuid and remove useless logs
This commit is contained in:
parent
2f5a28beb9
commit
e46fe9db87
3 changed files with 31 additions and 17 deletions
23
Cargo.lock
generated
23
Cargo.lock
generated
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<AuthorizeRequest>,
|
||||
_request: Request<AuthorizeRequest>,
|
||||
) -> Result<Response<AuthorizeResponse>, Status> {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let conn_info = request.extensions().get::<UdsConnectInfo>().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<TerminateRequest>,
|
||||
_request: Request<TerminateRequest>,
|
||||
) -> Result<Response<TerminateResponse>, Status> {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let conn_info = request.extensions().get::<UdsConnectInfo>().unwrap();
|
||||
println!("Got a request {:?} with info {:?}", request, conn_info);
|
||||
}
|
||||
|
||||
let reply = TerminateResponse {
|
||||
status: TerminateStatus::Ok.into()
|
||||
};
|
||||
|
|
Reference in a new issue