Repository navigation
TUN inbound: Duplicate the iOS tunnel file descriptor - #6883
Conversation
|
syscall.Dup() ? |
syscall.Dup() would work, but F_DUPFD_CLOEXEC also sets close-on-exec atomically. |
|
|
not need if so |
|
@yiguodev 你看看 |
|
Reviewed commit Skipping an explicit close is insufficient when a borrowed descriptor is wrapped in I validated this locally on macOS using a socketpair, without starting a VPN:
The Real NetworkExtension sleep/wake and reload scenarios were not exercised. Adding a regression test for borrowed-fd close/GC/reuse would be useful. |
…nt changes in README Covers #7173 (a connection that cannot be bound fails instead of leaving unbound), #7214 (IPv4-only and IPv6-only outbound interfaces on Windows), #7230 (IPV6_BOUND_IF on macOS), and also #7130 (built-in TCP/IP stack), #6874 (IPv6 disabled system-wide on Windows), #6811 (an existing Wintun adapter is reused) and #6883 (the iOS fd is duplicated). #7092 and autoSystemWfpBlockLeak were already covered. Co-Authored-By: Claude Opus 5.5 <[email protected]>
On iOS the tun fd belongs to NetworkExtension, and the app reuses it every time the core restarts (wake from sleep, reload). Xray wrapped it in an os.File, so once the core stopped, Go GC closed it, and after the next restart the tunnel either had no fd or quietly stopped passing traffic.
Duplicating the fd lets Xray close its own copy without ever touching the one iOS owns.