diff options
| author | David Lönnhager <david.l@mullvad.net> | 2026-04-21 18:20:51 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2026-04-22 13:15:05 +0200 |
| commit | 7ba25423ef120c033b403f655cf6509ac4d158da (patch) | |
| tree | b631026b1f891a488017cd4379a8f380e8704fc5 | |
| parent | ef6b61a78c2f8461578c9dcef9592b4580eb9ff9 (diff) | |
| download | mullvadvpn-7ba25423ef120c033b403f655cf6509ac4d158da.tar.xz mullvadvpn-7ba25423ef120c033b403f655cf6509ac4d158da.zip | |
Configure IP addresses without tun crate (i.e. do not use netsh)
| Variant | Average (10 runs) | Speedup |
|------------------|-------------------|-----------------|
| with netsh (main)| 3.824 s | - |
| without netsh | 0.512 s | ~7.5x faster |
Variation within each variant was small (<= ~150 ms).
Test conditions:
- Relay: Sweden (any relay)
- Settings: No PQ, no obfuscation
- 10 iterations per variant, 10 s wait between attempts
| -rw-r--r-- | talpid-tunnel/src/tun_provider/windows.rs | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/talpid-tunnel/src/tun_provider/windows.rs b/talpid-tunnel/src/tun_provider/windows.rs index 4be38b0877..e2b6ae3e1a 100644 --- a/talpid-tunnel/src/tun_provider/windows.rs +++ b/talpid-tunnel/src/tun_provider/windows.rs @@ -50,13 +50,6 @@ impl WindowsTunProvider { /// Open a tunnel using the current tunnel config. pub fn open_tun(&mut self) -> Result<WindowsTun, Error> { - let (first_addr, remaining_addrs) = self - .config - .addresses - .split_first() - .map(|(first, rest)| (Some(first), rest)) - .unwrap_or((None, &[])); - let mut tunnel_device = { let mut builder = TunnelDeviceBuilder::default(); @@ -65,12 +58,6 @@ impl WindowsTunProvider { // routes the highest possible priority. builder.config.metric(1); - // TODO: have tun either not use netsh or not set any default address at all - // TODO: tun can only set a single address - if let Some(addr) = first_addr { - builder.config.address(*addr); - } - /// Tunnel adapter name const ADAPTER_NAME: &str = "Mullvad"; /// Tunnel adapter GUID. @@ -93,7 +80,9 @@ impl WindowsTunProvider { builder.create()? }; - for ip in remaining_addrs { + // TODO: `tun` currently cannot handle IPv6 without using netsh, + // so we add IPs ourselves. + for ip in &self.config.addresses { tunnel_device.set_ip(*ip)?; } |
