Skip to content

Commit

Permalink
Run exit manager ping test only when registered to an exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranay Tulugu authored and jkilpatr committed Sep 19, 2023
1 parent db534d9 commit 8d013ba
Showing 1 changed file with 14 additions and 8 deletions.
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

0 comments on commit 8d013ba

Please sign in to comment.