summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2023-06-05 13:24:38 +0200
committerDavid Lönnhager <david.l@mullvad.net>2023-06-05 20:04:34 +0200
commit38d7c4b0a02c293a84ccec4a4cc632934a36cdfb (patch)
treeebbae33de7e464d85bc794b344df14076d8a9923
parente3cfce2dddc5ce7f2660cef52dae4e3a6571fcda (diff)
downloadmullvadvpn-38d7c4b0a02c293a84ccec4a4cc632934a36cdfb.tar.xz
mullvadvpn-38d7c4b0a02c293a84ccec4a4cc632934a36cdfb.zip
Update documentation for offline monitor
-rw-r--r--talpid-core/src/offline/macos.rs23
1 files changed, 5 insertions, 18 deletions
diff --git a/talpid-core/src/offline/macos.rs b/talpid-core/src/offline/macos.rs
index 6deafd57ce..7263f9ab0f 100644
--- a/talpid-core/src/offline/macos.rs
+++ b/talpid-core/src/offline/macos.rs
@@ -2,24 +2,9 @@
//! that the app gets stuck in an offline state, blocking all internet access and preventing the
//! user from connecting to a relay.
//!
-//! Currently, this functionality is implemented by using `route monitor -n` to observe routing
-//! table changes and then use the CLI once more to query if there exists a default route.
-//! Generally, it is assumed that a machine is online if there exists a route to a public IP
-//! address that isn't using a tunnel adapter. On macOS, there were various ways of deducing this:
-//! - watching the `State:/Network/Global/IPv4` key in SystemConfiguration via
-//! `system-configuration-rs`, relying on a CoreFoundation runloop to drive callbacks.
-//! The issue with this is that sometimes during early boot or after a re-install, the callbacks
-//! won't be called, often leaving the daemon stuck in an offline state.
-//! - setting a callback via [`SCNetworkReachability`]. The callback should be called whenever the
-//! reachability of a remote host changes, but sometimes the callbacks just don't get called.
-//! - [`NWPathMonitor`] is a macOS native interface to watch changes in the routing table. It works
-//! great, but it seems to deliver updates before they actually get added to the routing table,
-//! effectively calling our callbacks with routes that aren't yet usable, so starting tunnels
-//! would fail anyway. This would be the API to use if we were able to bind the sockets our tunnel
-//! implementations would use, but that is far too much complexity.
-//!
-//! [`SCNetworkReachability`]: https://developer.apple.com/documentation/systemconfiguration/scnetworkreachability-g7d
-//! [`NWPathMonitor`]: https://developer.apple.com/documentation/network/nwpathmonitor
+//! Currently, this functionality is implemented by watching for changes to the default route
+//! in [`RouteManager`] using a `PF_ROUTE` socket. If there is no default route for neither IPv4 nor
+//! IPv6, the host is considered to be offline.
use futures::{channel::mpsc::UnboundedSender, StreamExt};
use std::{
sync::{
@@ -74,6 +59,8 @@ pub async fn spawn_monitor(
Ok((v4_route, v6_route)) => (v4_route.is_some(), v6_route.is_some()),
Err(error) => {
log::warn!("Failed to initialize offline monitor: {error}");
+ // Fail open: Assume that we have connectivity if we cannot determine the existence of
+ // a default route, since we don't want to block the user from connecting
(true, true)
}
};