mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-26 13:06:58 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e76d009b8 |
@@ -14,7 +14,7 @@ require (
|
||||
github.com/miekg/dns v1.1.73
|
||||
github.com/pelletier/go-toml v1.9.5
|
||||
github.com/pion/stun/v3 v3.1.7
|
||||
github.com/pires/go-proxyproto v0.15.0
|
||||
github.com/pires/go-proxyproto v0.16.0
|
||||
github.com/refraction-networking/utls v1.8.3-0.20260301010127-aa6edf4b11af
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/stretchr/testify v1.12.1
|
||||
|
||||
@@ -59,8 +59,8 @@ github.com/pion/stun/v3 v3.1.7 h1:uRXMTlGLf89WgItGNyZ6aR5jMTX0NBbybXADpQCzn+E=
|
||||
github.com/pion/stun/v3 v3.1.7/go.mod h1:Nq77RW4aRrSNrltf2ksUJLjxWeipj4lnlgdsYIxC8g8=
|
||||
github.com/pion/transport/v4 v4.1.0 h1:8S+nF2reM2cJuqC6g78OVy2BBgmbdns+acx3jA97BvQ=
|
||||
github.com/pion/transport/v4 v4.1.0/go.mod h1:06hFI+jCFcok2X2MekVufNZ/uzNZXivGBPfviSVcjgM=
|
||||
github.com/pires/go-proxyproto v0.15.0 h1:dTshmNbFm/D+0+sbrxUuddPOZ5Y0B7c5NhtsBkm6LqI=
|
||||
github.com/pires/go-proxyproto v0.15.0/go.mod h1:OXsCrKwrK2tXS9YrI5tkHx5xaQlO8FH3lFW76orFh24=
|
||||
github.com/pires/go-proxyproto v0.16.0 h1:9KYT/fM3wpjT8bdMEj/7FBcoiUG1KyzEjRYnPu+vz7A=
|
||||
github.com/pires/go-proxyproto v0.16.0/go.mod h1:n7yhg8yIfNl3KgYDCwBzmeUHNpKTVnUhcWpc7rV4RW4=
|
||||
github.com/quic-go/go-ossfuzz-seeds v0.1.0 h1:APacT+iIaNF6fd8AGEiN3bT/Jtkd2jz4v4TzM7MFjy0=
|
||||
github.com/quic-go/go-ossfuzz-seeds v0.1.0/go.mod h1:3IOHRbJIc+L6YKMwfDtJAM9Vj9k0YY4muhuyUYk5tbk=
|
||||
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
||||
|
||||
@@ -558,16 +558,19 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) error {
|
||||
}
|
||||
|
||||
func setinterface(network, address string, fd uintptr, iface *net.Interface) error {
|
||||
var err1, err2 error
|
||||
|
||||
switch network {
|
||||
case "tcp6", "udp6", "ip6":
|
||||
// IPV6_BOUND_IF binds the IPv4 traffic of a dual-stack socket as
|
||||
// well, and an IPv6 socket rejects IP_BOUND_IF with EINVAL.
|
||||
return unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_BOUND_IF, iface.Index)
|
||||
err1 = unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_BOUND_IF, iface.Index)
|
||||
fallthrough
|
||||
case "tcp4", "udp4", "ip4":
|
||||
return unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, unix.IP_BOUND_IF, iface.Index)
|
||||
err2 = unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, unix.IP_BOUND_IF, iface.Index)
|
||||
default:
|
||||
panic(network + " " + address)
|
||||
}
|
||||
|
||||
return errors.Join(err1, err2)
|
||||
}
|
||||
|
||||
func findOutboundInterface(tunIndex int, fixedName string) (*net.Interface, error) {
|
||||
|
||||
@@ -3,10 +3,7 @@
|
||||
package tun
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"sync"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -234,40 +231,3 @@ func TestWaitKqueueReportsPersistentFailure(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestSetinterfaceSocketFamilies binds each kind of socket Xray's dialers
|
||||
// open to lo0, including the dual-stack one Go opens for UDP.
|
||||
func TestSetinterfaceSocketFamilies(t *testing.T) {
|
||||
lo, err := net.InterfaceByName("lo0")
|
||||
if err != nil {
|
||||
t.Skip(err)
|
||||
}
|
||||
lc := net.ListenConfig{Control: func(network, address string, c syscall.RawConn) error {
|
||||
var err error
|
||||
if controlErr := c.Control(func(fd uintptr) {
|
||||
err = setinterface(network, address, fd, lo)
|
||||
}); controlErr != nil {
|
||||
return controlErr
|
||||
}
|
||||
return err
|
||||
}}
|
||||
for _, s := range []struct{ network, address string }{
|
||||
{"udp", "0.0.0.0:0"}, // dual-stack
|
||||
{"udp4", "127.0.0.1:0"},
|
||||
{"udp6", "[::1]:0"},
|
||||
{"tcp4", "127.0.0.1:0"},
|
||||
{"tcp6", "[::1]:0"},
|
||||
} {
|
||||
var closer interface{ Close() error }
|
||||
if s.network[:3] == "udp" {
|
||||
closer, err = lc.ListenPacket(context.Background(), s.network, s.address)
|
||||
} else {
|
||||
closer, err = lc.Listen(context.Background(), s.network, s.address)
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("%s %s: %v", s.network, s.address, err)
|
||||
continue
|
||||
}
|
||||
closer.Close()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user