Skip to content

Commit

Permalink
Add a backoff for failed auth
Browse files Browse the repository at this point in the history
Change-type: patch
  • Loading branch information
Page- committed Apr 21, 2023
1 parent 9bc0816 commit 476bca4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions auth/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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();
}
Expand Down

0 comments on commit 476bca4

Please sign in to comment.