fix: handle empty host in relay AddrFeature ParseFrom for bind addresses

When rtcp listener calls Router.Bind with ":8000" (port-only address),
the relay AddrFeature.ParseFrom fails because net.SplitHostPort returns
an empty host. This leaves AType at default 0, causing AddrFeature.Encode
to return ErrBadAddrType.

Fix by normalizing port-only addresses to "0.0.0.0:<port>" in both tunnel
and relay connectors before ParseFrom. Also fix error check on
resp.WriteTo in the tunnel handler's handleBind to prevent silent
protocol desync.
This commit is contained in:
ginuerzh
2026-05-31 16:00:14 +08:00
parent e543c0b0fd
commit b8d9c79f72
3 changed files with 11 additions and 2 deletions
+3
View File
@@ -102,6 +102,9 @@ func (c *relayConnector) bind(conn net.Conn, cmd relay.CmdType, network, address
Network: nid,
})
fa := &relay.AddrFeature{}
if h, _, e := net.SplitHostPort(address); e == nil && h == "" {
address = net.JoinHostPort("0.0.0.0", address)
}
fa.ParseFrom(address)
req.Features = append(req.Features, fa)
if _, err := req.WriteTo(conn); err != nil {