mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-22 09:14:25 +00:00
Since #7173, a failed interface binding fails the dial. On Darwin (macOS and iOS), setinterface fell through from IPV6_BOUND_IF to IP_BOUND_IF on IPv6 sockets, which Darwin rejects with EINVAL. So every UDP dial failed, as Go opens a dual-stack IPv6 socket for it, and so did TCP to IPv6. TCP to IPv4 uses an IPv4 socket and kept working. Before #7173 the error was only logged. IPV6_BOUND_IF binds the whole socket, so on a dual-stack socket it covers its IPv4 traffic as well. Set only the option of the socket's family, as sockopt_darwin.go already does for sockopt.interface. The new test binds each kind of socket to lo0. Linux, Android and FreeBSD bind with socket-level options (SO_BINDTODEVICE, SO_SETFIB) that don't depend on the IP version. On Windows, the related case of an adapter without IPv4 or IPv6 is handled in #7214. Fixes #7228 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>