-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Closed
Description
完整性要求
- 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
- 我提供了完整的配置文件和日志,而不是出于自己的判断只给出截取的部分。
- 我搜索了 issues, 没有发现已提出的类似问题。
- 问题在 Release 最新的版本上可以成功复现
描述
如题,darwin平台设置interface会漏udp,看了下确实没有对udp进行处理
Xray-core/transport/internet/sockopt_darwin.go
Lines 100 to 148 in 44b1dd0
| func applyOutboundSocketOptions(network string, address string, fd uintptr, config *SocketConfig) error { | |
| if isTCPSocket(network) { | |
| tfo := config.ParseTFOValue() | |
| if tfo > 0 { | |
| tfo = TCP_FASTOPEN_CLIENT | |
| } | |
| if tfo >= 0 { | |
| if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_FASTOPEN, tfo); err != nil { | |
| return err | |
| } | |
| } | |
| if config.Interface != "" { | |
| InterfaceIndex := getInterfaceIndexByName(config.Interface) | |
| if InterfaceIndex != 0 { | |
| if err := unix.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_BOUND_IF, InterfaceIndex); err != nil { | |
| return errors.New("failed to set Interface").Base(err) | |
| } | |
| } | |
| } | |
| if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 { | |
| if config.TcpKeepAliveIdle > 0 { | |
| if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_KEEPALIVE, int(config.TcpKeepAliveInterval)); err != nil { | |
| return errors.New("failed to set TCP_KEEPINTVL", err) | |
| } | |
| } | |
| if config.TcpKeepAliveInterval > 0 { | |
| if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, sysTCP_KEEPINTVL, int(config.TcpKeepAliveIdle)); err != nil { | |
| return errors.New("failed to set TCP_KEEPIDLE", err) | |
| } | |
| } | |
| if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_KEEPALIVE, 1); err != nil { | |
| return errors.New("failed to set SO_KEEPALIVE", err) | |
| } | |
| } else if config.TcpKeepAliveInterval < 0 || config.TcpKeepAliveIdle < 0 { | |
| if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_KEEPALIVE, 0); err != nil { | |
| return errors.New("failed to unset SO_KEEPALIVE", err) | |
| } | |
| } | |
| if config.TcpNoDelay { | |
| if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_NODELAY, 1); err != nil { | |
| return errors.New("failed to set TCP_NODELAY", err) | |
| } | |
| } | |
| } | |
| return nil | |
| } |
自己参考隔壁sb和v2,把 unix.SetsockoptInt 放到外面来,编译后运行会出现如下错误
2024/11/12 14:39:24 [Info] transport/internet: failed to apply socket options to incoming connection > transport/internet: failed to set Interface > invalid argument希望官方能把这个问题修复,这对XHTTP上下行分离还是挺实用的,以及tun2socks前置场景 (感觉更像feature reqest而不是bug report
重现方式
无
客户端配置
Details
{
"outbounds": [
{
"protocol": "vless",
"streamSettings": {
"sockopt": { "interface": "en0" },
"network": "splithttp",
"security": "tls",
"tlsSettings": { "serverName": "", "alpn": ["h3"], "fingerprint": "chrome", "allowInsecure": false },
"splithttpSettings": {
"path": "/",
"host": "",
"scMaxEachPostBytes": "100000-2000000",
"scMaxConcurrentPosts": "50-100",
"scMinPostsIntervalMs": "30-50",
"xPaddingBytes": "100-1000"
}
},
"mux": { "enabled": false },
"tag": "proxy",
"settings": {
"vnext": [
{
"address": "",
"users": [{ "id": "", "encryption": "none", "flow": "", "level": 0 }],
"port": 443
}
]
}
},
{
"tag": "direct",
"protocol": "freedom",
"settings": { "domainStrategy": "UseIP" },
"streamSettings": {
"sockopt": { "interface": "en0" }
}
}
]
}
服务端配置
无
客户端日志
无
服务端日志
无
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels