summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarkus Pettersson <markus.pettersson@mullvad.net>2026-04-22 10:06:05 +0200
committerMarkus Pettersson <markus.pettersson@mullvad.net>2026-04-22 10:14:20 +0200
commitdd6d4bf5d27e4de908bf4c589c16de22486dbb31 (patch)
treea355d73890f97c04b0b9f91e06ec5ca7765fabb0
parent9e2f04c612001e5fd5755eb5a9f7b6e7a4252d16 (diff)
downloadmullvadvpn-untangle-talpid-wireguard.tar.xz
mullvadvpn-untangle-talpid-wireguard.zip
Fix `#[cfg(windows)]` -> `#[cfg(target_os = "windows")]`untangle-talpid-wireguard
Fix cross-compilation from other, non-Windows platforms.
-rw-r--r--talpid-wireguard/Cargo.toml2
-rw-r--r--talpid-wireguard/src/connectivity/pinger/icmp.rs2
-rw-r--r--talpid-wireguard/src/ephemeral.rs4
-rw-r--r--talpid-wireguard/src/gotatun/mod.rs4
-rw-r--r--talpid-wireguard/src/lib.rs26
-rw-r--r--talpid-wireguard/src/mtu_detection.rs6
-rw-r--r--talpid-wireguard/src/wireguard_go/mod.rs4
7 files changed, 24 insertions, 24 deletions
diff --git a/talpid-wireguard/Cargo.toml b/talpid-wireguard/Cargo.toml
index c860831eef..c3bdebb2ab 100644
--- a/talpid-wireguard/Cargo.toml
+++ b/talpid-wireguard/Cargo.toml
@@ -54,7 +54,7 @@ zerocopy = { workspace = true, features = ["derive"] }
libc = "0.2.150"
nix = { workspace = true, features = ["fs"] }
-[target.'cfg(windows)'.dependencies]
+[target.'cfg(target_os = "windows")'.dependencies]
bitflags = "1.2"
chrono = { workspace = true, features = ["clock"] }
talpid-windows = { path = "../talpid-windows" }
diff --git a/talpid-wireguard/src/connectivity/pinger/icmp.rs b/talpid-wireguard/src/connectivity/pinger/icmp.rs
index 2cbe05795d..1c606f423a 100644
--- a/talpid-wireguard/src/connectivity/pinger/icmp.rs
+++ b/talpid-wireguard/src/connectivity/pinger/icmp.rs
@@ -128,7 +128,7 @@ impl Pinger {
}
}
-#[cfg(windows)]
+#[cfg(target_os = "windows")]
fn should_retry_send(err: &io::Error) -> bool {
// Winsock error for when there is no route
// NOTE: It's unclear if we need to check this on Windows anymore, or why specifically on Windows
diff --git a/talpid-wireguard/src/ephemeral.rs b/talpid-wireguard/src/ephemeral.rs
index a87ddcbde9..f272655c38 100644
--- a/talpid-wireguard/src/ephemeral.rs
+++ b/talpid-wireguard/src/ephemeral.rs
@@ -22,7 +22,7 @@ const INITIAL_PSK_EXCHANGE_TIMEOUT: Duration = Duration::from_secs(8);
const MAX_PSK_EXCHANGE_TIMEOUT: Duration = Duration::from_secs(48);
const PSK_EXCHANGE_TIMEOUT_MULTIPLIER: u32 = 2;
-#[cfg(windows)]
+#[cfg(target_os = "windows")]
pub async fn config_ephemeral_peers(
tunnel: &Arc<AsyncMutex<Option<TunnelType>>>,
config: &mut Config,
@@ -61,7 +61,7 @@ pub async fn config_ephemeral_peers(
Ok(())
}
-#[cfg(windows)]
+#[cfg(target_os = "windows")]
fn try_set_ipv4_mtu(alias: &str, mtu: u16) {
use talpid_windows::net::*;
match luid_from_alias(alias) {
diff --git a/talpid-wireguard/src/gotatun/mod.rs b/talpid-wireguard/src/gotatun/mod.rs
index cda21dc88c..6c85fb0e2c 100644
--- a/talpid-wireguard/src/gotatun/mod.rs
+++ b/talpid-wireguard/src/gotatun/mod.rs
@@ -199,7 +199,7 @@ pub async fn open_gotatun_tunnel(
{
tun.into_inner().into_inner()
}
- #[cfg(windows)]
+ #[cfg(target_os = "windows")]
{
tun.into_inner()
}
@@ -573,7 +573,7 @@ fn get_tunnel_for_userspace(
let _ = routes;
- #[cfg(windows)]
+ #[cfg(target_os = "windows")]
tun_provider
.open_tun()
.map_err(TunnelError::SetupTunnelDevice)
diff --git a/talpid-wireguard/src/lib.rs b/talpid-wireguard/src/lib.rs
index 8b5e4137e3..85a9baa5d4 100644
--- a/talpid-wireguard/src/lib.rs
+++ b/talpid-wireguard/src/lib.rs
@@ -3,11 +3,11 @@
#![deny(missing_docs)]
use self::config::Config;
-#[cfg(windows)]
+#[cfg(target_os = "windows")]
use futures::channel::mpsc;
use futures::future::Future;
use obfuscation::ObfuscatorHandle;
-#[cfg(windows)]
+#[cfg(target_os = "windows")]
use std::io;
use std::{
convert::Infallible,
@@ -46,7 +46,7 @@ mod obfuscation;
mod stats;
#[cfg(target_os = "linux")]
pub(crate) mod wireguard_kernel;
-#[cfg(windows)]
+#[cfg(target_os = "windows")]
mod wireguard_nt;
#[cfg(not(target_os = "android"))]
@@ -88,7 +88,7 @@ pub enum Error {
EphemeralPeerNegotiationError(#[source] talpid_tunnel_config_client::Error),
/// Failed to set up IP interfaces.
- #[cfg(windows)]
+ #[cfg(target_os = "windows")]
#[error("Failed to set up IP interfaces")]
IpInterfacesError,
@@ -111,7 +111,7 @@ impl Error {
#[cfg(target_os = "android")]
Error::TunnelError(TunnelError::BypassError(_)) => true,
- #[cfg(windows)]
+ #[cfg(target_os = "windows")]
Error::TunnelError(TunnelError::SetupTunnelDevice(_)) => true,
_ => false,
@@ -119,7 +119,7 @@ impl Error {
}
/// Get the inner tunnel device error, if there is one
- #[cfg(windows)]
+ #[cfg(target_os = "windows")]
pub fn get_tunnel_device_error(&self) -> Option<&io::Error> {
match self {
Error::TunnelError(TunnelError::SetupTunnelDevice(tun_provider::Error::Io(error))) => {
@@ -253,7 +253,7 @@ impl WireguardMonitor {
let tunnel = moved_tunnel;
let close_obfs_sender: sync_mpsc::Sender<CloseMsg> = moved_close_obfs_sender;
let obfuscator = moved_obfuscator;
- #[cfg(windows)]
+ #[cfg(target_os = "windows")]
if cfg!(not(feature = "wireguard-go")) && userspace_wireguard {
// NOTE: For gotatun, we use the `tun` crate to create our tunnel interface.
// It will automatically configure the IP address and DNS servers using `netsh`.
@@ -333,7 +333,7 @@ impl WireguardMonitor {
gateway,
iface_name,
config.mtu,
- #[cfg(windows)]
+ #[cfg(target_os = "windows")]
config.ipv6_gateway.is_some(),
)
.await
@@ -640,7 +640,7 @@ impl WireguardMonitor {
AllowedTunnelTraffic::All
}
- #[cfg(windows)]
+ #[cfg(target_os = "windows")]
async fn wait_for_ip_addresses(
config: &Config,
iface_name: &String,
@@ -666,7 +666,7 @@ impl WireguardMonitor {
Ok(())
}
- #[cfg(windows)]
+ #[cfg(target_os = "windows")]
async fn add_device_ip_addresses(
iface_name: &str,
addresses: &[std::net::IpAddr],
@@ -894,7 +894,7 @@ impl WireguardMonitor {
iface_name: &str,
config: &Config,
) -> (talpid_routing::Node, talpid_routing::Node) {
- #[cfg(windows)]
+ #[cfg(target_os = "windows")]
{
let v4 = talpid_routing::Node::new(config.ipv4_gateway.into(), iface_name.to_string());
let v6 = if let Some(ipv6_gateway) = config.ipv6_gateway.as_ref() {
@@ -905,7 +905,7 @@ impl WireguardMonitor {
(v4, v6)
}
- #[cfg(not(windows))]
+ #[cfg(not(target_os = "windows"))]
{
let node = talpid_routing::Node::device(iface_name.to_string());
(node.clone(), node)
@@ -1146,7 +1146,7 @@ pub enum TunnelError {
SetupTunnelDevice(#[source] tun_provider::Error),
/// Failed to setup a tunnel device.
- #[cfg(windows)]
+ #[cfg(target_os = "windows")]
#[error("Failed to config IP interfaces on tunnel device")]
SetupIpInterfaces(#[source] io::Error),
diff --git a/talpid-wireguard/src/mtu_detection.rs b/talpid-wireguard/src/mtu_detection.rs
index 04f7f36c41..3b36e9c036 100644
--- a/talpid-wireguard/src/mtu_detection.rs
+++ b/talpid-wireguard/src/mtu_detection.rs
@@ -45,7 +45,7 @@ pub async fn automatic_mtu_correction(
gateway: std::net::Ipv4Addr,
iface_name: String,
current_tunnel_mtu: u16,
- #[cfg(windows)] ipv6: bool,
+ #[cfg(target_os = "windows")] ipv6: bool,
) -> Result<(), Error> {
log::debug!("Starting MTU detection");
let verified_mtu = detect_mtu(
@@ -61,7 +61,7 @@ pub async fn automatic_mtu_correction(
#[cfg(any(target_os = "linux", target_os = "macos"))]
talpid_net::unix::set_mtu(&iface_name, verified_mtu).map_err(Error::SetMtu)?;
- #[cfg(windows)]
+ #[cfg(target_os = "windows")]
set_mtu_windows(verified_mtu, iface_name, ipv6).map_err(Error::SetMtu)?;
} else {
log::debug!("MTU {verified_mtu} verified to not drop packets");
@@ -69,7 +69,7 @@ pub async fn automatic_mtu_correction(
Ok(())
}
-#[cfg(windows)]
+#[cfg(target_os = "windows")]
fn set_mtu_windows(verified_mtu: u16, iface_name: String, ipv6: bool) -> io::Result<()> {
use talpid_windows::net::{AddressFamily, set_mtu};
diff --git a/talpid-wireguard/src/wireguard_go/mod.rs b/talpid-wireguard/src/wireguard_go/mod.rs
index b2b4cef757..3921420608 100644
--- a/talpid-wireguard/src/wireguard_go/mod.rs
+++ b/talpid-wireguard/src/wireguard_go/mod.rs
@@ -90,10 +90,10 @@ pub(crate) async fn open_wireguard_go_tunnel(
log_path: Option<&Path>,
#[cfg(unix)] tun_provider: Arc<std::sync::Mutex<talpid_tunnel::tun_provider::TunProvider>>,
#[cfg(target_os = "android")] route_manager: RouteManagerHandle,
- #[cfg(windows)] setup_done_tx: futures::channel::mpsc::Sender<
+ #[cfg(target_os = "windows")] setup_done_tx: futures::channel::mpsc::Sender<
std::result::Result<(), BoxedError>,
>,
- #[cfg(windows)] route_manager: talpid_routing::RouteManagerHandle,
+ #[cfg(target_os = "windows")] route_manager: talpid_routing::RouteManagerHandle,
#[cfg(target_os = "android")] gateway_only: bool,
#[cfg(target_os = "android")] cancel_receiver: connectivity::CancelReceiver,
) -> Result<WgGoTunnel> {