UDP listener: Allow listening on "localhost" (#4940)

Fixes https://github.com/XTLS/Xray-core/issues/4939
This commit is contained in:
风扇滑翔翼 2025-07-26 09:27:35 +08:00 committed by GitHub
parent cfcf2a63d1
commit 1ea00fad81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -40,6 +40,14 @@ func ListenUDP(ctx context.Context, address net.Address, port net.Port, streamSe
opt(hub)
}
if address.Family().IsDomain() && address.Domain() == "localhost" {
address = net.LocalHostIP
}
if address.Family().IsDomain() {
return nil, errors.New("domain address is not allowed for listening: ", address.Domain())
}
var sockopt *internet.SocketConfig
if streamSettings != nil {
sockopt = streamSettings.SocketSettings