From 225ca1f2e53f1656b92fa81ae7a7c9146d39d83c Mon Sep 17 00:00:00 2001 From: DHR60 Date: Fri, 11 Apr 2025 19:33:51 +0800 Subject: [PATCH] Utils.GetFreePort() default port to be zero --- v2rayN/ServiceLib/Common/Utils.cs | 4 ++-- .../Services/CoreConfig/CoreConfigSingboxService.cs | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs index 63540ee2..369cc0f4 100644 --- a/v2rayN/ServiceLib/Common/Utils.cs +++ b/v2rayN/ServiceLib/Common/Utils.cs @@ -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; } diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index 85adfd28..5b110136 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -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];