mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-09-20 08:15:48 +00:00
Fix port "0" listen
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user