From a359a508ae01801f8bda9dbbfac617c56c937b9e Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Fri, 10 Feb 2023 21:02:29 +0800 Subject: [PATCH] fix Import old config --- v2rayN/v2rayN/Handler/ConfigHandler.cs | 42 ++++++++++++++++++++------ 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs index ad842ed8..b218c45c 100644 --- a/v2rayN/v2rayN/Handler/ConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs @@ -43,8 +43,7 @@ namespace v2rayN.Handler if (config == null) { config = new Config - { - + { }; } if (config.coreBasicItem == null) @@ -311,21 +310,46 @@ namespace v2rayN.Handler SqliteHelper.Instance.Replace(routing); } - config = Utils.FromJson(Utils.ToJson(configOld)); - if (config.tunModeItem == null) + config = Utils.FromJson(Utils.ToJson(configOld)); + + if (config.coreBasicItem == null) { - config.tunModeItem = new TunModeItem + config.coreBasicItem = new() { - enableTun = false, - showWindow = true, - mtu = 9000, + 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, + statisticsFreshRate = configOld.statisticsFreshRate, + keepOlderDedupl = configOld.keepOlderDedupl, + ignoreGeoUpdateCore = configOld.ignoreGeoUpdateCore, + autoUpdateInterval = configOld.autoUpdateInterval, + checkPreReleaseUpdate = configOld.checkPreReleaseUpdate, + enableSecurityProtocolTls13 = configOld.enableSecurityProtocolTls13, + trayMenuServersLimit = configOld.trayMenuServersLimit, }; } GetDefaultServer(ref config); GetDefaultRouting(ref config); SaveConfig(ref config); - LazyConfig.Instance.SetConfig(ref config); + LoadConfig(ref config); return 0; }