Utils.GetFreePort() default port to be zero

DHR60 2025-04-11 19:33:51 +08:00
parent 85b7a728ed
commit 225ca1f2e5
2 changed files with 2 additions and 3 deletions

View File

@ -466,11 +466,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

@ -790,7 +790,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];