From f2c7cb4e43008b1e1530b9920ead9cd68c50bb18 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 03a1a860..2078940d 100644 --- a/v2rayN/ServiceLib/Common/Utils.cs +++ b/v2rayN/ServiceLib/Common/Utils.cs @@ -427,11 +427,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 5df11976..fec5c524 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -825,7 +825,6 @@ public class CoreConfigSingboxService try { endpoints.address = Utils.String2List(node.RequestHost); - // Utils.GetFreePort() 9090 ? endpoints.listen_port = Utils.GetFreePort(); endpoints.type = Global.ProtocolTypes[node.ConfigType];