summaryrefslogtreecommitdiffhomepage
path: root/talpid-core/src
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2024-01-15 14:20:01 +0100
committerDavid Lönnhager <david.l@mullvad.net>2024-01-15 16:56:35 +0100
commit6f2bddd8ceb6204906c43c847c7e0380b462d4ec (patch)
tree449feb17b7166bb4591e1ceeb95738bc80936b2f /talpid-core/src
parentfbdcaa4f1ab82d1ba6b49fe8fc362b72efe9061e (diff)
downloadmullvadvpn-6f2bddd8ceb6204906c43c847c7e0380b462d4ec.tar.xz
mullvadvpn-6f2bddd8ceb6204906c43c847c7e0380b462d4ec.zip
Reconnect if default route disappears while connecting on macOS
Diffstat (limited to 'talpid-core/src')
-rw-r--r--talpid-core/src/tunnel_state_machine/connecting_state.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/talpid-core/src/tunnel_state_machine/connecting_state.rs b/talpid-core/src/tunnel_state_machine/connecting_state.rs
index e49e5b69d8..75f3d8eebf 100644
--- a/talpid-core/src/tunnel_state_machine/connecting_state.rs
+++ b/talpid-core/src/tunnel_state_machine/connecting_state.rs
@@ -599,7 +599,7 @@ fn should_retry(error: &tunnel::Error, retry_attempt: u32) -> bool {
TunnelError::BypassError(_),
)) => true,
- #[cfg(windows)]
+ #[cfg(any(target_os = "windows", target_os = "macos"))]
tunnel::Error::WireguardTunnelMonitoringError(Error::SetupRoutingError(error)) => {
is_recoverable_routing_error(error)
}
@@ -624,6 +624,18 @@ fn is_recoverable_routing_error(error: &talpid_routing::Error) -> bool {
matches!(error, talpid_routing::Error::AddRoutesFailed(_))
}
+#[cfg(target_os = "macos")]
+fn is_recoverable_routing_error(error: &talpid_routing::Error) -> bool {
+ // If the default route disappears while connecting but before it is caught by the offline
+ // monitor, then the gateway will be unreachable. In this case, just retry.
+ matches!(
+ error,
+ talpid_routing::Error::PlatformError(talpid_routing::PlatformError::AddRoute(
+ talpid_routing::RouteError::Unreachable,
+ ))
+ )
+}
+
impl TunnelState for ConnectingState {
fn handle_event(
mut self: Box<Self>,