From 994bc1ca6ac984554584dfc62038126616f8b94f Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 11 Jul 2026 17:43:32 +0800 Subject: [PATCH] Code clean --- v2rayN/ServiceLib/Handler/ConfigHandler.cs | 2 +- v2rayN/ServiceLib/Manager/CertPemManager.cs | 2 + v2rayN/ServiceLib/Manager/CoreManager.cs | 2 + v2rayN/ServiceLib/Resx/ResUI.Designer.cs | 40 +++++++++---------- .../CoreConfig/V2ray/V2rayOutboundService.cs | 2 +- v2rayN/ServiceLib/Services/DownloadService.cs | 1 - 6 files changed, 26 insertions(+), 23 deletions(-) diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index f1fc385f..9f401fba 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -164,7 +164,7 @@ public static class ConfigHandler config.ClashUIItem.ConnectionsColumnItem ??= []; config.SystemProxyItem ??= new(); config.WebDavItem ??= new(); - config.CheckUpdateItem ??= new(); + config.CheckUpdateItem ??= new(); config.Fragment4RayItem ??= new() { Packets = "tlshello", diff --git a/v2rayN/ServiceLib/Manager/CertPemManager.cs b/v2rayN/ServiceLib/Manager/CertPemManager.cs index b655c33c..adb48368 100644 --- a/v2rayN/ServiceLib/Manager/CertPemManager.cs +++ b/v2rayN/ServiceLib/Manager/CertPemManager.cs @@ -288,6 +288,7 @@ public class CertPemManager collection.ImportFromPem(pemText); return collection; }); + private static readonly Lazy _mozillaRootCerts = new(() => { var pemText = EmbedUtils.GetEmbedText(Global.MozillaRootCertFileName); @@ -295,6 +296,7 @@ public class CertPemManager collection.ImportFromPem(pemText); return collection; }); + private X509Certificate2Collection BuildTrustedCertificateCollection() { if (_config.GuiItem.RootCertProvider == Global.ChromeRootProvider) diff --git a/v2rayN/ServiceLib/Manager/CoreManager.cs b/v2rayN/ServiceLib/Manager/CoreManager.cs index 6453c90d..7610673c 100644 --- a/v2rayN/ServiceLib/Manager/CoreManager.cs +++ b/v2rayN/ServiceLib/Manager/CoreManager.cs @@ -8,8 +8,10 @@ public class CoreManager private static readonly Lazy _instance = new(() => new()); public static CoreManager Instance => _instance.Value; private Config _config; + [SupportedOSPlatform("windows")] private WindowsJobService? _processJob; + private ProcessService? _processService; private ProcessService? _processPreService; private bool _linuxSudo = false; diff --git a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs index c6b6ca47..18403692 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs +++ b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs @@ -149,7 +149,7 @@ namespace ServiceLib.Resx { return ResourceManager.GetString("Downloading", resourceCulture); } } - + /// /// 查找类似 Failed to convert configuration file 的本地化字符串。 /// @@ -321,6 +321,15 @@ namespace ServiceLib.Resx { } } + /// + /// 查找类似 Please enter valid HTTP request headers JSON. 的本地化字符串。 + /// + public static string InvalidHttpOutboundHeaders { + get { + return ResourceManager.GetString("InvalidHttpOutboundHeaders", resourceCulture); + } + } + /// /// 查找类似 Invalid Realm URL. 的本地化字符串。 /// @@ -330,15 +339,6 @@ namespace ServiceLib.Resx { } } - /// - /// 查找类似 Please enter valid HTTP request headers JSON. 的本地化字符串。 - /// - public static string InvalidHttpOutboundHeaders { - get { - return ResourceManager.GetString("InvalidHttpOutboundHeaders", resourceCulture); - } - } - /// /// 查找类似 Invalid address (URL) 的本地化字符串。 /// @@ -3231,15 +3231,6 @@ namespace ServiceLib.Resx { } } - /// - /// 查找类似 HTTP headers 的本地化字符串。 - /// - public static string TbHttpOutboundHeaders { - get { - return ResourceManager.GetString("TbHttpOutboundHeaders", resourceCulture); - } - } - /// /// 查找类似 Port hopping interval 的本地化字符串。 /// @@ -3258,6 +3249,15 @@ namespace ServiceLib.Resx { } } + /// + /// 查找类似 HTTP headers 的本地化字符串。 + /// + public static string TbHttpOutboundHeaders { + get { + return ResourceManager.GetString("TbHttpOutboundHeaders", resourceCulture); + } + } + /// /// 查找类似 Realm URL 的本地化字符串。 /// @@ -5012,7 +5012,7 @@ namespace ServiceLib.Resx { return ResourceManager.GetString("TipHttpOutboundHeaders", resourceCulture); } } - + /// /// 查找类似 *Default value raw 的本地化字符串。 /// diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs index acd87e50..8b98fe10 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs @@ -175,7 +175,7 @@ public partial class CoreConfigV2rayService outbound.settings.address = _node.Address; outbound.settings.port = _node.Port; - if(protocolExtra.HttpHeaders.IsNotEmpty()) + if (protocolExtra.HttpHeaders.IsNotEmpty()) { outbound.settings.headers = JsonUtils.ParseJson(protocolExtra.HttpHeaders); } diff --git a/v2rayN/ServiceLib/Services/DownloadService.cs b/v2rayN/ServiceLib/Services/DownloadService.cs index 5a115d58..14129c36 100644 --- a/v2rayN/ServiceLib/Services/DownloadService.cs +++ b/v2rayN/ServiceLib/Services/DownloadService.cs @@ -1,5 +1,4 @@ using System.Net.Http.Headers; -using System.Reflection.Metadata; namespace ServiceLib.Services;