Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a backoff for failed auth #329

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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