From 476bca422c4a92189f19aa9f02c45b8a95e6a209 Mon Sep 17 00:00:00 2001 From: Pagan Gazzard Date: Fri, 21 Apr 2023 13:42:51 +0100 Subject: [PATCH] Add a backoff for failed auth Change-type: patch --- auth/src/main.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/auth/src/main.rs b/auth/src/main.rs index 13fc1f2d..543b37be 100644 --- a/auth/src/main.rs +++ b/auth/src/main.rs @@ -21,6 +21,7 @@ fn main() { let username = std::env::var("username").unwrap(); let password = std::env::var("password").unwrap(); let auth_control_file = std::env::var("auth_control_file").unwrap(); + let auth_failed_reason_file = std::env::var("auth_failed_reason_file").unwrap(); let vpn_api_port = std::env::args().nth(1).unwrap(); match ureq::post(&format!("http://127.0.0.1:{}/api/v1/auth/", vpn_api_port)) @@ -34,6 +35,8 @@ fn main() { std::fs::write(auth_control_file, "1").unwrap(); } Err(_) => { + // Mark as a temp failure so that we can specify a backoff rather than have clients forever retry at their own rate + std::fs::write(auth_failed_reason_file, "TEMP[backoff 60]").unwrap(); // Writing 0 rejects login. std::fs::write(auth_control_file, "0").unwrap(); }