Fix port "0" listen

This commit is contained in:
Fangliding
2026-08-18 01:01:09 +08:00
parent 6e3322d219
commit be10221454
2 changed files with 3 additions and 3 deletions
-3
View File
@@ -42,9 +42,6 @@ func ListenTCP(ctx context.Context, address net.Address, port net.Port, streamSe
var listener net.Listener
var err error
if port == net.Port(0) { // unix
if !address.Family().IsDomain() {
return nil, errors.New("invalid unix listen: ", address).AtError()
}
listener, err = internet.ListenSystem(ctx, &net.UnixAddr{
Name: address.Domain(),
Net: "unix",
+3
View File
@@ -65,6 +65,9 @@ func ListenTCP(ctx context.Context, address net.Address, port net.Port, settings
if address.Family().IsDomain() {
return nil, errors.New("domain address is not allowed for listening: ", address.Domain())
}
if port == 0 {
return nil, errors.New("port 0 is not allowed for listening on TCP")
}
protocol := settings.ProtocolName
listenFunc := transportListenerCache[protocol]