Utils.GetFreePort() default port to be zero

This commit is contained in:
DHR60 2025-04-11 19:33:51 +08:00
parent b938538926
commit f2c7cb4e43
2 changed files with 2 additions and 3 deletions

View file

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

View file

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