From cc027d2cc196015bc97cd08639b0c18793f5874d Mon Sep 17 00:00:00 2001 From: ghe0 Date: Thu, 6 Mar 2025 01:30:51 +0200 Subject: [PATCH] pass message from daemon to CLI --- src/data.rs | 10 +++++----- src/grpc.rs | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/data.rs b/src/data.rs index 13e02e0..17add83 100644 --- a/src/data.rs +++ b/src/data.rs @@ -661,6 +661,11 @@ impl BrainData { return; } }; + if let Err(e) = update_vm_req.1.send(update_vm_resp.clone()) { + log::warn!( + "CLI RX dropped before receiving UpdateVMResp {update_vm_resp:?}. Error: {e:?}" + ); + } if update_vm_resp.error != "" { return; } @@ -697,11 +702,6 @@ impl BrainData { update_vm_resp.error = "VM Contract not found.".to_string(); } } - if let Err(e) = update_vm_req.1.send(update_vm_resp.clone()) { - log::warn!( - "CLI RX dropped before receiving UpdateVMResp {update_vm_resp:?}. Error: {e:?}" - ); - } } pub async fn submit_newvm_req( diff --git a/src/grpc.rs b/src/grpc.rs index f3a6327..370d075 100644 --- a/src/grpc.rs +++ b/src/grpc.rs @@ -475,9 +475,9 @@ fn check_sig_from_req(req: Request) -> Res let parsed_time = chrono::DateTime::parse_from_rfc3339(time) .map_err(|_| Status::unauthenticated("Coult not parse timestamp"))?; let seconds_elapsed = now.signed_duration_since(parsed_time).num_seconds(); - if seconds_elapsed > 1 || seconds_elapsed < -1 { + if seconds_elapsed > 4 || seconds_elapsed < -4 { return Err(Status::unauthenticated(format!( - "Date is not within 1 sec of the time of the server: CLI {} vs Server {}", + "Date is not within 4 sec of the time of the server: CLI {} vs Server {}", parsed_time, now ))); } @@ -530,9 +530,9 @@ fn check_sig_from_parts(pubkey: &str, time: &str, msg: &str, sig: &str) -> Resul let parsed_time = chrono::DateTime::parse_from_rfc3339(time) .map_err(|_| Status::unauthenticated("Coult not parse timestamp"))?; let seconds_elapsed = now.signed_duration_since(parsed_time).num_seconds(); - if seconds_elapsed > 1 || seconds_elapsed < -1 { + if seconds_elapsed > 4 || seconds_elapsed < -4 { return Err(Status::unauthenticated(format!( - "Date is not within 1 sec of the time of the server: CLI {} vs Server {}", + "Date is not within 4 sec of the time of the server: CLI {} vs Server {}", parsed_time, now ))); }