From 3e74bb65bd9922ad822681e63645955bb2a8e7f8 Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Tue, 8 Oct 2024 09:50:03 +0800
Subject: [PATCH] Improved models

---
 v2rayN/ServiceLib/Handler/ConfigHandler.cs    | 242 ++++--------------
 v2rayN/ServiceLib/Handler/CoreHandler.cs      |   2 +-
 v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs     |   2 +-
 .../ServiceLib/Models/ClashConnectionModel.cs |  16 +-
 v2rayN/ServiceLib/Models/ClashConnections.cs  |  30 +--
 v2rayN/ServiceLib/Models/ClashProviders.cs    |  10 +-
 v2rayN/ServiceLib/Models/ClashProxies.cs      |  14 +-
 v2rayN/ServiceLib/Models/ClashProxyModel.cs   |   8 +-
 v2rayN/ServiceLib/Models/ComboItem.cs         |   4 +-
 v2rayN/ServiceLib/Models/Config.cs            |   2 -
 v2rayN/ServiceLib/Models/GitHubRelease.cs     |  34 +--
 v2rayN/ServiceLib/Models/ServerTestItem.cs    |  12 +-
 v2rayN/ServiceLib/Models/SsSIP008.cs          |  14 +-
 v2rayN/ServiceLib/Models/SysProxyConfig.cs    |  20 --
 .../CoreConfig/CoreConfigSingboxService.cs    |  14 +-
 .../CoreConfig/CoreConfigV2rayService.cs      |  14 +-
 .../ServiceLib/Services/SpeedtestService.cs   |  82 +++---
 17 files changed, 176 insertions(+), 344 deletions(-)
 delete mode 100644 v2rayN/ServiceLib/Models/SysProxyConfig.cs

diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs
index 5dd97d63..16dbfc58 100644
--- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs
+++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs
@@ -9,8 +9,8 @@ namespace ServiceLib.Handler
     /// </summary>
     public class ConfigHandler
     {
-        private static string configRes = Global.ConfigFileName;
-        private static readonly object objLock = new();
+        private static readonly string _configRes = Global.ConfigFileName;
+        private static readonly object _objLock = new();
 
         #region ConfigHandler
 
@@ -21,39 +21,29 @@ namespace ServiceLib.Handler
         /// <returns></returns>
         public static int LoadConfig(ref Config? config)
         {
-            //载入配置文件
-            var result = Utils.LoadResource(Utils.GetConfigPath(configRes));
+            var result = Utils.LoadResource(Utils.GetConfigPath(_configRes));
             if (Utils.IsNotEmpty(result))
             {
-                //转成Json
                 config = JsonUtils.Deserialize<Config>(result);
             }
             else
             {
-                if (File.Exists(Utils.GetConfigPath(configRes)))
+                if (File.Exists(Utils.GetConfigPath(_configRes)))
                 {
                     Logging.SaveLog("LoadConfig Exception");
                     return -1;
                 }
             }
 
-            if (config == null)
-            {
-                config = new Config
-                {
-                };
-            }
-            if (config.coreBasicItem == null)
-            {
-                config.coreBasicItem = new()
-                {
-                    logEnabled = false,
-                    loglevel = "warning",
-                    muxEnabled = false,
-                };
-            }
+            config ??= new Config();
+
+            config.coreBasicItem ??= new()
+            {
+                logEnabled = false,
+                loglevel = "warning",
+                muxEnabled = false,
+            };
 
-            //本地监听
             if (config.inbound == null)
             {
                 config.inbound = new List<InItem>();
@@ -75,55 +65,38 @@ namespace ServiceLib.Handler
                     config.inbound[0].protocol = EInboundProtocol.socks.ToString();
                 }
             }
-            if (config.routingBasicItem == null)
+            config.routingBasicItem ??= new()
             {
-                config.routingBasicItem = new()
-                {
-                    enableRoutingAdvanced = true
-                };
-            }
-            //路由规则
+                enableRoutingAdvanced = true
+            };
+
             if (Utils.IsNullOrEmpty(config.routingBasicItem.domainStrategy))
             {
                 config.routingBasicItem.domainStrategy = Global.DomainStrategies[0];//"IPIfNonMatch";
             }
-            //if (Utile.IsNullOrEmpty(config.domainMatcher))
-            //{
-            //    config.domainMatcher = "linear";
-            //}
 
-            //kcp
-            if (config.kcpItem == null)
+            config.kcpItem ??= new KcpItem
             {
-                config.kcpItem = new KcpItem
-                {
-                    mtu = 1350,
-                    tti = 50,
-                    uplinkCapacity = 12,
-                    downlinkCapacity = 100,
-                    readBufferSize = 2,
-                    writeBufferSize = 2,
-                    congestion = false
-                };
-            }
-            if (config.grpcItem == null)
+                mtu = 1350,
+                tti = 50,
+                uplinkCapacity = 12,
+                downlinkCapacity = 100,
+                readBufferSize = 2,
+                writeBufferSize = 2,
+                congestion = false
+            };
+            config.grpcItem ??= new GrpcItem
             {
-                config.grpcItem = new GrpcItem
-                {
-                    idle_timeout = 60,
-                    health_check_timeout = 20,
-                    permit_without_stream = false,
-                    initial_windows_size = 0,
-                };
-            }
-            if (config.tunModeItem == null)
+                idle_timeout = 60,
+                health_check_timeout = 20,
+                permit_without_stream = false,
+                initial_windows_size = 0,
+            };
+            config.tunModeItem ??= new TunModeItem
             {
-                config.tunModeItem = new TunModeItem
-                {
-                    enableTun = false,
-                    mtu = 9000,
-                };
-            }
+                enableTun = false,
+                mtu = 9000,
+            };
             config.guiItem ??= new()
             {
                 enableStatistics = false,
@@ -150,19 +123,13 @@ namespace ServiceLib.Handler
                 }
             }
 
-            if (config.constItem == null)
-            {
-                config.constItem = new ConstItem();
-            }
+            config.constItem ??= new ConstItem();
             if (Utils.IsNullOrEmpty(config.constItem.defIEProxyExceptions))
             {
                 config.constItem.defIEProxyExceptions = Global.IEProxyExceptions;
             }
 
-            if (config.speedTestItem == null)
-            {
-                config.speedTestItem = new();
-            }
+            config.speedTestItem ??= new();
             if (config.speedTestItem.speedTestTimeout < 10)
             {
                 config.speedTestItem.speedTestTimeout = 10;
@@ -183,34 +150,19 @@ namespace ServiceLib.Handler
                 xudpProxyUDP443 = "reject"
             };
 
-            if (config.mux4SboxItem == null)
+            config.mux4SboxItem ??= new()
             {
-                config.mux4SboxItem = new()
-                {
-                    protocol = Global.SingboxMuxs[0],
-                    max_connections = 8
-                };
-            }
+                protocol = Global.SingboxMuxs[0],
+                max_connections = 8
+            };
 
-            if (config.hysteriaItem == null)
+            config.hysteriaItem ??= new()
             {
-                config.hysteriaItem = new()
-                {
-                    up_mbps = 100,
-                    down_mbps = 100
-                };
-            }
+                up_mbps = 100,
+                down_mbps = 100
+            };
             config.clashUIItem ??= new();
-
-            if (config.systemProxyItem == null)
-            {
-                config.systemProxyItem = new()
-                {
-                    systemProxyExceptions = config.systemProxyExceptions,
-                    systemProxyAdvancedProtocol = config.systemProxyAdvancedProtocol,
-                };
-            }
-
+            config.systemProxyItem ??= new();
             config.webDavItem ??= new();
 
             return 0;
@@ -234,12 +186,12 @@ namespace ServiceLib.Handler
         /// <param name="config"></param>
         private static void ToJsonFile(Config config)
         {
-            lock (objLock)
+            lock (_objLock)
             {
                 try
                 {
                     //save temp file
-                    var resPath = Utils.GetConfigPath(configRes);
+                    var resPath = Utils.GetConfigPath(_configRes);
                     var tempPath = $"{resPath}_temp";
                     if (JsonUtils.ToFile(config, tempPath) != 0)
                     {
@@ -260,104 +212,6 @@ namespace ServiceLib.Handler
             }
         }
 
-        //public static int ImportOldGuiConfig(Config config, string fileName)
-        //{
-        //    var result = Utils.LoadResource(fileName);
-        //    if (Utils.IsNullOrEmpty(result))
-        //    {
-        //        return -1;
-        //    }
-
-        //    var configOld = JsonUtils.Deserialize<ConfigOld>(result);
-        //    if (configOld == null)
-        //    {
-        //        return -1;
-        //    }
-
-        //    var subItem = JsonUtils.Deserialize<List<SubItem>>(JsonUtils.Serialize(configOld.subItem));
-        //    foreach (var it in subItem)
-        //    {
-        //        if (Utils.IsNullOrEmpty(it.id))
-        //        {
-        //            it.id = Utils.GetGUID(false);
-        //        }
-        //        SQLiteHelper.Instance.Replace(it);
-        //    }
-
-        //    var profileItems = JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(configOld.vmess));
-        //    foreach (var it in profileItems)
-        //    {
-        //        if (Utils.IsNullOrEmpty(it.indexId))
-        //        {
-        //            it.indexId = Utils.GetGUID(false);
-        //        }
-        //        SQLiteHelper.Instance.Replace(it);
-        //    }
-
-        //    foreach (var it in configOld.routings)
-        //    {
-        //        if (it.locked)
-        //        {
-        //            continue;
-        //        }
-        //        var routing = JsonUtils.Deserialize<RoutingItem>(JsonUtils.Serialize(it));
-        //        foreach (var it2 in it.rules)
-        //        {
-        //            it2.id = Utils.GetGUID(false);
-        //        }
-        //        routing.ruleNum = it.rules.Count;
-        //        routing.ruleSet = JsonUtils.Serialize(it.rules, false);
-
-        //        if (Utils.IsNullOrEmpty(routing.id))
-        //        {
-        //            routing.id = Utils.GetGUID(false);
-        //        }
-        //        SQLiteHelper.Instance.Replace(routing);
-        //    }
-
-        //    config = JsonUtils.Deserialize<Config>(JsonUtils.Serialize(configOld));
-
-        //    if (config.coreBasicItem == null)
-        //    {
-        //        config.coreBasicItem = new()
-        //        {
-        //            logEnabled = configOld.logEnabled,
-        //            loglevel = configOld.loglevel,
-        //            muxEnabled = configOld.muxEnabled,
-        //        };
-        //    }
-
-        //    if (config.routingBasicItem == null)
-        //    {
-        //        config.routingBasicItem = new()
-        //        {
-        //            enableRoutingAdvanced = configOld.enableRoutingAdvanced,
-        //            domainStrategy = configOld.domainStrategy
-        //        };
-        //    }
-
-        //    if (config.guiItem == null)
-        //    {
-        //        config.guiItem = new()
-        //        {
-        //            enableStatistics = configOld.enableStatistics,
-        //            keepOlderDedupl = configOld.keepOlderDedupl,
-        //            ignoreGeoUpdateCore = configOld.ignoreGeoUpdateCore,
-        //            autoUpdateInterval = configOld.autoUpdateInterval,
-        //            checkPreReleaseUpdate = configOld.checkPreReleaseUpdate,
-        //            enableSecurityProtocolTls13 = configOld.enableSecurityProtocolTls13,
-        //            trayMenuServersLimit = configOld.trayMenuServersLimit,
-        //        };
-        //    }
-
-        //    GetDefaultServer(config);
-        //    GetDefaultRouting(config);
-        //    SaveConfig(config);
-        //    LoadConfig(ref config);
-
-        //    return 0;
-        //}
-
         #endregion ConfigHandler
 
         #region Server
diff --git a/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayN/ServiceLib/Handler/CoreHandler.cs
index b3553a1b..985eb1d6 100644
--- a/v2rayN/ServiceLib/Handler/CoreHandler.cs
+++ b/v2rayN/ServiceLib/Handler/CoreHandler.cs
@@ -68,7 +68,7 @@ namespace ServiceLib.Handler
         public int LoadCoreConfigSpeedtest(List<ServerTestItem> selecteds)
         {
             int pid = -1;
-            var coreType = selecteds.Exists(t => t.configType == EConfigType.Hysteria2 || t.configType == EConfigType.TUIC || t.configType == EConfigType.WireGuard) ? ECoreType.sing_box : ECoreType.Xray;
+            var coreType = selecteds.Exists(t => t.ConfigType == EConfigType.Hysteria2 || t.ConfigType == EConfigType.TUIC || t.ConfigType == EConfigType.WireGuard) ? ECoreType.sing_box : ECoreType.Xray;
             string configPath = Utils.GetConfigPath(Global.CoreSpeedtestConfigFileName);
             if (CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType, out string msg) != 0)
             {
diff --git a/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs
index 698b4804..f172cd82 100644
--- a/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs
+++ b/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs
@@ -59,7 +59,7 @@
             result = result[Global.ProtocolShares[EConfigType.VMess].Length..];
             result = Utils.Base64Decode(result);
 
-            //转成Json
+            
             VmessQRCode? vmessQRCode = JsonUtils.Deserialize<VmessQRCode>(result);
             if (vmessQRCode == null)
             {
diff --git a/v2rayN/ServiceLib/Models/ClashConnectionModel.cs b/v2rayN/ServiceLib/Models/ClashConnectionModel.cs
index 5d987a01..4889500b 100644
--- a/v2rayN/ServiceLib/Models/ClashConnectionModel.cs
+++ b/v2rayN/ServiceLib/Models/ClashConnectionModel.cs
@@ -2,16 +2,16 @@
 {
     public class ClashConnectionModel
     {
-        public string id { get; set; }
-        public string network { get; set; }
-        public string type { get; set; }
-        public string host { get; set; }
+        public string? id { get; set; }
+        public string? network { get; set; }
+        public string? type { get; set; }
+        public string? host { get; set; }
         public ulong upload { get; set; }
         public ulong download { get; set; }
-        public string uploadTraffic { get; set; }
-        public string downloadTraffic { get; set; }
+        public string? uploadTraffic { get; set; }
+        public string? downloadTraffic { get; set; }
         public double time { get; set; }
-        public string elapsed { get; set; }
-        public string chain { get; set; }
+        public string? elapsed { get; set; }
+        public string? chain { get; set; }
     }
 }
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Models/ClashConnections.cs b/v2rayN/ServiceLib/Models/ClashConnections.cs
index b5fb2fcf..f6510ad6 100644
--- a/v2rayN/ServiceLib/Models/ClashConnections.cs
+++ b/v2rayN/ServiceLib/Models/ClashConnections.cs
@@ -9,29 +9,29 @@
 
     public class ConnectionItem
     {
-        public string id { get; set; } = string.Empty;
-        public MetadataItem metadata { get; set; }
+        public string? id { get; set; }
+        public MetadataItem? metadata { get; set; }
         public ulong upload { get; set; }
         public ulong download { get; set; }
         public DateTime start { get; set; }
         public List<string>? chains { get; set; }
-        public string rule { get; set; }
-        public string rulePayload { get; set; }
+        public string? rule { get; set; }
+        public string? rulePayload { get; set; }
     }
 
     public class MetadataItem
     {
-        public string network { get; set; }
-        public string type { get; set; }
-        public string sourceIP { get; set; }
-        public string destinationIP { get; set; }
-        public string sourcePort { get; set; }
-        public string destinationPort { get; set; }
-        public string host { get; set; }
-        public string nsMode { get; set; }
+        public string? network { get; set; }
+        public string? type { get; set; }
+        public string? sourceIP { get; set; }
+        public string? destinationIP { get; set; }
+        public string? sourcePort { get; set; }
+        public string? destinationPort { get; set; }
+        public string? host { get; set; }
+        public string? nsMode { get; set; }
         public object uid { get; set; }
-        public string process { get; set; }
-        public string processPath { get; set; }
-        public string remoteDestination { get; set; }
+        public string? process { get; set; }
+        public string? processPath { get; set; }
+        public string? remoteDestination { get; set; }
     }
 }
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Models/ClashProviders.cs b/v2rayN/ServiceLib/Models/ClashProviders.cs
index ca64e0d2..1832f028 100644
--- a/v2rayN/ServiceLib/Models/ClashProviders.cs
+++ b/v2rayN/ServiceLib/Models/ClashProviders.cs
@@ -4,14 +4,14 @@ namespace ServiceLib.Models
 {
     public class ClashProviders
     {
-        public Dictionary<String, ProvidersItem> providers { get; set; }
+        public Dictionary<string, ProvidersItem>? providers { get; set; }
 
         public class ProvidersItem
         {
-            public string name { get; set; }
-            public ProxiesItem[] proxies { get; set; }
-            public string type { get; set; }
-            public string vehicleType { get; set; }
+            public string? name { get; set; }
+            public List<ProxiesItem>? proxies { get; set; }
+            public string? type { get; set; }
+            public string? vehicleType { get; set; }
         }
     }
 }
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Models/ClashProxies.cs b/v2rayN/ServiceLib/Models/ClashProxies.cs
index b2fddeed..b5a5de6c 100644
--- a/v2rayN/ServiceLib/Models/ClashProxies.cs
+++ b/v2rayN/ServiceLib/Models/ClashProxies.cs
@@ -2,22 +2,22 @@
 {
     public class ClashProxies
     {
-        public Dictionary<String, ProxiesItem> proxies { get; set; }
+        public Dictionary<string, ProxiesItem>? proxies { get; set; }
 
         public class ProxiesItem
         {
-            public string[] all { get; set; }
-            public List<HistoryItem> history { get; set; }
-            public string name { get; set; }
-            public string type { get; set; }
+            public List<string>? all { get; set; }
+            public List<HistoryItem>? history { get; set; }
+            public string? name { get; set; }
+            public string? type { get; set; }
             public bool udp { get; set; }
-            public string now { get; set; }
+            public string? now { get; set; }
             public int delay { get; set; }
         }
 
         public class HistoryItem
         {
-            public string time { get; set; }
+            public string? time { get; set; }
             public int delay { get; set; }
         }
     }
diff --git a/v2rayN/ServiceLib/Models/ClashProxyModel.cs b/v2rayN/ServiceLib/Models/ClashProxyModel.cs
index e648b85a..d3a9e0b0 100644
--- a/v2rayN/ServiceLib/Models/ClashProxyModel.cs
+++ b/v2rayN/ServiceLib/Models/ClashProxyModel.cs
@@ -3,15 +3,15 @@
     [Serializable]
     public class ClashProxyModel
     {
-        public string name { get; set; }
+        public string? name { get; set; }
 
-        public string type { get; set; }
+        public string? type { get; set; }
 
-        public string now { get; set; }
+        public string? now { get; set; }
 
         public int delay { get; set; }
 
-        public string delayName { get; set; }
+        public string? delayName { get; set; }
 
         public bool isActive { get; set; }
     }
diff --git a/v2rayN/ServiceLib/Models/ComboItem.cs b/v2rayN/ServiceLib/Models/ComboItem.cs
index f1b013ad..12f7ddba 100644
--- a/v2rayN/ServiceLib/Models/ComboItem.cs
+++ b/v2rayN/ServiceLib/Models/ComboItem.cs
@@ -2,12 +2,12 @@
 {
     public class ComboItem
     {
-        public string ID
+        public string? ID
         {
             get; set;
         }
 
-        public string Text
+        public string? Text
         {
             get; set;
         }
diff --git a/v2rayN/ServiceLib/Models/Config.cs b/v2rayN/ServiceLib/Models/Config.cs
index 53f68ff2..6bc73d3a 100644
--- a/v2rayN/ServiceLib/Models/Config.cs
+++ b/v2rayN/ServiceLib/Models/Config.cs
@@ -10,8 +10,6 @@
 
         public string indexId { get; set; }
         public string subIndexId { get; set; }
-        public string systemProxyExceptions { get; set; }
-        public string systemProxyAdvancedProtocol { get; set; }
 
         public ECoreType runningCoreType { get; set; }
 
diff --git a/v2rayN/ServiceLib/Models/GitHubRelease.cs b/v2rayN/ServiceLib/Models/GitHubRelease.cs
index 804753d8..8f062b40 100644
--- a/v2rayN/ServiceLib/Models/GitHubRelease.cs
+++ b/v2rayN/ServiceLib/Models/GitHubRelease.cs
@@ -4,19 +4,19 @@ namespace ServiceLib.Models
 {
     public class GitHubReleaseAsset
     {
-        [JsonPropertyName("url")] public string Url { get; set; }
+        [JsonPropertyName("url")] public string? Url { get; set; }
 
         [JsonPropertyName("id")] public int Id { get; set; }
 
-        [JsonPropertyName("node_id")] public string NodeId { get; set; }
+        [JsonPropertyName("node_id")] public string? NodeId { get; set; }
 
-        [JsonPropertyName("name")] public string Name { get; set; }
+        [JsonPropertyName("name")] public string? Name { get; set; }
 
         [JsonPropertyName("label")] public object Label { get; set; }
 
-        [JsonPropertyName("content_type")] public string ContentType { get; set; }
+        [JsonPropertyName("content_type")] public string? ContentType { get; set; }
 
-        [JsonPropertyName("state")] public string State { get; set; }
+        [JsonPropertyName("state")] public string? State { get; set; }
 
         [JsonPropertyName("size")] public int Size { get; set; }
 
@@ -26,28 +26,28 @@ namespace ServiceLib.Models
 
         [JsonPropertyName("updated_at")] public DateTime UpdatedAt { get; set; }
 
-        [JsonPropertyName("browser_download_url")] public string BrowserDownloadUrl { get; set; }
+        [JsonPropertyName("browser_download_url")] public string? BrowserDownloadUrl { get; set; }
     }
 
     public class GitHubRelease
     {
-        [JsonPropertyName("url")] public string Url { get; set; }
+        [JsonPropertyName("url")] public string? Url { get; set; }
 
-        [JsonPropertyName("assets_url")] public string AssetsUrl { get; set; }
+        [JsonPropertyName("assets_url")] public string? AssetsUrl { get; set; }
 
-        [JsonPropertyName("upload_url")] public string UploadUrl { get; set; }
+        [JsonPropertyName("upload_url")] public string? UploadUrl { get; set; }
 
-        [JsonPropertyName("html_url")] public string HtmlUrl { get; set; }
+        [JsonPropertyName("html_url")] public string? HtmlUrl { get; set; }
 
         [JsonPropertyName("id")] public int Id { get; set; }
 
-        [JsonPropertyName("node_id")] public string NodeId { get; set; }
+        [JsonPropertyName("node_id")] public string? NodeId { get; set; }
 
-        [JsonPropertyName("tag_name")] public string TagName { get; set; }
+        [JsonPropertyName("tag_name")] public string? TagName { get; set; }
 
-        [JsonPropertyName("target_commitish")] public string TargetCommitish { get; set; }
+        [JsonPropertyName("target_commitish")] public string? TargetCommitish { get; set; }
 
-        [JsonPropertyName("name")] public string Name { get; set; }
+        [JsonPropertyName("name")] public string? Name { get; set; }
 
         [JsonPropertyName("draft")] public bool Draft { get; set; }
 
@@ -59,10 +59,10 @@ namespace ServiceLib.Models
 
         [JsonPropertyName("assets")] public List<GitHubReleaseAsset> Assets { get; set; }
 
-        [JsonPropertyName("tarball_url")] public string TarballUrl { get; set; }
+        [JsonPropertyName("tarball_url")] public string? TarballUrl { get; set; }
 
-        [JsonPropertyName("zipball_url")] public string ZipballUrl { get; set; }
+        [JsonPropertyName("zipball_url")] public string? ZipballUrl { get; set; }
 
-        [JsonPropertyName("body")] public string Body { get; set; }
+        [JsonPropertyName("body")] public string? Body { get; set; }
     }
 }
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Models/ServerTestItem.cs b/v2rayN/ServiceLib/Models/ServerTestItem.cs
index de5c2869..1a6352f6 100644
--- a/v2rayN/ServiceLib/Models/ServerTestItem.cs
+++ b/v2rayN/ServiceLib/Models/ServerTestItem.cs
@@ -3,11 +3,11 @@
     [Serializable]
     public class ServerTestItem
     {
-        public string indexId { get; set; }
-        public string address { get; set; }
-        public int port { get; set; }
-        public EConfigType configType { get; set; }
-        public bool allowTest { get; set; }
-        public int delay { get; set; }
+        public string? IndexId { get; set; }
+        public string? Address { get; set; }
+        public int Port { get; set; }
+        public EConfigType ConfigType { get; set; }
+        public bool AllowTest { get; set; }
+        public int Delay { get; set; }
     }
 }
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Models/SsSIP008.cs b/v2rayN/ServiceLib/Models/SsSIP008.cs
index 9e3d14a8..9c5f1a22 100644
--- a/v2rayN/ServiceLib/Models/SsSIP008.cs
+++ b/v2rayN/ServiceLib/Models/SsSIP008.cs
@@ -2,17 +2,17 @@
 {
     public class SsSIP008
     {
-        public List<SsServer> servers { get; set; }
+        public List<SsServer>? servers { get; set; }
     }
 
     [Serializable]
     public class SsServer
     {
-        public string remarks { get; set; }
-        public string server { get; set; }
-        public string server_port { get; set; }
-        public string method { get; set; }
-        public string password { get; set; }
-        public string plugin { get; set; }
+        public string? remarks { get; set; }
+        public string? server { get; set; }
+        public string? server_port { get; set; }
+        public string? method { get; set; }
+        public string? password { get; set; }
+        public string? plugin { get; set; }
     }
 }
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Models/SysProxyConfig.cs b/v2rayN/ServiceLib/Models/SysProxyConfig.cs
deleted file mode 100644
index 6cc95824..00000000
--- a/v2rayN/ServiceLib/Models/SysProxyConfig.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-namespace ServiceLib.Models
-{
-    public class SysProxyConfig
-    {
-        public bool UserSettingsRecorded;
-        public string Flags;
-        public string ProxyServer;
-        public string BypassList;
-        public string PacUrl;
-
-        public SysProxyConfig()
-        {
-            UserSettingsRecorded = false;
-            Flags = "1";
-            ProxyServer = "";
-            BypassList = "";
-            PacUrl = "";
-        }
-    }
-}
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs
index 99cf4b2e..26839b11 100644
--- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs
+++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs
@@ -124,16 +124,16 @@ namespace ServiceLib.Services.CoreConfig
 
                 foreach (var it in selecteds)
                 {
-                    if (it.configType == EConfigType.Custom)
+                    if (it.ConfigType == EConfigType.Custom)
                     {
                         continue;
                     }
-                    if (it.port <= 0)
+                    if (it.Port <= 0)
                     {
                         continue;
                     }
-                    var item = AppHandler.Instance.GetProfileItem(it.indexId);
-                    if (it.configType is EConfigType.VMess or EConfigType.VLESS)
+                    var item = AppHandler.Instance.GetProfileItem(it.IndexId);
+                    if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
                     {
                         if (item is null || Utils.IsNullOrEmpty(item.id) || !Utils.IsGuidByParse(item.id))
                         {
@@ -164,8 +164,8 @@ namespace ServiceLib.Services.CoreConfig
                     {
                         continue;
                     }
-                    it.port = port;
-                    it.allowTest = true;
+                    it.Port = port;
+                    it.AllowTest = true;
 
                     //inbound
                     Inbound4Sbox inbound = new()
@@ -192,7 +192,7 @@ namespace ServiceLib.Services.CoreConfig
                     {
                         continue;
                     }
-                    if (it.configType is EConfigType.VLESS or EConfigType.Trojan
+                    if (it.ConfigType is EConfigType.VLESS or EConfigType.Trojan
                         && item.streamSecurity == Global.StreamSecurityReality
                         && item.publicKey.IsNullOrEmpty())
                     {
diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs
index 16cbf5fd..1b774111 100644
--- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs
+++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs
@@ -240,16 +240,16 @@ namespace ServiceLib.Services.CoreConfig
 
                 foreach (var it in selecteds)
                 {
-                    if (it.configType == EConfigType.Custom)
+                    if (it.ConfigType == EConfigType.Custom)
                     {
                         continue;
                     }
-                    if (it.port <= 0)
+                    if (it.Port <= 0)
                     {
                         continue;
                     }
-                    var item = AppHandler.Instance.GetProfileItem(it.indexId);
-                    if (it.configType is EConfigType.VMess or EConfigType.VLESS)
+                    var item = AppHandler.Instance.GetProfileItem(it.IndexId);
+                    if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
                     {
                         if (item is null || Utils.IsNullOrEmpty(item.id) || !Utils.IsGuidByParse(item.id))
                         {
@@ -280,8 +280,8 @@ namespace ServiceLib.Services.CoreConfig
                     {
                         continue;
                     }
-                    it.port = port;
-                    it.allowTest = true;
+                    it.Port = port;
+                    it.AllowTest = true;
 
                     //inbound
                     Inbounds4Ray inbound = new()
@@ -308,7 +308,7 @@ namespace ServiceLib.Services.CoreConfig
                     {
                         continue;
                     }
-                    if (it.configType is EConfigType.VLESS or EConfigType.Trojan
+                    if (it.ConfigType is EConfigType.VLESS or EConfigType.Trojan
                         && item.streamSecurity == Global.StreamSecurityReality
                         && item.publicKey.IsNullOrEmpty())
                     {
diff --git a/v2rayN/ServiceLib/Services/SpeedtestService.cs b/v2rayN/ServiceLib/Services/SpeedtestService.cs
index 06c8b727..a708416a 100644
--- a/v2rayN/ServiceLib/Services/SpeedtestService.cs
+++ b/v2rayN/ServiceLib/Services/SpeedtestService.cs
@@ -32,10 +32,10 @@ namespace ServiceLib.Services
                 }
                 _selecteds.Add(new ServerTestItem()
                 {
-                    indexId = it.indexId,
-                    address = it.address,
-                    port = it.port,
-                    configType = it.configType
+                    IndexId = it.indexId,
+                    Address = it.address,
+                    Port = it.port,
+                    ConfigType = it.configType
                 });
             }
             //clear test result
@@ -45,19 +45,19 @@ namespace ServiceLib.Services
                 {
                     case ESpeedActionType.Tcping:
                     case ESpeedActionType.Realping:
-                        UpdateFunc(it.indexId, ResUI.Speedtesting, "");
-                        ProfileExHandler.Instance.SetTestDelay(it.indexId, "0");
+                        UpdateFunc(it.IndexId, ResUI.Speedtesting, "");
+                        ProfileExHandler.Instance.SetTestDelay(it.IndexId, "0");
                         break;
 
                     case ESpeedActionType.Speedtest:
-                        UpdateFunc(it.indexId, "", ResUI.SpeedtestingWait);
-                        ProfileExHandler.Instance.SetTestSpeed(it.indexId, "0");
+                        UpdateFunc(it.IndexId, "", ResUI.SpeedtestingWait);
+                        ProfileExHandler.Instance.SetTestSpeed(it.IndexId, "0");
                         break;
 
                     case ESpeedActionType.Mixedtest:
-                        UpdateFunc(it.indexId, ResUI.Speedtesting, ResUI.SpeedtestingWait);
-                        ProfileExHandler.Instance.SetTestDelay(it.indexId, "0");
-                        ProfileExHandler.Instance.SetTestSpeed(it.indexId, "0");
+                        UpdateFunc(it.IndexId, ResUI.Speedtesting, ResUI.SpeedtestingWait);
+                        ProfileExHandler.Instance.SetTestDelay(it.IndexId, "0");
+                        ProfileExHandler.Instance.SetTestSpeed(it.IndexId, "0");
                         break;
                 }
             }
@@ -95,7 +95,7 @@ namespace ServiceLib.Services
                 List<Task> tasks = [];
                 foreach (var it in _selecteds)
                 {
-                    if (it.configType == EConfigType.Custom)
+                    if (it.ConfigType == EConfigType.Custom)
                     {
                         continue;
                     }
@@ -103,11 +103,11 @@ namespace ServiceLib.Services
                     {
                         try
                         {
-                            int time = GetTcpingTime(it.address, it.port);
+                            int time = GetTcpingTime(it.Address, it.Port);
                             var output = FormatOut(time, Global.DelayUnit);
 
-                            ProfileExHandler.Instance.SetTestDelay(it.indexId, output);
-                            UpdateFunc(it.indexId, output);
+                            ProfileExHandler.Instance.SetTestDelay(it.IndexId, output);
+                            UpdateFunc(it.IndexId, output);
                         }
                         catch (Exception ex)
                         {
@@ -148,11 +148,11 @@ namespace ServiceLib.Services
                 List<Task> tasks = new();
                 foreach (var it in _selecteds)
                 {
-                    if (!it.allowTest)
+                    if (!it.AllowTest)
                     {
                         continue;
                     }
-                    if (it.configType == EConfigType.Custom)
+                    if (it.ConfigType == EConfigType.Custom)
                     {
                         continue;
                     }
@@ -160,13 +160,13 @@ namespace ServiceLib.Services
                     {
                         try
                         {
-                            WebProxy webProxy = new(Global.Loopback, it.port);
+                            WebProxy webProxy = new(Global.Loopback, it.Port);
                             string output = await GetRealPingTime(downloadHandle, webProxy);
 
-                            ProfileExHandler.Instance.SetTestDelay(it.indexId, output);
-                            UpdateFunc(it.indexId, output);
+                            ProfileExHandler.Instance.SetTestDelay(it.IndexId, output);
+                            UpdateFunc(it.IndexId, output);
                             int.TryParse(output, out int delay);
-                            it.delay = delay;
+                            it.Delay = delay;
                         }
                         catch (Exception ex)
                         {
@@ -216,14 +216,14 @@ namespace ServiceLib.Services
             {
                 if (_exitLoop)
                 {
-                    UpdateFunc(it.indexId, "", ResUI.SpeedtestingSkip);
+                    UpdateFunc(it.IndexId, "", ResUI.SpeedtestingSkip);
                     continue;
                 }
-                if (!it.allowTest)
+                if (!it.AllowTest)
                 {
                     continue;
                 }
-                if (it.configType == EConfigType.Custom)
+                if (it.ConfigType == EConfigType.Custom)
                 {
                     continue;
                 }
@@ -232,22 +232,22 @@ namespace ServiceLib.Services
                 //    UpdateFunc(it.indexId, "", ResUI.SpeedtestingSkip);
                 //    continue;
                 //}
-                ProfileExHandler.Instance.SetTestSpeed(it.indexId, "-1");
-                UpdateFunc(it.indexId, "", ResUI.Speedtesting);
+                ProfileExHandler.Instance.SetTestSpeed(it.IndexId, "-1");
+                UpdateFunc(it.IndexId, "", ResUI.Speedtesting);
 
-                var item = AppHandler.Instance.GetProfileItem(it.indexId);
+                var item = AppHandler.Instance.GetProfileItem(it.IndexId);
                 if (item is null) continue;
 
-                WebProxy webProxy = new(Global.Loopback, it.port);
+                WebProxy webProxy = new(Global.Loopback, it.Port);
 
                 await downloadHandle.DownloadDataAsync(url, webProxy, timeout, (success, msg) =>
                 {
                     decimal.TryParse(msg, out decimal dec);
                     if (dec > 0)
                     {
-                        ProfileExHandler.Instance.SetTestSpeed(it.indexId, msg);
+                        ProfileExHandler.Instance.SetTestSpeed(it.IndexId, msg);
                     }
-                    UpdateFunc(it.indexId, "", msg);
+                    UpdateFunc(it.IndexId, "", msg);
                 });
             }
 
@@ -278,38 +278,38 @@ namespace ServiceLib.Services
             {
                 if (_exitLoop)
                 {
-                    UpdateFunc(it.indexId, "", ResUI.SpeedtestingSkip);
+                    UpdateFunc(it.IndexId, "", ResUI.SpeedtestingSkip);
                     continue;
                 }
 
-                if (!it.allowTest)
+                if (!it.AllowTest)
                 {
                     continue;
                 }
-                if (it.configType == EConfigType.Custom)
+                if (it.ConfigType == EConfigType.Custom)
                 {
                     continue;
                 }
-                if (it.delay < 0)
+                if (it.Delay < 0)
                 {
-                    UpdateFunc(it.indexId, "", ResUI.SpeedtestingSkip);
+                    UpdateFunc(it.IndexId, "", ResUI.SpeedtestingSkip);
                     continue;
                 }
-                ProfileExHandler.Instance.SetTestSpeed(it.indexId, "-1");
-                UpdateFunc(it.indexId, "", ResUI.Speedtesting);
+                ProfileExHandler.Instance.SetTestSpeed(it.IndexId, "-1");
+                UpdateFunc(it.IndexId, "", ResUI.Speedtesting);
 
-                var item = AppHandler.Instance.GetProfileItem(it.indexId);
+                var item = AppHandler.Instance.GetProfileItem(it.IndexId);
                 if (item is null) continue;
 
-                WebProxy webProxy = new(Global.Loopback, it.port);
+                WebProxy webProxy = new(Global.Loopback, it.Port);
                 _ = downloadHandle.DownloadDataAsync(url, webProxy, timeout, (success, msg) =>
                 {
                     decimal.TryParse(msg, out decimal dec);
                     if (dec > 0)
                     {
-                        ProfileExHandler.Instance.SetTestSpeed(it.indexId, msg);
+                        ProfileExHandler.Instance.SetTestSpeed(it.IndexId, msg);
                     }
-                    UpdateFunc(it.indexId, "", msg);
+                    UpdateFunc(it.IndexId, "", msg);
                 });
                 await Task.Delay(2000);
             }