fix(connector/relay): handle empty address in bind to fix UDP ASSOCIATE

Fixes a bug where an empty bind address (as in SOCKS5 UDP ASSOCIATE) bypassed the SplitHostPort guard and passed `""` to `AddrFeature.ParseFrom`, which returns an error for empty hosts. Default to `0.0.0.0:0` (any address, any port) when address is empty.
This commit is contained in:
PahaKush
2026-06-26 20:48:47 +09:00
committed by GitHub
parent b777bcb81a
commit d4e9450bad
+3 -1
View File
@@ -106,7 +106,9 @@ func (c *relayConnector) bind(conn net.Conn, cmd relay.CmdType, network, address
})
fa := &relay.AddrFeature{}
if network != "unix" {
if h, _, e := net.SplitHostPort(address); e == nil && h == "" {
if address == "" {
address = "0.0.0.0:0"
} else if h, _, e := net.SplitHostPort(address); e == nil && h == "" {
address = net.JoinHostPort("0.0.0.0", address)
}
}