diff options
| author | David Lönnhager <david.l@mullvad.net> | 2025-01-24 16:11:53 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2025-01-24 17:35:04 +0100 |
| commit | 3a4efae3efd0c58559b652055402d14f1e9f14a8 (patch) | |
| tree | dc987dd2bda53dc202fe89917ed11b3fc0f3a1e7 | |
| parent | 50b31b950a1a533aeb580af1dbc334dedb0d04fd (diff) | |
| download | mullvadvpn-3a4efae3efd0c58559b652055402d14f1e9f14a8.tar.xz mullvadvpn-3a4efae3efd0c58559b652055402d14f1e9f14a8.zip | |
Make start_tunnel async on Windows
| -rw-r--r-- | talpid-wireguard/src/lib.rs | 8 | ||||
| -rw-r--r-- | talpid-wireguard/src/wireguard_go/mod.rs | 13 |
2 files changed, 8 insertions, 13 deletions
diff --git a/talpid-wireguard/src/lib.rs b/talpid-wireguard/src/lib.rs index ea3207f12d..330a2c76cf 100644 --- a/talpid-wireguard/src/lib.rs +++ b/talpid-wireguard/src/lib.rs @@ -698,7 +698,6 @@ impl WireguardMonitor { log::debug!("Using userspace WireGuard implementation"); let tunnel = runtime .block_on(Self::open_wireguard_go_tunnel( - runtime, config, log_path, setup_done_tx, @@ -736,7 +735,6 @@ impl WireguardMonitor { #[cfg(wireguard_go)] #[allow(clippy::unused_async)] async fn open_wireguard_go_tunnel( - #[cfg(windows)] runtime: tokio::runtime::Handle, config: &Config, log_path: Option<&Path>, #[cfg(unix)] tun_provider: Arc<Mutex<TunProvider>>, @@ -755,9 +753,9 @@ impl WireguardMonitor { .map_err(Error::TunnelError)?; #[cfg(target_os = "windows")] - let tunnel = - WgGoTunnel::start_tunnel(runtime, config, log_path, route_manager, setup_done_tx) - .map_err(Error::TunnelError)?; + let tunnel = WgGoTunnel::start_tunnel(config, log_path, route_manager, setup_done_tx) + .await + .map_err(Error::TunnelError)?; // Android uses multihop implemented in Mullvad's wireguard-go fork. When negotiating // with an ephemeral peer, this multihop strategy require us to restart the tunnel diff --git a/talpid-wireguard/src/wireguard_go/mod.rs b/talpid-wireguard/src/wireguard_go/mod.rs index 0e64797ad5..1c6fc41fd3 100644 --- a/talpid-wireguard/src/wireguard_go/mod.rs +++ b/talpid-wireguard/src/wireguard_go/mod.rs @@ -260,8 +260,7 @@ impl WgGoTunnel { } #[cfg(target_os = "windows")] - pub fn start_tunnel( - runtime: tokio::runtime::Handle, + pub async fn start_tunnel( config: &Config, log_path: Option<&Path>, route_manager: talpid_routing::RouteManagerHandle, @@ -275,12 +274,10 @@ impl WgGoTunnel { .map(|ordinal| LoggingContext::new(ordinal, log_path.map(Path::to_owned))) .map_err(TunnelError::LoggingError)?; - let socket_update_cb = - runtime - .block_on(route_manager.add_default_route_change_callback(Box::new( - Self::default_route_changed_callback, - ))) - .ok(); + let socket_update_cb = route_manager + .add_default_route_change_callback(Box::new(Self::default_route_changed_callback)) + .await + .ok(); if socket_update_cb.is_none() { log::warn!("Failed to register default route callback"); } |
