Repository navigation
Description
完整性要求
- 我读完了 issue 模板中的所有注释,确保填写符合要求。
- 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
- 我提供了完整的配置文件和日志,而不是出于自己的判断只给出截取的部分。
- 我搜索了 issues, 没有发现已提出的类似问题。
- 问题在 Release 最新的版本上可以成功复现
描述
之前记错了,并不是socks协议使用用户密码验证时不能代理udp,而是socks协议的udp流量不能通过路由中的“user”来分流,tcp流量通过路由中的“user”分流是没问题的,,
如果使用"inboudTag"来分流是没有问题的。
通过NatTypeTester来测试发现此问题的。
所以只能换用vless+no encryption来内网传输了,经测试用vless无论tcp流量还是udp流量路由中使用“user”分流都是可以正常分流的,,不过鉴于未来版本可能将移除vless+no encryption,所以还是来发这个issue。
重现方式
比如如下客户端的配置,默认outbound为block,路由中使用“user”分流socks的流量到proxy,经测试只有tcp流量能正常分流,udp流量走默认outbound也就是block了。
经测试无论是客户端windows上的xray.exe还是服务端linux上的xray,只要是类似配置路由中使用“user”分流都存在这个问题。
客户端配置
"inbounds":
[
{
"tag": "inbound",
"port": 10802,
"listen": "127.0.0.1",
"protocol": "socks",
"settings":
{
"auth": "password",
"users":
[
{
"user": "user",
"pass": "pass"
}
],
"udp": true
},
"sniffing":
{
"enabled": true,
"destOverride": [ "http", "tls", "quic", "fakedns" ],
"routeOnly": true
}
}
],
"routing":
{
"rules":
[
{
"domain": [ "geosite:cn", "geosite:private" ],
"outboundTag": "direct"
},
{
"ip": [ "geoip:cn", "geoip:private" ],
"outboundTag": "direct"
},
{
"network": "udp",
"port": 443,
"outboundTag": "block"
},
{
"user": [ "user" ],
"outboundTag": "proxy"
}/*,
{
"inboundTag": [ "inbound" ],
"outboundTag": "proxy"
}*/
]
},
"outbounds":
[
{
"tag": "block",
"protocol": "block"
},
{
"tag": "direct",
"protocol": "direct"
},
{
"tag": "proxy",
......
}
]
服务端配置
无需提供
客户端日志
access.log
2026/05/16 17:52:19.253400 from tcp:127.0.0.1:12564 accepted tcp:api.github.com:443 [inbound -> proxy]
2026/05/16 17:52:31.004910 from udp:127.0.0.1:54268 accepted udp:49.12.125.53:3478 [inbound >> block]
2026/05/16 17:52:35.601348 from tcp:127.0.0.1:9555 accepted tcp:49.12.125.53:3478 [inbound -> proxy]
2026/05/16 17:52:36.185395 from tcp:127.0.0.1:9555 accepted tcp:49.12.125.24:3478 [inbound -> proxy]
2026/05/16 17:52:36.931342 from tcp:127.0.0.1:9555 accepted tcp:49.12.125.24:3479 [inbound -> proxy]
2026/05/16 17:52:40.282334 from udp:127.0.0.1:63170 accepted udp:49.12.125.53:3478 [inbound >> block]
error.log
2026/05/16 17:52:13.428414 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:10802
2026/05/16 17:52:13.428414 [Info] transport/internet/udp: listening UDP on 127.0.0.1:10802
2026/05/16 17:52:13.428414 [Warning] core: Xray 26.5.9 started
2026/05/16 17:52:19.227827 [Info] [3814039331] proxy/socks: TCP Connect request to tcp:api.github.com:443
2026/05/16 17:52:19.253400 [Info] [3814039331] app/dispatcher: sniffed domain: api.github.com
2026/05/16 17:52:19.253400 [Info] [3814039331] app/dispatcher: taking detour [proxy] for [tcp:api.github.com:443]
2026/05/16 17:52:19.340585 [Info] [3814039331] transport/internet/splithttp: XHTTP is dialing to udp:mydomain:443, mode packet-up, HTTP version 3, host mydomain
2026/05/16 17:52:19.457316 [Info] [3814039331] proxy/vless/outbound: tunneling request to tcp:api.github.com:443 via mydomain:443
2026/05/16 17:52:31.004910 [Info] [1978250581] proxy/socks: client UDP connection from udp:127.0.0.1:54268
2026/05/16 17:52:31.004910 [Info] [1978250581] transport/internet/udp: establishing new connection for udp:49.12.125.53:3478
2026/05/16 17:52:31.004910 [Info] [1978250581] app/dispatcher: default route for udp:49.12.125.53:3478
2026/05/16 17:52:35.600845 [Info] [1436704621] proxy/socks: TCP Connect request to tcp:49.12.125.53:3478
2026/05/16 17:52:35.601348 [Info] [1436704621] app/dispatcher: taking detour [proxy] for [tcp:49.12.125.53:3478]
2026/05/16 17:52:35.601348 [Info] [1436704621] transport/internet/splithttp: XHTTP is dialing to udp:mydomain:443, mode packet-up, HTTP version 3, mydomain
2026/05/16 17:52:35.601348 [Info] [1436704621] proxy/vless/outbound: tunneling request to tcp:49.12.125.53:3478 via mydomain:443
2026/05/16 17:52:36.183813 [Info] [1436704621] app/proxyman/outbound: app/proxyman/outbound: failed to process outbound traffic > proxy/vless/outbound: connection ends > proxy/vless/outbound: failed to transfer request payload > read tcp 127.0.0.1:10802->127.0.0.1:9555: wsarecv: An existing connection was forcibly closed by the remote host.
2026/05/16 17:52:36.185395 [Info] [3225896517] proxy/socks: TCP Connect request to tcp:49.12.125.24:3478
2026/05/16 17:52:36.185395 [Info] [3225896517] app/dispatcher: taking detour [proxy] for [tcp:49.12.125.24:3478]
2026/05/16 17:52:36.185395 [Info] [3225896517] transport/internet/splithttp: XHTTP is dialing to udp:mydomain:443, mode packet-up, HTTP version 3, host mydomain
2026/05/16 17:52:36.185914 [Info] [3225896517] proxy/vless/outbound: tunneling request to tcp:49.12.125.24:3478 via mydomain:443
2026/05/16 17:52:36.930262 [Info] [3225896517] app/proxyman/outbound: app/proxyman/outbound: failed to process outbound traffic > proxy/vless/outbound: connection ends > proxy/vless/outbound: failed to transfer request payload > read tcp 127.0.0.1:10802->127.0.0.1:9555: wsarecv: An existing connection was forcibly closed by the remote host.
2026/05/16 17:52:36.930828 [Info] [291629771] proxy/socks: TCP Connect request to tcp:49.12.125.24:3479
2026/05/16 17:52:36.931342 [Info] [291629771] app/dispatcher: taking detour [proxy] for [tcp:49.12.125.24:3479]
2026/05/16 17:52:36.931342 [Info] [291629771] transport/internet/splithttp: XHTTP is dialing to udp:mydomain:443, mode packet-up, HTTP version 3, host mydomain
2026/05/16 17:52:36.931342 [Info] [291629771] proxy/vless/outbound: tunneling request to tcp:49.12.125.24:3479 via mydomain:443
2026/05/16 17:52:37.710969 [Info] [291629771] app/proxyman/outbound: app/proxyman/outbound: failed to process outbound traffic > proxy/vless/outbound: connection ends > proxy/vless/outbound: failed to transfer request payload > read tcp 127.0.0.1:10802->127.0.0.1:9555: wsarecv: An existing connection was forcibly closed by the remote host.
2026/05/16 17:52:40.282334 [Info] [899674809] proxy/socks: client UDP connection from udp:127.0.0.1:63170
2026/05/16 17:52:40.282334 [Info] [899674809] transport/internet/udp: establishing new connection for udp:49.12.125.53:3478
2026/05/16 17:52:40.282334 [Info] [899674809] app/dispatcher: default route for udp:49.12.125.53:3478
服务端日志
无需提供
Activity
RPRX commentedon May 16, 2026
目前 Xray-core Socks5 服务端实现的 UDP 是固定端口、不区分用户的,只有个启用密码时根据 TCP 请求来过滤的“来源 IP 白名单”
Xray-core/proxy/socks/server.go
Lines 172 to 192 in 1bdb488
而标准的 Socks5 服务端需要新开一个随机 UDP 端口来接收 UDP 流量,可以做到“区分用户”,所以 PR welcome
Fangliding commentedon May 16, 2026
尝试一下 https://github.com/XTLS/Xray-core/actions/runs/25970332300 ?
GleenJi commentedon May 17, 2026
只试了windows端,这个没问题了,udp流量可以根据"user"正常分流了
Socks5 server: More standard UDP ASSOCIATE (RFC 1928) (XTLS#6149)
Squashed commit of the following:
Socks5 server: More standard UDP ASSOCIATE (RFC 1928) (#6149)