Accept commands 30s in the future

This commit is contained in:
Erik 2023-06-06 11:45:23 +02:00
parent 0b5ab4872c
commit cc0d2fb3f0

View File

@ -43,19 +43,16 @@ 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) {
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 more than a minute old");
false
}
} else {
tracing::warn!("command is from the future");
false
}
}
(Some(_), None) => false,
(None, _) => true,