diff --git a/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs b/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs
index 7b8c4438..f2197a1c 100644
--- a/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs
+++ b/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs
@@ -41,6 +41,7 @@ namespace v2rayN.Handler
msg = ResUI.FailedGenDefaultConfiguration;
return -1;
}
+ Outbound4Sbox originOutBound = JsonUtils.DeepCopy(singboxConfig.outbounds[0]);
GenLog(singboxConfig);
@@ -48,6 +49,8 @@ namespace v2rayN.Handler
GenOutbound(node, singboxConfig.outbounds[0]);
+ GenOutbounds(singboxConfig, originOutBound);
+
GenMoreOutbounds(node, singboxConfig);
GenRouting(singboxConfig);
@@ -205,6 +208,32 @@ namespace v2rayN.Handler
return inbound;
}
+ ///
+ /// 生成分流的出站规则
+ ///
+ private int GenOutbounds(SingboxConfig singboxConfig, Outbound4Sbox outbound)
+ {
+ var routing = ConfigHandler.GetDefaultRouting(_config);
+ var ruleSet = JsonUtils.Deserialize>(routing.ruleSet);
+ if (ruleSet == null) return -1;
+
+ int index = 1;
+ foreach (var item in ruleSet)
+ {
+ string outBoundIndexId = item.bingServerIndexId;
+ if (outBoundIndexId == null) continue;
+ var serverItem = LazyConfig.Instance.GetProfileItem(outBoundIndexId);
+ if (serverItem == null) continue;
+
+ var newOutbounds = JsonUtils.DeepCopy(outbound);
+ newOutbounds.tag = $"{(serverItem.indexId.Equals(_config.indexId) ? "[proxy]" : $"[{index++}]")}{serverItem.remarks} ## {serverItem.indexId}";
+ singboxConfig.outbounds.Add(newOutbounds);
+ GenOutbound(serverItem, newOutbounds);
+ }
+
+ return 0;
+ }
+
private int GenOutbound(ProfileItem node, Outbound4Sbox outbound)
{
try
@@ -520,8 +549,18 @@ namespace v2rayN.Handler
if (routing != null)
{
var rules = JsonUtils.Deserialize>(routing.ruleSet);
- foreach (var item in rules!)
+ int index = 1;
+ foreach (var item in rules)
{
+ // 分流修改
+ string outBoundIndexId = item.bingServerIndexId;
+
+ if (outBoundIndexId == null) continue;
+
+ var serverItem = LazyConfig.Instance.GetProfileItem(outBoundIndexId);
+ if (serverItem == null) continue;
+ item.outboundTag = $"{(serverItem.indexId.Equals(_config.indexId) ? "[proxy]" : $"[{index++}]")}{serverItem.remarks} ## {serverItem.indexId}";
+ // end
if (item.enabled)
{
GenRoutingUserRule(item, singboxConfig.route.rules);
@@ -535,8 +574,18 @@ namespace v2rayN.Handler
if (lockedItem != null)
{
var rules = JsonUtils.Deserialize>(lockedItem.ruleSet);
- foreach (var item in rules!)
+ int index = 1;
+ foreach (var item in rules)
{
+ // 分流修改
+ string outBoundIndexId = item.bingServerIndexId;
+
+ if (outBoundIndexId == null) continue;
+
+ var serverItem = LazyConfig.Instance.GetProfileItem(outBoundIndexId);
+ if (serverItem == null) continue;
+ item.outboundTag = $"{(serverItem.indexId.Equals(_config.indexId) ? "[proxy]" : $"[{index++}]")}{serverItem.remarks} ## {serverItem.indexId}";
+ // end
GenRoutingUserRule(item, singboxConfig.route.rules);
}
}
diff --git a/v2rayN/v2rayN/Handler/CoreConfigV2ray.cs b/v2rayN/v2rayN/Handler/CoreConfigV2ray.cs
index a77e94bc..93d6aa8d 100644
--- a/v2rayN/v2rayN/Handler/CoreConfigV2ray.cs
+++ b/v2rayN/v2rayN/Handler/CoreConfigV2ray.cs
@@ -43,6 +43,7 @@ namespace v2rayN.Handler
msg = ResUI.FailedGenDefaultConfiguration;
return -1;
}
+ Outbounds4Ray originOutBound = JsonUtils.DeepCopy(v2rayConfig.outbounds[0]);
GenLog(v2rayConfig);
@@ -52,6 +53,8 @@ namespace v2rayN.Handler
GenOutbound(node, v2rayConfig.outbounds[0]);
+ GenOutbounds(v2rayConfig, originOutBound);
+
GenMoreOutbounds(node, v2rayConfig);
GenDns(v2rayConfig);
@@ -187,8 +190,18 @@ namespace v2rayN.Handler
v2rayConfig.routing.domainStrategy = routing.domainStrategy;
}
var rules = JsonUtils.Deserialize>(routing.ruleSet);
+ int index = 1;
foreach (var item in rules)
{
+ // 分流
+ string outBoundIndexId = item.bingServerIndexId;
+
+ if (outBoundIndexId == null) continue;
+
+ var serverItem = LazyConfig.Instance.GetProfileItem(outBoundIndexId);
+ if (serverItem == null) continue;
+ item.outboundTag = $"{(serverItem.indexId.Equals(_config.indexId) ? "[proxy]" : $"[{index++}]")}{serverItem.remarks} ## {serverItem.indexId}";
+ // end
if (item.enabled)
{
var item2 = JsonUtils.Deserialize(JsonUtils.Serialize(item));
@@ -203,8 +216,18 @@ namespace v2rayN.Handler
if (lockedItem != null)
{
var rules = JsonUtils.Deserialize>(lockedItem.ruleSet);
+ int index = 1;
foreach (var item in rules)
{
+ // 分流修改
+ string outBoundIndexId = item.bingServerIndexId;
+
+ if (outBoundIndexId == null) continue;
+
+ var serverItem = LazyConfig.Instance.GetProfileItem(outBoundIndexId);
+ if (serverItem == null) continue;
+ item.outboundTag = $"{(serverItem.indexId.Equals(_config.indexId) ? "[proxy]" : $"[{index++}]")}{serverItem.remarks} ## {serverItem.indexId}";
+ // end
var item2 = JsonUtils.Deserialize(JsonUtils.Serialize(item));
GenRoutingUserRule(item2, v2rayConfig);
}
@@ -293,6 +316,32 @@ namespace v2rayN.Handler
return 0;
}
+ ///
+ /// 生成分流的出站规则
+ ///
+ private int GenOutbounds(V2rayConfig v2rayConfig, Outbounds4Ray outbound)
+ {
+ var routing = ConfigHandler.GetDefaultRouting(_config);
+ var ruleSet = JsonUtils.Deserialize>(routing.ruleSet);
+ if (ruleSet == null) return -1;
+
+ int index = 1;
+ foreach (var item in ruleSet)
+ {
+ string outBoundIndexId = item.bingServerIndexId;
+ if (outBoundIndexId == null) continue;
+ var serverItem = LazyConfig.Instance.GetProfileItem(outBoundIndexId);
+ if (serverItem == null) continue;
+
+ var newOutbounds = JsonUtils.DeepCopy(outbound);
+ newOutbounds.tag = $"{(serverItem.indexId.Equals(_config.indexId) ? "[proxy]" : $"[{index++}]")}{serverItem.remarks} ## {serverItem.indexId}";
+ v2rayConfig.outbounds.Add(newOutbounds);
+ GenOutbound(serverItem, newOutbounds);
+ }
+
+ return 0;
+ }
+
private int GenOutbound(ProfileItem node, Outbounds4Ray outbound)
{
try
diff --git a/v2rayN/v2rayN/Mode/RulesItem.cs b/v2rayN/v2rayN/Mode/RulesItem.cs
index 1985c258..c7505493 100644
--- a/v2rayN/v2rayN/Mode/RulesItem.cs
+++ b/v2rayN/v2rayN/Mode/RulesItem.cs
@@ -12,6 +12,9 @@
public string outboundTag { get; set; }
+ // 分流修改
+ public string bingServerIndexId { get; set; }
+
public List ip { get; set; }
public List domain { get; set; }
diff --git a/v2rayN/v2rayN/Sample/tun_singbox_rules b/v2rayN/v2rayN/Sample/tun_singbox_rules
index 528adb76..df1dc4ec 100644
--- a/v2rayN/v2rayN/Sample/tun_singbox_rules
+++ b/v2rayN/v2rayN/Sample/tun_singbox_rules
@@ -1,8 +1,4 @@
[
- {
- "protocol": [ "dns" ],
- "outbound": "dns_out"
- },
{
"network": "udp",
"port": [
@@ -20,12 +16,5 @@
"ff00::/8"
],
"outbound": "block"
- },
- {
- "source_ip_cidr": [
- "224.0.0.0/3",
- "ff00::/8"
- ],
- "outbound": "block"
}
]
\ No newline at end of file
diff --git a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs
index eb622188..a17006f7 100644
--- a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs
+++ b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs
@@ -1621,6 +1621,12 @@ namespace v2rayN.ViewModels
if (_config.tunModeItem.enableTun != EnableTun)
{
_config.tunModeItem.enableTun = EnableTun;
+ // ǹԱʱtunģʽ
+ if (!Utils.IsAdministrator())
+ {
+ RebootAsAdmin();
+ return;
+ }
Reload();
}
}
@@ -1839,7 +1845,7 @@ namespace v2rayN.ViewModels
if (_config.uiItem.autoHideStartup)
{
Observable.Range(1, 1)
- .Delay(TimeSpan.FromSeconds(2))
+ .Delay(TimeSpan.FromSeconds(0.5)) // ʱ
.Subscribe(x =>
{
Application.Current.Dispatcher.Invoke(() =>
diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs
index e4f30d56..ae5117ba 100644
--- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs
+++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs
@@ -212,7 +212,8 @@ namespace v2rayN.Views
var IsAdministrator = Utils.IsAdministrator();
this.Title = $"{Utils.GetVersion()} - {(IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}";
- spEnableTun.Visibility = IsAdministrator ? Visibility.Visible : Visibility.Collapsed;
+ // 非管理员运行时tun模式开启逻辑修改
+ // spEnableTun.Visibility = IsAdministrator ? Visibility.Visible : Visibility.Collapsed;
//if (_config.uiItem.autoHideStartup)
//{
diff --git a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml
index bbce43c4..2d482c59 100644
--- a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml
+++ b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml
@@ -52,7 +52,22 @@
Margin="4"
MaxDropDownHeight="1000"
Style="{StaticResource DefComboBox}" />
-
+
+
+
+
{
clbProtocol.Items.Add(it);
@@ -54,6 +79,19 @@ namespace v2rayN.Views
this.WhenActivated(disposables =>
{
+ // 分流
+ cmbOutboundIndexId.SelectedItem = cmbOutboundIndexId.Items.Cast