From cc0d2fb3f0d297ffefa715d7b6f954392709c9fd Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 6 Jun 2023 11:45:23 +0200 Subject: [PATCH] Accept commands 30s in the future --- src/lib.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 08ebfa3..5c82fd4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,17 +43,14 @@ impl ProxyCommand { let now = time::SystemTime::now() .duration_since(time::UNIX_EPOCH) .unwrap(); - if now > timestamp { - // timestamp is older - if now - timestamp <= time::Duration::from_secs(60) { - // less than a minute old - true - } else { - tracing::warn!("command is more than a minute old"); - false - } + if timestamp > (now + time::Duration::from_secs(30)) { + tracing::warn!("command is more than 30s from the future"); + false + } else if now - timestamp <= time::Duration::from_secs(60) { + // less than a minute old + true } else { - tracing::warn!("command is from the future"); + tracing::warn!("command is more than a minute old"); false } }