From 26a86f9bd2015c20ebd316d20aee3f04c575ba7f Mon Sep 17 00:00:00 2001 From: DHR60 <192860629+DHR60@users.noreply.github.com> Date: Sat, 22 Aug 2026 02:17:09 +0000 Subject: [PATCH] Fix (#10002) --- v2rayN/ServiceLib/Handler/ConfigHandler.cs | 19 ++++++++----------- v2rayN/ServiceLib/Handler/Fmt/SingboxFmt.cs | 2 +- v2rayN/ServiceLib/Handler/Fmt/V2rayFmt.cs | 2 +- .../Singbox/SingboxConfigTemplateService.cs | 3 ++- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index 308c86f9..f9a95c6f 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -1797,21 +1797,18 @@ public static class ConfigHandler { ECoreType.Xray => V2rayFmt.ResolveToCustom(strData, subRemarks), ECoreType.sing_box => SingboxFmt.ResolveToCustom(strData, subRemarks), - _ => null + _ => null, }; - if (lstProfiles is not null) + if ((lstProfiles?.Count ?? 0) == 0) { - if (lstProfiles.Count == 0) - { - return -1; - } + return -1; + } - var count = await AddBatchCustomServers(config, lstProfiles, subid, isSub); - if (count > 0) - { - return count; - } + var count = await AddBatchCustomServers(config, lstProfiles, subid, isSub); + if (count > 0) + { + return count; } return await SaveCustomRawFileServer(config, strData, subid, isSub, subItem, customCoreType); diff --git a/v2rayN/ServiceLib/Handler/Fmt/SingboxFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/SingboxFmt.cs index f8b36773..64a51a30 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/SingboxFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/SingboxFmt.cs @@ -34,9 +34,9 @@ public class SingboxFmt : BaseFmt if (!isOutbound) { var fullProfile = ResolveFull(jsonObject, subRemarks); - profileList.Add(fullProfile); if (fullProfile is not null) { + profileList.Add(fullProfile); return profileList; } } diff --git a/v2rayN/ServiceLib/Handler/Fmt/V2rayFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/V2rayFmt.cs index bd014165..1290a0a7 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/V2rayFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/V2rayFmt.cs @@ -34,9 +34,9 @@ public class V2rayFmt : BaseFmt if (!isOutbound) { var fullProfile = ResolveFull(jsonObject, subRemarks); - profileList.Add(fullProfile); if (fullProfile is not null) { + profileList.Add(fullProfile); return profileList; } } diff --git a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxConfigTemplateService.cs b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxConfigTemplateService.cs index c08c29c6..df4117f8 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxConfigTemplateService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxConfigTemplateService.cs @@ -125,7 +125,8 @@ public partial class CoreConfigSingboxService fullConfigTemplateNode["outbounds"] = customOutboundsNode; // Process endpoints - if (fullConfigTemplateNode["endpoints"] is JsonArray { Count: > 0 } coreConfigEndpointsNode) + var coreConfigEndpointsNode = coreConfigNode?["endpoints"] as JsonArray ?? []; + if (coreConfigEndpointsNode is { Count: > 0 }) { var customEndpointsNode = fullConfigTemplateNode["endpoints"] as JsonArray ?? []; foreach (var endpoint in coreConfigEndpointsNode)