ITADN

[程序崩溃] TUN 入站 代理 udp 流量

#6279Opensimplerick-simplefun 创建于 2026-06-06
### 完整性要求 - [x] 我读完了 issue 模板中的所有注释,确保填写符合要求。 - [x] 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。 - [x] 我提供了完整的配置文件和日志,而不是出于自己的判断只给出截取的部分。 - [x] 我搜索了 issues, 没有发现已提出的类似问题。 - [x] 问题在 Release 最新的版本上可以成功复现 ### 描述 客户端,使用 TUN 入站,代理发送 udp 流量,有时会导致程序崩溃。 测试,出站为 vless 时无问题,出站为 hysteria2 或 dns 时,发生 程序崩溃 现象。 日志 1 的配置为,TUN入站 -> socks 出站 -> 本地socks入站 -> hysteria2 出站 日志 2 的配置为,TUN入站 -> hysteria2 出站 版本: Xray 26.6.1 (Xray, Penetrates Everything.) 94ffd50 (go1.26.3 windows/amd64) ### 重现方式 使用 TUN 入站,出站使用 dns 或 hysteria2。代理发送 udp 流量。例如 udp/53 dns 请求,或 quic 443。 ### 客户端配置 <details><pre><code> { "inbounds": [ { "tag": "in-tun", "protocol": "tun", "settings": { "name": "tun0", "mtu": 1400, "gateway": ["10.0.0.1/16", "fdfe::1/64"], "dns": ["1.1.1.1"], "userLevel": 0, "autoSystemRoutingTable": ["0.0.0.0/0", "::/0"], "autoOutboundsInterface": "auto" }, "sniffing": { "enabled": true, "destOverride": [ "http", "tls", "quic", "fakedns" ] } } ], "outbounds": [ { "tag": "out-direct", "protocol": "freedom", "settings": { "domainStrategy": "AsIs", "userLevel": 0 } }, { "tag": "out-proxy", "protocol": "hysteria", "settings": { "version": 2, "address": "x:x:x:x:x:x:x:x", "port": 443 }, "streamSettings": { "security": "tls", "tlsSettings": { "fingerprint": "firefox", "serverName": "y.y.com" }, "network": "hysteria", "hysteriaSettings": { "version": 2, "auth": "xxxxx" }, "finalmask": { "udp": [ ], "quicParams": { "congestion": "brutal", "bbrProfile": "aggressive", "brutalUp": "32 mbps", "brutalDown": "256 mbps" } } } } { "tag": "out-dns", "protocol": "dns", "settings": { "rewriteNetwork": "udp", "rewriteAddress": "1.1.1.1", "rewritePort": 53, "userLevel": 0, "rules": [ { "action": "return", "rCode": 5, "domain": ["geosite:category-ads-all", "wpad.DHCP HOST"] }, { "action": "hijack", "qtype": 1 }, { "action": "hijack", "qtype": 28 }, { "action": "direct", "domain": ["regexp:.*"] } ] } } ], "routing": { "domainStrategy": "IPOnDemand", "rules": [ { "ruleTag": "rule-catch-dns", "port": 53, "outboundTag": "out-dns" }, { "ruleTag": "rule-!cn-proxy", "domain": [ "geosite:geolocation-!cn" ], "outboundTag": "out-proxy" }, { "ruleTag": "rule-cn-direct", "domain": [ "geosite:cn" ], "outboundTag": "out-direct" }, { "ruleTag": "rule-ip-direct", "ip": [ "geoip:private", "geoip:cn" ], "outboundTag": "out-direct" }, { "ruleTag": "rule-default-proxy", "network": "tcp,udp", "outboundTag": "out-proxy" } ] } } </code></pre></details> ### 服务端配置 NONE ### 客户端日志 日志 1: ``` 2026/06/05 22:39:14.550883 [Info] [656051477] proxy/tun: processing from udp:10.0.0.1:63135 to udp:34.107.243.93:443 2026/06/05 22:39:14.552301 [Info] [656051477] app/dispatcher: Hit route rule: [rule-default-proxy] so taking detour [out#jp-osaka@oracle] for [udp:34.107.243.93:443] 2026/06/05 22:39:14.552815 [Info] [656051477] transport/internet/tcp: dialing TCP to tcp:127.0.0.1:59091 2026/06/05 22:39:14.552815 [Debug] [656051477] transport/internet: dialing to tcp:127.0.0.1:59091 2026/06/05 22:39:14.552815 from udp:10.0.0.1:63135 accepted udp:34.107.243.93:443 [in-tun -> out#jp-osaka@oracle] 2026/06/05 22:39:14.552815 [Debug] [656051477] transport/internet: dialing to udp:127.0.0.1:63136 2026/06/05 22:39:14.555173 [Info] [23791235] proxy/socks: client UDP connection from tcp:127.0.0.1:49687 2026/06/05 22:39:14.556098 [Debug] [23791235] proxy/socks: send packet to udp:34.107.243.93:443 with 1252 bytes 2026/06/05 22:39:14.556098 [Debug] [23791235] transport/internet/udp: dispatch request to: udp:34.107.243.93:443 2026/06/05 22:39:14.556613 [Info] [23791235] transport/internet/udp: establishing new connection for udp:34.107.243.93:443 2026/06/05 22:39:14.556613 [Debug] [23791235] proxy/socks: send packet to udp:34.107.243.93:443 with 1252 bytes 2026/06/05 22:39:14.556613 [Debug] [23791235] transport/internet/udp: dispatch request to: udp:34.107.243.93:443 2026/06/05 22:39:14.556613 [Info] [23791235] app/dispatcher: Hit route rule: [rule-bal-oosk] so taking detour [oosk-hy2-v6] for [udp:34.107.243.93:443] 2026/06/05 22:39:14.557191 [Info] [23791235] proxy/hysteria: tunneling request to udp:34.107.243.93:443 via UDP:[x:x:x:x:x:x:x:x]:443 2026/06/05 22:39:14.556098 from tcp:127.0.0.1:49687 accepted udp:34.107.243.93:443 [inbal-oosk -> oosk-hy2-v6] 2026/06/05 22:39:14.669508 [Debug] [23791235] proxy/socks: writing back UDP response with 43 bytes panic: Calling IP() on a DomainAddress. goroutine 69952 [running]: github.com/xtls/xray-core/common/net.domainAddress.IP(...) github.com/xtls/xray-core/common/net/address.go:172 github.com/xtls/xray-core/proxy/tun.(*stackGVisor).writeRawUDPPacket(0x1b809bba0f0, {0x1b80e2b0020, 0x2b, 0x1fe0}, {{0x7ff75b7ea0c8?, 0x1b8192b5580?}, 0x5d68?, 0x1b8?}, {{0x7ff75b7ea538, 0x1b813cd281c}, ...}) github.com/xtls/xray-core/proxy/tun/stack_gvisor.go:132 +0x74 github.com/xtls/xray-core/proxy/tun.(*udpConn).WriteMultiBuffer(0x1b8159d8d40, {0x1b8183125f8, 0x1, 0x1}) github.com/xtls/xray-core/proxy/tun/udp_fullcone.go:134 +0x137 github.com/xtls/xray-core/common/buf.copyInternal({0x7ff75b7d7340, 0x1b80dba1220}, {0x1fe62080068, 0x1b8159d8d40}, 0x1b8123568d0) github.com/xtls/xray-core/common/buf/copy.go:99 +0x15a github.com/xtls/xray-core/common/buf.Copy(...) github.com/xtls/xray-core/common/buf/copy.go:116 github.com/xtls/xray-core/proxy/socks.(*Client).Process.func7() github.com/xtls/xray-core/proxy/socks/client.go:161 +0x1aa github.com/xtls/xray-core/proxy/socks.(*Client).Process.OnSuccess.func12() github.com/xtls/xray-core/common/task/task.go:12 +0x22 github.com/xtls/xray-core/common/task.Run.func1(0x1b80f1c4d20?) github.com/xtls/xray-core/common/task/task.go:28 +0x28 created by github.com/xtls/xray-core/common/task.Run in goroutine 70052 github.com/xtls/xray-core/common/task/task.go:27 +0xdb ``` 日志 2: ``` 2026/06/06 18:32:05.237392 [Info] [1850638617] proxy/tun: processing from udp:[x:x:x:x:x:x:x:x]:59530 to udp:[y:y:y::1111]:53 2026/06/06 18:32:05.238153 [Info] [1850638617] app/dispatcher: Hit route rule: [rule-catch-dns] so taking detour [out-dns] for [udp:[y:y:y::1111]:53] 2026/06/06 18:32:05.238153 [Info] [1850638617] proxy/dns: handling DNS traffic to udp:1.1.1.1:53 2026/06/06 18:32:05.238703 [Info] [1850638617] proxy/dns: rejected type TypeAAAA query for domain wpad.DHCP HOST. 2026/06/06 18:32:05.238153 from udp:[x:x:x:x:x:x:x:x]:59530 accepted udp:[y:y:y::1111]:53 [in-tun -> out-dns] panic: Calling IP() on a DomainAddress. goroutine 2460 [running]: github.com/xtls/xray-core/common/net.domainAddress.IP(...) github.com/xtls/xray-core/common/net/address.go:172 github.com/xtls/xray-core/proxy/tun.(*stackGVisor).writeRawUDPPacket(0x18ea007fa4b0, {0x18ea09aca000, 0x4e4, 0x2000}, {{0x7ff730ddb2e8?, 0x18ea097732e0?}, 0x984?, 0x7ff7?}, {{0x7ff730ddb758, 0x18ea0aa19b28}, ...}) github.com/xtls/xray-core/proxy/tun/stack_gvisor.go:132 +0x74 github.com/xtls/xray-core/proxy/tun.(*udpConn).WriteMultiBuffer(0x18ea09c42640, {0x18ea03159d80, 0x1, 0x1}) github.com/xtls/xray-core/proxy/tun/udp_fullcone.go:134 +0x137 github.com/xtls/xray-core/common/buf.copyInternal({0x7ff730dc97c0, 0x18ea09aae380}, {0x1c9e5834708, 0x18ea09c42640}, 0x18ea09ad0030) github.com/xtls/xray-core/common/buf/copy.go:99 +0x15a github.com/xtls/xray-core/common/buf.Copy(...) github.com/xtls/xray-core/common/buf/copy.go:116 github.com/xtls/xray-core/proxy/hysteria.(*Client).Process.func5() github.com/xtls/xray-core/proxy/hysteria/client.go:148 +0x1da github.com/xtls/xray-core/proxy/hysteria.(*Client).Process.OnSuccess.func11() github.com/xtls/xray-core/common/task/task.go:12 +0x22 github.com/xtls/xray-core/common/task.Run.func1(0x18ea09778f4c?) github.com/xtls/xray-core/common/task/task.go:28 +0x28 created by github.com/xtls/xray-core/common/task.Run in goroutine 2424 github.com/xtls/xray-core/common/task/task.go:27 +0xdb ``` ### 服务端日志 NONE
3 条评论