diff options
| author | David Lönnhager <david.l@mullvad.net> | 2023-02-06 13:18:49 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2023-02-07 14:23:01 +0100 |
| commit | 92abd6e9dadd4952b18711ebf44b6d203a3593d6 (patch) | |
| tree | 88db489313022c7198cf1cf3d875a53af2df099c | |
| parent | 40d0bc36cae646854055544fec5d4fb837c156ab (diff) | |
| download | mullvadvpn-92abd6e9dadd4952b18711ebf44b6d203a3593d6.tar.xz mullvadvpn-92abd6e9dadd4952b18711ebf44b6d203a3593d6.zip | |
Remove automatic fallback when wireguard-nt is enabled
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | talpid-wireguard/src/lib.rs | 24 | ||||
| -rw-r--r-- | talpid-wireguard/src/wireguard_nt.rs | 26 |
3 files changed, 35 insertions, 19 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 98accf7223..9208413a09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,10 @@ Line wrap the file at 100 chars. Th - Update the Post-Quantum secure key exchange gRPC client to use the stabilized `PskExchangeV1` endpoint +#### Windows +- Remove automatic fallback to wireguard-go. This is done as a first step before fully + deprecating it on Windows. + ### Fixed #### Android - Fix adaptive app icon which previously had a displaced nose and some other oddities. diff --git a/talpid-wireguard/src/lib.rs b/talpid-wireguard/src/lib.rs index 8cb85e460e..9eaa477430 100644 --- a/talpid-wireguard/src/lib.rs +++ b/talpid-wireguard/src/lib.rs @@ -587,23 +587,15 @@ impl WireguardMonitor { #[cfg(target_os = "windows")] if config.use_wireguard_nt { - match wireguard_nt::WgNtTunnel::start_tunnel( + log::debug!("Using WireGuardNT"); + return wireguard_nt::WgNtTunnel::start_tunnel( config, log_path, resource_dir, - setup_done_tx.clone(), - ) { - Ok(tunnel) => { - log::debug!("Using WireGuardNT"); - return Ok(Box::new(tunnel)); - } - Err(error) => { - log::error!( - "{}", - error.display_chain_with_msg("Failed to setup WireGuardNT tunnel") - ); - } - } + setup_done_tx, + ) + .map(|tun| Box::new(tun) as Box<dyn Tunnel + 'static>) + .map_err(Error::TunnelError); } #[cfg(any(target_os = "linux", windows))] @@ -812,14 +804,14 @@ pub(crate) trait Tunnel: Send { pub enum TunnelError { /// A recoverable error occurred while starting the wireguard tunnel /// - /// This is an error returned by wireguard-go that indicates that trying to establish the + /// This is an error returned by the implementation that indicates that trying to establish the /// tunnel again should work normally. The error encountered is known to be sporadic. #[error(display = "Recoverable error while starting wireguard tunnel")] RecoverableStartWireguardError, /// An unrecoverable error occurred while starting the wireguard tunnel /// - /// This is an error returned by wireguard-go that indicates that trying to establish the + /// This is an error returned by the implementation that indicates that trying to establish the /// tunnel again will likely fail with the same error. An error was encountered during tunnel /// configuration which can't be dealt with gracefully. #[error(display = "Failed to start wireguard tunnel")] diff --git a/talpid-wireguard/src/wireguard_nt.rs b/talpid-wireguard/src/wireguard_nt.rs index 1044a3fd9a..3180e56064 100644 --- a/talpid-wireguard/src/wireguard_nt.rs +++ b/talpid-wireguard/src/wireguard_nt.rs @@ -410,6 +410,27 @@ impl WgNtTunnel { config: &Config, log_path: Option<&Path>, resource_dir: &Path, + done_tx: futures::channel::mpsc::Sender<std::result::Result<(), BoxedError>>, + ) -> std::result::Result<Self, super::TunnelError> { + Self::start_tunnel_inner(config, log_path, resource_dir, done_tx).map_err(|error| { + log::error!( + "{}", + error.display_chain_with_msg("Failed to setup WireGuardNT tunnel") + ); + + match error { + Error::CreateTunnelDeviceError(_) => { + super::TunnelError::RecoverableStartWireguardError + } + _ => super::TunnelError::FatalStartWireguardError, + } + }) + } + + fn start_tunnel_inner( + config: &Config, + log_path: Option<&Path>, + resource_dir: &Path, mut done_tx: futures::channel::mpsc::Sender<std::result::Result<(), BoxedError>>, ) -> Result<Self> { let dll = load_wg_nt_dll(resource_dir)?; @@ -447,13 +468,12 @@ impl WgNtTunnel { .await; }); - let tunnel = WgNtTunnel { + Ok(WgNtTunnel { device, interface_name, setup_handle, _logger_handle: logger_handle, - }; - Ok(tunnel) + }) } fn stop_tunnel(&mut self) { |
