From 6507cb6805b4bb89a91aa7342f465507658b249b Mon Sep 17 00:00:00 2001 From: Owen Date: Fri, 7 Aug 2026 16:04:28 -0400 Subject: [PATCH] disable native network configuration for already-open TUN devices on mobile platforms --- olm/connect.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/olm/connect.go b/olm/connect.go index 9e2a77a..5fc5f47 100644 --- a/olm/connect.go +++ b/olm/connect.go @@ -74,6 +74,17 @@ func (o *Olm) handleConnect(msg websocket.WSMessage) { return } + // When handed an already-open FD (mobile/NetworkExtension platforms), the + // TUN device's addresses and routes are owned and reconciled by the host + // platform from NetworkSettings (e.g. Apple's NEPacketTunnelProvider via + // setTunnelNetworkSettings) - our own ifconfig/route subprocess calls must + // not also run against the same interface, or the two end up installing + // competing routes to the same destination. On macOS specifically this + // package's darwin code paths would otherwise run for real here (the NE + // build shares GOOS=darwin with the CLI), unlike iOS where they're already + // no-ops via a GOOS check. + network.NativeConfigDisabled = o.tunnelConfig.FileDescriptorTun != 0 + o.tdev, err = func() (tun.Device, error) { if o.tunnelConfig.FileDescriptorTun != 0 { return olmDevice.CreateTUNFromFD(o.tunnelConfig.FileDescriptorTun, o.tunnelConfig.MTU)