mirror of https://github.com/2dust/v2rayN
Refactor routing basic settings
parent
9b8181b72b
commit
f4c9ca8dff
|
@ -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 (Utils.IsNullOrEmpty(config.domainStrategy))
|
||||
if (config.routingBasicItem == null)
|
||||
{
|
||||
config.domainStrategy = Global.domainStrategys[0];//"IPIfNonMatch";
|
||||
config.routingBasicItem = new()
|
||||
{
|
||||
enableRoutingAdvanced = true
|
||||
};
|
||||
}
|
||||
//路由规则
|
||||
if (Utils.IsNullOrEmpty(config.routingBasicItem.domainStrategy))
|
||||
{
|
||||
config.routingBasicItem.domainStrategy = Global.domainStrategys[0];//"IPIfNonMatch";
|
||||
}
|
||||
//if (Utils.IsNullOrEmpty(config.domainMatcher))
|
||||
//{
|
||||
|
@ -1455,7 +1461,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
if (SqliteHelper.Instance.Table<RoutingItem>().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<RoutingItem>().FirstOrDefault(t => t.locked == false);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
try
|
||||
{
|
||||
if (!config.enableRoutingAdvanced)
|
||||
if (!config.routingBasicItem.enableRoutingAdvanced)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -8,59 +8,16 @@
|
|||
{
|
||||
#region property
|
||||
|
||||
public string indexId
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public ESysProxyType sysProxyType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自定义远程DNS
|
||||
/// </summary>
|
||||
public string remoteDNS
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public string indexId { get; set; }
|
||||
|
||||
public string remoteDNS { get; set; }
|
||||
/// <summary>
|
||||
/// Outbound Freedom domainStrategy
|
||||
/// </summary>
|
||||
public string domainStrategy4Freedom
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public string domainStrategy4Freedom { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 域名解析策略
|
||||
/// </summary>
|
||||
public string domainStrategy
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public string domainMatcher
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public string routingIndexId { get; set; }
|
||||
public bool enableRoutingAdvanced
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// systemProxyExceptions
|
||||
/// </summary>
|
||||
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; }
|
||||
|
|
|
@ -180,4 +180,15 @@ namespace v2rayN.Mode
|
|||
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class RoutingBasicItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 域名解析策略
|
||||
/// </summary>
|
||||
public string domainStrategy { get; set; }
|
||||
public string domainMatcher { get; set; }
|
||||
public string routingIndexId { get; set; }
|
||||
public bool enableRoutingAdvanced { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue