mirror of
https://github.com/go-gost/x.git
synced 2026-10-19 16:16:32 +00:00
An unprivileged Android app cannot open /dev/net/tun, so the device can only come from a VpnService: the Java side creates and configures it (addresses, routes, MTU, DNS via VpnService.Builder) and hands its fd over as the "fd" metadata, either as a fixed descriptor or — for an embedder, which is what the platform's own VPN is — as a provider resolved when each device is built, so a device rebuilt after its session ended never copies a closed or recycled descriptor. The device is created with tun.CreateUnmonitoredTUNFromFD (no netlink listener, no setMTU — the builder already set it), which makes the Linux variant, with its netlink and resolvectl calls, inapplicable: it is now linux && !android. The interface lookup in the accept loop was fatal on any error; it is informational, and on Android the device may not be listed in this process.