summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarkus Pettersson <markus.pettersson@mullvad.net>2025-01-02 13:21:47 +0100
committerMarkus Pettersson <markus.pettersson@mullvad.net>2025-01-03 11:04:20 +0100
commitcb658aff39d14f14fda94ef81406e7da7d22ee83 (patch)
treeb55023300ac6d87d70fca526754b6b6cc896c70b
parent8b31a8417142d1c5a61aed2e080eb13f177b7d87 (diff)
downloadmullvadvpn-cb658aff39d14f14fda94ef81406e7da7d22ee83.tar.xz
mullvadvpn-cb658aff39d14f14fda94ef81406e7da7d22ee83.zip
Clean up API for setting tunnel device name
-rw-r--r--talpid-tunnel/src/tun_provider/mod.rs2
-rw-r--r--talpid-tunnel/src/tun_provider/unix.rs9
2 files changed, 7 insertions, 4 deletions
diff --git a/talpid-tunnel/src/tun_provider/mod.rs b/talpid-tunnel/src/tun_provider/mod.rs
index 94a82735d1..1bf4e1abb4 100644
--- a/talpid-tunnel/src/tun_provider/mod.rs
+++ b/talpid-tunnel/src/tun_provider/mod.rs
@@ -35,6 +35,7 @@ cfg_if! {
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct TunConfig {
/// Interface name to use.
+ #[cfg(target_os = "linux")]
pub name: Option<String>,
/// IP addresses for the tunnel interface.
@@ -80,6 +81,7 @@ impl TunConfig {
/// Android to route all traffic inside the tunnel.
pub fn blocking_config() -> TunConfig {
TunConfig {
+ #[cfg(target_os = "linux")]
name: None,
addresses: vec![IpAddr::V4(Ipv4Addr::new(10, 0, 0, 1))],
mtu: 1380,
diff --git a/talpid-tunnel/src/tun_provider/unix.rs b/talpid-tunnel/src/tun_provider/unix.rs
index b045dad877..6286779cee 100644
--- a/talpid-tunnel/src/tun_provider/unix.rs
+++ b/talpid-tunnel/src/tun_provider/unix.rs
@@ -66,10 +66,11 @@ impl UnixTunProvider {
#[allow(unused_mut)]
let mut builder = TunnelDeviceBuilder::default();
#[cfg(target_os = "linux")]
- builder.enable_packet_information();
- #[cfg(target_os = "linux")]
- if let Some(ref name) = self.config.name {
- builder.name(name);
+ {
+ builder.enable_packet_information();
+ if let Some(ref name) = self.config.name {
+ builder.name(name);
+ }
}
builder.create()?
};