XTLS / Xray-core

Xray, Penetrates Everything. Also the best v2ray-core, with XTLS support. Fully compatible configuration.
https://t.me/projectXray
Mozilla Public License 2.0
22.85k stars 3.66k forks source link

panic: Calling IP() on a DomainAddress #116

Open maskedeken opened 3 years ago

maskedeken commented 3 years ago

在往buf.Buffer的UDP属性赋值的时候,创建 &net.UDPAddr{ IP: addr.IP(), Port: int(port.Value()), }

但这里的addr是从addrParser.ReadAddressPort()而来,这里的addr有可能是域名,如果直接调用addr.IP(),会直接panic

func (domainAddress) IP() net.IP { panic("Calling IP() on a DomainAddress.") }

RPRX commented 3 years ago

两天前的提交已经修复 https://github.com/XTLS/Xray-core/commit/13ad3fddf6f7ff01fe9541b6c9f2dca6f7f87e4b

(不过最新的 commit 有问题,等下会 force

maskedeken commented 3 years ago

怎么解决循环引用的问题?

RPRX commented 3 years ago

怎么解决循环引用的问题?

https://github.com/XTLS/Xray-core/commit/6bcac6cb1016295a0722015ec853ece135766cc3

RPRX commented 3 years ago

如果发现存在其它问题,也请直接反馈

比如目前发现任意门 TPROXY 那里不能缓存 conns,只能发一个包就 close,否则行为会异常,等下打算看看把 dial 改为 listen 的表现

z719893361 commented 1 year ago

问题修复了吗,我用最新版碰到了相同的问题 我想大概是使用TPROXY转发UDP流量导致,使用tun2socks转发不会出现这类问题。

mmmray commented 2 months ago

I encountered this issue just now on xray 1.8.10

unfortunately i have nothing useful to reproduce it with. the server config has been running fine for a very long time before then, so i suspect it is somehow triggered by traffic and not the config itself. but i also don't know which protocol.

stacktrace ``` panic: Calling IP() on a DomainAddress. goroutine 10315396 [running]: github.com/xtls/xray-core/common/net.domainAddress.IP(...) github.com/xtls/xray-core/common/net/address.go:164 github.com/xtls/xray-core/features/routing/session.(*Context).GetTargetIPs(0xc00cfb1290) github.com/xtls/xray-core/features/routing/session/context.go:54 +0x5f github.com/xtls/xray-core/app/router.(*MultiGeoIPMatcher).Apply(0xc0003bc4e0, {0x1549850?, 0xc00cfb1290?}) github.com/xtls/xray-core/app/router/condition.go:142 +0x3e github.com/xtls/xray-core/app/router.(*ConditionChan).Apply(0x8?, {0x1549850, 0xc00cfb1290}) github.com/xtls/xray-core/app/router/condition.go:31 +0x5c github.com/xtls/xray-core/app/router.(*Rule).Apply(...) github.com/xtls/xray-core/app/router/config.go:28 github.com/xtls/xray-core/app/router.(*Router).pickRouteInternal(0xc0003a1260, {0x1549850, 0xc00cfb1290}) github.com/xtls/xray-core/app/router/router.go:195 +0x176 github.com/xtls/xray-core/app/router.(*Router).PickRoute(0x15402b8?, {0x1549850?, 0xc00cfb1290?}) github.com/xtls/xray-core/app/router/router.go:83 +0x25 github.com/xtls/xray-core/app/dispatcher.(*DefaultDispatcher).routedDispatch(0xc00039d8c0, {0x15402b8, 0xc009bfa570}, 0xc00bdaa360, {{0x1540440, 0xc00b6dc204}, 0x1bb, 0x2}) github.com/xtls/xray-core/app/dispatcher/default.go:403 +0x2e2 github.com/xtls/xray-core/app/dispatcher.(*DefaultDispatcher).Dispatch.func1() github.com/xtls/xray-core/app/dispatcher/default.go:266 +0x3f9 created by github.com/xtls/xray-core/app/dispatcher.(*DefaultDispatcher).Dispatch in goroutine 10315389 github.com/xtls/xray-core/app/dispatcher/default.go:239 +0x40b ```
config (users, wireguard credentials and http paths redacted) ``` { "inbounds": [ { "listen": "0.0.0.0", "port": 42007, "protocol": "socks", "settings": { "auth": "password", "accounts": [ ], "udp": true, "userLevel": 8 }, "sniffing": { "destOverride": [ "http", "tls" ], "enabled": true }, "tag": "socks" }, { "port": 42003, "listen": "0.0.0.0", "protocol": "vmess", "sniffing": { "enabled": true, "destOverride": [ "http", "tls" ] }, "settings": { "clients": [ ] }, "streamSettings": { "network": "ws", "wsSettings": { "path": "/xxx" } } }, { "port": 42005, "listen": "0.0.0.0", "protocol": "vmess", "sniffing": { "enabled": true, "destOverride": [ "http", "tls" ] }, "settings": { "clients": [ ] }, "streamSettings": { "network": "grpc", "grpcSettings": { "serviceName": "xxx" } } }, { "port": 42006, "listen": "0.0.0.0", "protocol": "vmess", "sniffing": { "enabled": true, "destOverride": [ "http", "tls" ] }, "settings": { "clients": [ ] }, "streamSettings": { "network": "httpupgrade", "httpUpgradeSettings": { "path": "/xxx" } } } ], "outbounds": [ { "protocol": "wireguard", }, { "protocol": "blackhole", "settings": {}, "tag": "block" } ], "routing": { "domainStrategy": "AsIs", "rules": [ { "type": "field", "outboundTag": "block", "protocol": [ "bittorrent" ] }, { "type": "field", "outboundTag": "block", "ip": [ "0.0.0.0/8", "10.0.0.0/8", "100.64.0.0/10", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24", "192.0.2.0/24", "192.88.99.0/24", "192.168.0.0/16", "198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "224.0.0.0/4", "233.252.0.0/24", "240.0.0.0/4", "255.255.255.255/32" ] } ] }, "log": { "access": "none", "error": "", "loglevel": "error" } } ```
mmmray commented 1 month ago

It occurs with 1.8.13 as well. Stacktrace is the same.

Is it reasonable to think the broken address comes from a specific inbound? I can try to remove inbounds from production (or rather, move them to a secondary xray container) until the problem stops occurring, but would like to know if it's worth the effort.

currently the issue only happens 2-3 times per day, so it's kind of fine with autorestart.

somebodywashere commented 1 month ago

Also had this a few times on one server. Can you by any chance have any outbound with ForceIP?

I didn't checked the code but I didn't see this error anymore when I removed plain ForceIP from outbound (ForceIPv4v6 & ForceIPv6v4 is ok for me)

mmmray commented 1 month ago

i posted my full config above, no I don't use any variant of ForceIP.

somebodywashere commented 1 month ago

i posted my full config above, no I don't use any variant of ForceIP.

Oh, sorry, didn't pay enough attention. Now I see. That's strange than.

If I encounter that once more I'll get back with additional info.