Skip to content

Commit

Permalink
Refresh routes when connecting in offline states
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Oct 9, 2023
1 parent b19618a commit 9001f98
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions talpid-core/src/tunnel_state_machine/connecting_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,12 @@ impl TunnelState for ConnectingState {
retry_attempt: u32,
) -> (TunnelStateWrapper, TunnelStateTransition) {
if shared_values.is_offline {
// FIXME: Temporary: Nudge route manager to update the default interface
#[cfg(target_os = "macos")]
if let Ok(handle) = shared_values.route_manager.handle() {
log::debug!("Poking route manager to update default routes");
let _ = handle.refresh_routes();
}
return ErrorState::enter(shared_values, ErrorStateCause::IsOffline);
}
match shared_values.runtime.block_on(
Expand Down
8 changes: 8 additions & 0 deletions talpid-routing/src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ impl RouteManagerHandle {
response_rx.await.map_err(|_| Error::ManagerChannelDown)
}

/// Get current non-tunnel default routes.
#[cfg(target_os = "macos")]
pub fn refresh_routes(&self) -> Result<(), Error> {
self.tx
.unbounded_send(RouteManagerCommand::RefreshRoutes)
.map_err(|_| Error::RouteManagerDown)
}

/// Ensure that packets are routed using the correct tables.
#[cfg(target_os = "linux")]
pub async fn create_routing_rules(&self, enable_ipv6: bool) -> Result<(), Error> {
Expand Down

0 comments on commit 9001f98

Please sign in to comment.