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:
@@ -106,9 +106,11 @@ func (c *relayConnector) bind(conn net.Conn, cmd relay.CmdType, network, address
|
|||||||
})
|
})
|
||||||
fa := &relay.AddrFeature{}
|
fa := &relay.AddrFeature{}
|
||||||
if network != "unix" {
|
if network != "unix" {
|
||||||
if h, _, e := net.SplitHostPort(address); e == nil && h == "" {
|
if address == "" {
|
||||||
address = net.JoinHostPort("0.0.0.0", 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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fa.ParseFrom(address)
|
fa.ParseFrom(address)
|
||||||
req.Features = append(req.Features, fa)
|
req.Features = append(req.Features, fa)
|
||||||
|
|||||||
Reference in New Issue
Block a user