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

Run exit manager ping test only when registered to an exit #832

Merged
merged 1 commit into from
Sep 19, 2023
Merged
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
22 changes: 14 additions & 8 deletions rita_client/src/exit_manager/exit_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,22 @@ pub fn start_exit_manager_loop() {
}
};

// Run this ping test every PING_TEST_SPEED seconds
if Instant::now() - em_state.last_connection_time > PING_TEST_SPEED {
if run_ping_test() {
em_state.last_connection_time = Instant::now();
} else {
// If this router has been in a bad state for >10 mins, reboot
if (Instant::now() - em_state.last_connection_time) > REBOOT_TIMEOUT {
let _res = KI.run_command("reboot", &[]);
// Run ping test only when we are registered to prevent constant reboots
if let ExitState::Registered { .. } = exit.info {
// Run this ping test every PING_TEST_SPEED seconds
if Instant::now() - em_state.last_connection_time > PING_TEST_SPEED {
if run_ping_test() {
em_state.last_connection_time = Instant::now();
} else {
// If this router has been in a bad state for >10 mins, reboot
if (Instant::now() - em_state.last_connection_time) > REBOOT_TIMEOUT {
let _res = KI.run_command("reboot", &[]);
}
}
}
} else {
// reset our reboot timer every tick if not registered
em_state.last_connection_time = Instant::now();
}

// Get cluster exit list. This is saved locally and updated every tick depending on what exit we connect to.
Expand Down