Utils.GetFreePort() default port to be zero

DHR60 2025-04-11 19:33:51 +08:00
parent 98d3ba38cb
commit 6311a72387
2 changed files with 2 additions and 3 deletions

View File

@ -435,11 +435,11 @@ public class Utils
return false;
}
public static int GetFreePort(int defaultPort = 9090)
public static int GetFreePort(int defaultPort = 0)
{
try
{
if (!Utils.PortInUse(defaultPort))
if (!(defaultPort == 0 || Utils.PortInUse(defaultPort)))
{
return defaultPort;
}

View File

@ -785,7 +785,6 @@ public class CoreConfigSingboxService
try
{
endpoint.address = Utils.String2List(node.RequestHost);
// Utils.GetFreePort() 9090 ?
endpoint.listen_port = Utils.GetFreePort();
endpoint.type = Global.ProtocolTypes[node.ConfigType];