summaryrefslogtreecommitdiffhomepage
path: root/talpid-core/src
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2025-05-21 14:06:05 +0200
committerDavid Lönnhager <david.l@mullvad.net>2025-05-22 12:51:30 +0200
commit6c46326470bb45cfba35401e3b63238829010f4e (patch)
treefb966d1b34e8e6f9371a64f601c78df5fdb85c8e /talpid-core/src
parentedafd1f9ff5ade6955bbc93dd3803be35e525f22 (diff)
downloadmullvadvpn-6c46326470bb45cfba35401e3b63238829010f4e.tar.xz
mullvadvpn-6c46326470bb45cfba35401e3b63238829010f4e.zip
Fix missing connectivity messages on Windows
Diffstat (limited to 'talpid-core/src')
-rw-r--r--talpid-core/src/offline/windows.rs40
-rw-r--r--talpid-core/src/tunnel_state_machine/connecting_state.rs12
2 files changed, 15 insertions, 37 deletions
diff --git a/talpid-core/src/offline/windows.rs b/talpid-core/src/offline/windows.rs
index 319e12bde3..2111c4cd6c 100644
--- a/talpid-core/src/offline/windows.rs
+++ b/talpid-core/src/offline/windows.rs
@@ -32,12 +32,14 @@ impl BroadcastListener {
) -> Result<Self, Error> {
let notify_tx = Arc::new(notify_tx);
let (ipv4, ipv6) = Self::check_initial_connectivity();
+ let connectivity = ConnectivityInner {
+ ipv4,
+ ipv6,
+ suspended: false,
+ };
+ log::info!("Initial connectivity: {}", connectivity.into_connectivity());
let system_state = Arc::new(Mutex::new(SystemState {
- connectivity: ConnectivityInner {
- ipv4,
- ipv6,
- suspended: false,
- },
+ connectivity,
notify_tx: Arc::downgrade(&notify_tx),
}));
@@ -93,10 +95,6 @@ impl BroadcastListener {
);
true
});
-
- let is_online = v4_connectivity || v6_connectivity;
- log::info!("Initial connectivity: {}", is_offline_str(!is_online));
-
(v4_connectivity, v6_connectivity)
}
@@ -157,7 +155,7 @@ struct SystemState {
impl SystemState {
fn apply_change(&mut self, change: StateChange) {
- let old_state = self.is_offline_currently();
+ let old_state = self.connectivity.into_connectivity();
match change {
StateChange::NetworkV4Connectivity(connectivity) => {
self.connectivity.ipv4 = connectivity;
@@ -170,9 +168,9 @@ impl SystemState {
}
};
- let new_state = self.connectivity.is_offline();
+ let new_state = self.connectivity.into_connectivity();
if old_state != new_state {
- log::info!("Connectivity changed: {}", is_offline_str(new_state));
+ log::info!("Connectivity changed: {new_state}");
if let Some(notify_tx) = self.notify_tx.upgrade() {
if let Err(e) = notify_tx.unbounded_send(self.connectivity.into_connectivity()) {
log::error!("Failed to send new offline state to daemon: {}", e);
@@ -180,19 +178,6 @@ impl SystemState {
}
}
}
-
- fn is_offline_currently(&self) -> bool {
- self.connectivity.is_offline()
- }
-}
-
-// If `offline` is true, return "Offline". Otherwise, return "Connected".
-fn is_offline_str(offline: bool) -> &'static str {
- if offline {
- "Offline"
- } else {
- "Connected"
- }
}
pub type MonitorHandle = BroadcastListener;
@@ -235,9 +220,4 @@ impl ConnectivityInner {
Connectivity::new(self.ipv4, self.ipv6)
}
}
-
- /// See [`Connectivity::is_offline`] for details.
- fn is_offline(&self) -> bool {
- self.into_connectivity().is_offline()
- }
}
diff --git a/talpid-core/src/tunnel_state_machine/connecting_state.rs b/talpid-core/src/tunnel_state_machine/connecting_state.rs
index cdf324b5b1..e3411d6b9a 100644
--- a/talpid-core/src/tunnel_state_machine/connecting_state.rs
+++ b/talpid-core/src/tunnel_state_machine/connecting_state.rs
@@ -9,9 +9,7 @@ use futures::{FutureExt, StreamExt};
use talpid_routing::RouteManagerHandle;
use talpid_tunnel::tun_provider::TunProvider;
use talpid_tunnel::{EventHook, TunnelArgs, TunnelEvent, TunnelMetadata};
-use talpid_types::net::{
- AllowedClients, AllowedEndpoint, AllowedTunnelTraffic, IpAvailability, TunnelParameters,
-};
+use talpid_types::net::{AllowedClients, AllowedEndpoint, AllowedTunnelTraffic, TunnelParameters};
use talpid_types::tunnel::{ErrorStateCause, FirewallPolicyError};
use talpid_types::ErrorExt;
@@ -75,8 +73,10 @@ impl ConnectingState {
});
}
- let ip_availability = match shared_values.connectivity {
- talpid_types::net::Connectivity::Offline => {
+ let ip_availability = match shared_values.connectivity.availability() {
+ Some(ip_availability) => ip_availability,
+ // If we're offline, enter the offline state
+ None => {
// FIXME: Temporary: Nudge route manager to update the default interface
#[cfg(target_os = "macos")]
{
@@ -85,8 +85,6 @@ impl ConnectingState {
}
return ErrorState::enter(shared_values, ErrorStateCause::IsOffline);
}
- talpid_types::net::Connectivity::PresumeOnline => IpAvailability::Ipv4,
- talpid_types::net::Connectivity::Online(ip_availability) => ip_availability,
};
match shared_values.runtime.block_on(