diff --git a/talpid-wireguard/src/lib.rs b/talpid-wireguard/src/lib.rs index 89823be3a97f..ec798e9cf745 100644 --- a/talpid-wireguard/src/lib.rs +++ b/talpid-wireguard/src/lib.rs @@ -691,13 +691,13 @@ impl WireguardMonitor { } else { #[cfg(target_os = "linux")] { - let res = if will_nm_manage_dns() { + let res: Option = if will_nm_manage_dns() { match wireguard_kernel::NetworkManagerTunnel::new(runtime, config) { Ok(tunnel) => { log::debug!( "Using NetworkManager to use kernel WireGuard implementation" ); - Ok(Box::new(tunnel)) + Some(Box::new(tunnel)) } Err(err) => { log::error!( @@ -706,13 +706,14 @@ impl WireguardMonitor { "Failed to initialize WireGuard tunnel via NetworkManager" ) ); + None } - }; + } } else { match wireguard_kernel::NetlinkTunnel::new(runtime, config) { Ok(tunnel) => { log::debug!("Using kernel WireGuard implementation"); - Ok(Box::new(tunnel)) + Some(Box::new(tunnel)) } Err(error) => { log::error!( @@ -721,12 +722,14 @@ impl WireguardMonitor { "Failed to setup kernel WireGuard device, falling back to the userspace implementation" ) ); + None } - }; + } }; + match res { - Ok(tunnel) => Ok(tunnel), - Err(_) => { + Some(tunnel) => Ok(tunnel), + None => { log::warn!("Falling back to userspace WireGuard implementation"); let tunnel = Self::open_wireguard_go_tunnel(config, log_path, tun_provider) .map(Box::new)?; diff --git a/talpid-wireguard/src/logging.rs b/talpid-wireguard/src/logging.rs index 946d614f0172..44e98e37e943 100644 --- a/talpid-wireguard/src/logging.rs +++ b/talpid-wireguard/src/logging.rs @@ -44,8 +44,8 @@ pub fn clean_up_logging(ordinal: u64) { state.map.remove(&ordinal); } +#[allow(dead_code)] pub enum LogLevel { - #[cfg_attr(windows, allow(dead_code))] Verbose, Info, Warning,