diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs index af7fbc19..ad842ed8 100644 --- a/v2rayN/v2rayN/Handler/ConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs @@ -45,7 +45,6 @@ namespace v2rayN.Handler config = new Config { - enableRoutingAdvanced = true }; } if (config.coreBasicItem == null) @@ -88,10 +87,17 @@ namespace v2rayN.Handler config.inbound[0].protocol = Global.InboundSocks; } } + if (config.routingBasicItem == null) + { + config.routingBasicItem = new() + { + enableRoutingAdvanced = true + }; + } //路由规则 - if (Utils.IsNullOrEmpty(config.domainStrategy)) + if (Utils.IsNullOrEmpty(config.routingBasicItem.domainStrategy)) { - config.domainStrategy = Global.domainStrategys[0];//"IPIfNonMatch"; + config.routingBasicItem.domainStrategy = Global.domainStrategys[0];//"IPIfNonMatch"; } //if (Utils.IsNullOrEmpty(config.domainMatcher)) //{ @@ -153,7 +159,7 @@ namespace v2rayN.Handler if (Utils.IsNullOrEmpty(config.uiItem.currentLanguage)) { config.uiItem.currentLanguage = Global.Languages[0]; - } + } if (config.constItem == null) { @@ -1455,7 +1461,7 @@ namespace v2rayN.Handler { if (SqliteHelper.Instance.Table().Where(t => t.id == routingItem.id).Count() > 0) { - config.routingIndexId = routingItem.id; + config.routingBasicItem.routingIndexId = routingItem.id; } Global.reloadCore = true; @@ -1466,7 +1472,7 @@ namespace v2rayN.Handler } public static RoutingItem GetDefaultRouting(ref Config config) { - var item = LazyConfig.Instance.GetRoutingItem(config.routingIndexId); + var item = LazyConfig.Instance.GetRoutingItem(config.routingBasicItem.routingIndexId); if (item is null) { var item2 = SqliteHelper.Instance.Table().FirstOrDefault(t => t.locked == false); diff --git a/v2rayN/v2rayN/Handler/CoreConfigHandler.cs b/v2rayN/v2rayN/Handler/CoreConfigHandler.cs index b6be7fab..be92a35b 100644 --- a/v2rayN/v2rayN/Handler/CoreConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/CoreConfigHandler.cs @@ -187,10 +187,10 @@ namespace v2rayN.Handler if (v2rayConfig.routing != null && v2rayConfig.routing.rules != null) { - v2rayConfig.routing.domainStrategy = config.domainStrategy; - v2rayConfig.routing.domainMatcher = Utils.IsNullOrEmpty(config.domainMatcher) ? null : config.domainMatcher; + v2rayConfig.routing.domainStrategy = config.routingBasicItem.domainStrategy; + v2rayConfig.routing.domainMatcher = Utils.IsNullOrEmpty(config.routingBasicItem.domainMatcher) ? null : config.routingBasicItem.domainMatcher; - if (config.enableRoutingAdvanced) + if (config.routingBasicItem.enableRoutingAdvanced) { var routing = ConfigHandler.GetDefaultRouting(ref config); if (routing != null) diff --git a/v2rayN/v2rayN/Handler/MainFormHandler.cs b/v2rayN/v2rayN/Handler/MainFormHandler.cs index 72b99f77..96c15478 100644 --- a/v2rayN/v2rayN/Handler/MainFormHandler.cs +++ b/v2rayN/v2rayN/Handler/MainFormHandler.cs @@ -86,7 +86,7 @@ namespace v2rayN.Handler { try { - if (!config.enableRoutingAdvanced) + if (!config.routingBasicItem.enableRoutingAdvanced) { return null; } diff --git a/v2rayN/v2rayN/Mode/Config.cs b/v2rayN/v2rayN/Mode/Config.cs index a6341523..c141052f 100644 --- a/v2rayN/v2rayN/Mode/Config.cs +++ b/v2rayN/v2rayN/Mode/Config.cs @@ -8,59 +8,16 @@ { #region property - public string indexId - { - get; set; - } - - /// - /// - /// - public ESysProxyType sysProxyType - { - get; set; - } - - /// - /// 自定义远程DNS - /// - public string remoteDNS - { - get; set; - } - + public string indexId { get; set; } + + public string remoteDNS { get; set; } /// /// Outbound Freedom domainStrategy /// - public string domainStrategy4Freedom - { - get; set; - } - - /// - /// 域名解析策略 - /// - public string domainStrategy - { - get; set; - } - public string domainMatcher - { - get; set; - } - public string routingIndexId { get; set; } - public bool enableRoutingAdvanced - { - get; set; - } + public string domainStrategy4Freedom { get; set; } - /// - /// systemProxyExceptions - /// - public string systemProxyExceptions - { - get; set; - } + public ESysProxyType sysProxyType { get; set; } + public string systemProxyExceptions { get; set; } public string systemProxyAdvancedProtocol { get; set; } #endregion @@ -71,6 +28,7 @@ public TunModeItem tunModeItem { get; set; } public KcpItem kcpItem { get; set; } public GrpcItem grpcItem { get; set; } + public RoutingBasicItem routingBasicItem { get; set; } public GUIItem guiItem { get; set; } public UIItem uiItem { get; set; } public ConstItem constItem { get; set; } diff --git a/v2rayN/v2rayN/Mode/ConfigItems.cs b/v2rayN/v2rayN/Mode/ConfigItems.cs index 1aa90eb4..5f89e201 100644 --- a/v2rayN/v2rayN/Mode/ConfigItems.cs +++ b/v2rayN/v2rayN/Mode/ConfigItems.cs @@ -180,4 +180,15 @@ namespace v2rayN.Mode } + [Serializable] + public class RoutingBasicItem + { + /// + /// 域名解析策略 + /// + public string domainStrategy { get; set; } + public string domainMatcher { get; set; } + public string routingIndexId { get; set; } + public bool enableRoutingAdvanced { get; set; } + } } diff --git a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs index d9c8927c..b4556c80 100644 --- a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs @@ -1434,7 +1434,7 @@ namespace v2rayN.ViewModels private void RefreshRoutingsMenu() { _routingItems.Clear(); - if (!_config.enableRoutingAdvanced) + if (!_config.routingBasicItem.enableRoutingAdvanced) { BlRouting = false; return; @@ -1445,7 +1445,7 @@ namespace v2rayN.ViewModels foreach (var item in routings) { _routingItems.Add(item); - if (item.id.Equals(_config.routingIndexId)) + if (item.id.Equals(_config.routingBasicItem.routingIndexId)) { SelectedRouting = item; } @@ -1469,7 +1469,7 @@ namespace v2rayN.ViewModels { return; } - if (_config.routingIndexId == item.id) + if (_config.routingBasicItem.routingIndexId == item.id) { return; } diff --git a/v2rayN/v2rayN/ViewModels/RoutingSettingViewModel.cs b/v2rayN/v2rayN/ViewModels/RoutingSettingViewModel.cs index 884c6760..233f0c44 100644 --- a/v2rayN/v2rayN/ViewModels/RoutingSettingViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/RoutingSettingViewModel.cs @@ -71,9 +71,9 @@ namespace v2rayN.ViewModels ConfigHandler.InitBuiltinRouting(ref _config); - enableRoutingAdvanced = _config.enableRoutingAdvanced; - domainStrategy = _config.domainStrategy; - domainMatcher = _config.domainMatcher; + enableRoutingAdvanced = _config.routingBasicItem.enableRoutingAdvanced; + domainStrategy = _config.routingBasicItem.domainStrategy; + domainMatcher = _config.routingBasicItem.domainMatcher; RefreshRoutingItems(); @@ -163,7 +163,7 @@ namespace v2rayN.ViewModels foreach (var item in routings) { bool def = false; - if (item.id.Equals(_config.routingIndexId)) + if (item.id.Equals(_config.routingBasicItem.routingIndexId)) { def = true; } @@ -182,9 +182,9 @@ namespace v2rayN.ViewModels } private void SaveRouting() { - _config.domainStrategy = domainStrategy; - _config.enableRoutingAdvanced = enableRoutingAdvanced; - _config.domainMatcher = domainMatcher; + _config.routingBasicItem.domainStrategy = domainStrategy; + _config.routingBasicItem.enableRoutingAdvanced = enableRoutingAdvanced; + _config.routingBasicItem.domainMatcher = domainMatcher; EndBindingLockedData();