mirror of
https://github.com/2dust/v2rayN.git
synced 2025-07-02 04:52:09 +00:00
Refactor routing basic settings
This commit is contained in:
parent
9b8181b72b
commit
f4c9ca8dff
7 changed files with 45 additions and 70 deletions
|
@ -45,7 +45,6 @@ namespace v2rayN.Handler
|
||||||
config = new Config
|
config = new Config
|
||||||
{
|
{
|
||||||
|
|
||||||
enableRoutingAdvanced = true
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (config.coreBasicItem == null)
|
if (config.coreBasicItem == null)
|
||||||
|
@ -88,10 +87,17 @@ namespace v2rayN.Handler
|
||||||
config.inbound[0].protocol = Global.InboundSocks;
|
config.inbound[0].protocol = Global.InboundSocks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//路由规则
|
if (config.routingBasicItem == null)
|
||||||
if (Utils.IsNullOrEmpty(config.domainStrategy))
|
|
||||||
{
|
{
|
||||||
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))
|
//if (Utils.IsNullOrEmpty(config.domainMatcher))
|
||||||
//{
|
//{
|
||||||
|
@ -153,7 +159,7 @@ namespace v2rayN.Handler
|
||||||
if (Utils.IsNullOrEmpty(config.uiItem.currentLanguage))
|
if (Utils.IsNullOrEmpty(config.uiItem.currentLanguage))
|
||||||
{
|
{
|
||||||
config.uiItem.currentLanguage = Global.Languages[0];
|
config.uiItem.currentLanguage = Global.Languages[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.constItem == null)
|
if (config.constItem == null)
|
||||||
{
|
{
|
||||||
|
@ -1455,7 +1461,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
if (SqliteHelper.Instance.Table<RoutingItem>().Where(t => t.id == routingItem.id).Count() > 0)
|
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;
|
Global.reloadCore = true;
|
||||||
|
@ -1466,7 +1472,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
public static RoutingItem GetDefaultRouting(ref Config config)
|
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)
|
if (item is null)
|
||||||
{
|
{
|
||||||
var item2 = SqliteHelper.Instance.Table<RoutingItem>().FirstOrDefault(t => t.locked == false);
|
var item2 = SqliteHelper.Instance.Table<RoutingItem>().FirstOrDefault(t => t.locked == false);
|
||||||
|
|
|
@ -187,10 +187,10 @@ namespace v2rayN.Handler
|
||||||
if (v2rayConfig.routing != null
|
if (v2rayConfig.routing != null
|
||||||
&& v2rayConfig.routing.rules != null)
|
&& v2rayConfig.routing.rules != null)
|
||||||
{
|
{
|
||||||
v2rayConfig.routing.domainStrategy = config.domainStrategy;
|
v2rayConfig.routing.domainStrategy = config.routingBasicItem.domainStrategy;
|
||||||
v2rayConfig.routing.domainMatcher = Utils.IsNullOrEmpty(config.domainMatcher) ? null : config.domainMatcher;
|
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);
|
var routing = ConfigHandler.GetDefaultRouting(ref config);
|
||||||
if (routing != null)
|
if (routing != null)
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!config.enableRoutingAdvanced)
|
if (!config.routingBasicItem.enableRoutingAdvanced)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,59 +8,16 @@
|
||||||
{
|
{
|
||||||
#region property
|
#region property
|
||||||
|
|
||||||
public string indexId
|
public string indexId { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
public string remoteDNS { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public ESysProxyType sysProxyType
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 自定义远程DNS
|
|
||||||
/// </summary>
|
|
||||||
public string remoteDNS
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Outbound Freedom domainStrategy
|
/// Outbound Freedom domainStrategy
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string domainStrategy4Freedom
|
public string domainStrategy4Freedom { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
public ESysProxyType sysProxyType { get; set; }
|
||||||
/// 域名解析策略
|
public string systemProxyExceptions { get; set; }
|
||||||
/// </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 string systemProxyAdvancedProtocol { get; set; }
|
public string systemProxyAdvancedProtocol { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -71,6 +28,7 @@
|
||||||
public TunModeItem tunModeItem { get; set; }
|
public TunModeItem tunModeItem { get; set; }
|
||||||
public KcpItem kcpItem { get; set; }
|
public KcpItem kcpItem { get; set; }
|
||||||
public GrpcItem grpcItem { get; set; }
|
public GrpcItem grpcItem { get; set; }
|
||||||
|
public RoutingBasicItem routingBasicItem { get; set; }
|
||||||
public GUIItem guiItem { get; set; }
|
public GUIItem guiItem { get; set; }
|
||||||
public UIItem uiItem { get; set; }
|
public UIItem uiItem { get; set; }
|
||||||
public ConstItem constItem { 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()
|
private void RefreshRoutingsMenu()
|
||||||
{
|
{
|
||||||
_routingItems.Clear();
|
_routingItems.Clear();
|
||||||
if (!_config.enableRoutingAdvanced)
|
if (!_config.routingBasicItem.enableRoutingAdvanced)
|
||||||
{
|
{
|
||||||
BlRouting = false;
|
BlRouting = false;
|
||||||
return;
|
return;
|
||||||
|
@ -1445,7 +1445,7 @@ namespace v2rayN.ViewModels
|
||||||
foreach (var item in routings)
|
foreach (var item in routings)
|
||||||
{
|
{
|
||||||
_routingItems.Add(item);
|
_routingItems.Add(item);
|
||||||
if (item.id.Equals(_config.routingIndexId))
|
if (item.id.Equals(_config.routingBasicItem.routingIndexId))
|
||||||
{
|
{
|
||||||
SelectedRouting = item;
|
SelectedRouting = item;
|
||||||
}
|
}
|
||||||
|
@ -1469,7 +1469,7 @@ namespace v2rayN.ViewModels
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_config.routingIndexId == item.id)
|
if (_config.routingBasicItem.routingIndexId == item.id)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,9 +71,9 @@ namespace v2rayN.ViewModels
|
||||||
|
|
||||||
ConfigHandler.InitBuiltinRouting(ref _config);
|
ConfigHandler.InitBuiltinRouting(ref _config);
|
||||||
|
|
||||||
enableRoutingAdvanced = _config.enableRoutingAdvanced;
|
enableRoutingAdvanced = _config.routingBasicItem.enableRoutingAdvanced;
|
||||||
domainStrategy = _config.domainStrategy;
|
domainStrategy = _config.routingBasicItem.domainStrategy;
|
||||||
domainMatcher = _config.domainMatcher;
|
domainMatcher = _config.routingBasicItem.domainMatcher;
|
||||||
|
|
||||||
RefreshRoutingItems();
|
RefreshRoutingItems();
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ namespace v2rayN.ViewModels
|
||||||
foreach (var item in routings)
|
foreach (var item in routings)
|
||||||
{
|
{
|
||||||
bool def = false;
|
bool def = false;
|
||||||
if (item.id.Equals(_config.routingIndexId))
|
if (item.id.Equals(_config.routingBasicItem.routingIndexId))
|
||||||
{
|
{
|
||||||
def = true;
|
def = true;
|
||||||
}
|
}
|
||||||
|
@ -182,9 +182,9 @@ namespace v2rayN.ViewModels
|
||||||
}
|
}
|
||||||
private void SaveRouting()
|
private void SaveRouting()
|
||||||
{
|
{
|
||||||
_config.domainStrategy = domainStrategy;
|
_config.routingBasicItem.domainStrategy = domainStrategy;
|
||||||
_config.enableRoutingAdvanced = enableRoutingAdvanced;
|
_config.routingBasicItem.enableRoutingAdvanced = enableRoutingAdvanced;
|
||||||
_config.domainMatcher = domainMatcher;
|
_config.routingBasicItem.domainMatcher = domainMatcher;
|
||||||
|
|
||||||
EndBindingLockedData();
|
EndBindingLockedData();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue