diff --git a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs index 514df308..6167fd75 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs +++ b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs @@ -2724,6 +2724,15 @@ namespace ServiceLib.Resx { } } + /// + /// 查找类似 Can fill in the configuration remarks, please make sure it exist and are unique 的本地化字符串。 + /// + public static string TbRuleOutboundTagTip { + get { + return ResourceManager.GetString("TbRuleOutboundTagTip", resourceCulture); + } + } + /// /// 查找类似 Encryption method (security) 的本地化字符串。 /// diff --git a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx index 7eb87b93..3bc07d9f 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx @@ -1392,4 +1392,7 @@ URL آزمایش اطلاعات اتصال فعلی + + Can fill in the configuration remarks, please make sure it exist and are unique + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.hu.resx b/v2rayN/ServiceLib/Resx/ResUI.hu.resx index 6edbb227..114e1a21 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.hu.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.hu.resx @@ -1392,4 +1392,7 @@ Current connection info test URL + + Can fill in the configuration remarks, please make sure it exist and are unique + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.resx b/v2rayN/ServiceLib/Resx/ResUI.resx index a83edea6..4be88f75 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.resx @@ -1392,4 +1392,7 @@ Current connection info test URL + + Can fill in the configuration remarks, please make sure it exist and are unique + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.ru.resx b/v2rayN/ServiceLib/Resx/ResUI.ru.resx index 182dfaf0..b987c364 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.ru.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.ru.resx @@ -1392,4 +1392,7 @@ URL для тестирования текущего соединения + + Can fill in the configuration remarks, please make sure it exist and are unique + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx index e6399488..0d1d50d4 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx @@ -1389,4 +1389,7 @@ 当前连接信息测试地址 + + 可以填写配置文件别名,请确保存在并唯一 + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx index 3a8fc8aa..4ea33211 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx @@ -1389,4 +1389,7 @@ 目前連接資訊測試地址 + + 可以填寫設定檔別名,請確保存在並唯一 + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index d81b0783..a4887968 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -1166,7 +1166,7 @@ public class CoreConfigSingboxService { if (item.Enabled) { - await GenRoutingUserRule(item, singboxConfig.route.rules); + await GenRoutingUserRule(item, singboxConfig); } } } @@ -1206,7 +1206,7 @@ public class CoreConfigSingboxService lstDirectExe = new List(directExeSet); } - private async Task GenRoutingUserRule(RulesItem item, List rules) + private async Task GenRoutingUserRule(RulesItem item, SingboxConfig singboxConfig) { try { @@ -1214,6 +1214,8 @@ public class CoreConfigSingboxService { return 0; } + item.OutboundTag = await GenRoutingUserRuleOutbound(item.OutboundTag, singboxConfig); + var rules = singboxConfig.route.rules; var rule = new Rule4Sbox() { @@ -1365,6 +1367,29 @@ public class CoreConfigSingboxService return true; } + private async Task GenRoutingUserRuleOutbound(string outboundTag, SingboxConfig singboxConfig) + { + if (outboundTag is Global.ProxyTag or Global.ProxyTag or Global.BlockTag) + { + return outboundTag; + } + + var node = await AppHandler.Instance.GetProfileItemViaRemarks(outboundTag); + if (node == null + || node.ConfigType == EConfigType.Custom) + { + return Global.ProxyTag; + } + + var txtOutbound = EmbedUtils.GetEmbedText(Global.SingboxSampleOutbound); + var outbound = JsonUtils.Deserialize(txtOutbound); + await GenOutbound(node, outbound); + outbound.tag = Global.ProxyTag + node.IndexId.ToString(); + singboxConfig.outbounds.Add(outbound); + + return outbound.tag; + } + private async Task GenDns(ProfileItem? node, SingboxConfig singboxConfig) { try diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs index c181d426..f008cc14 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs @@ -54,12 +54,12 @@ public class CoreConfigV2rayService await GenInbounds(v2rayConfig); - await GenRouting(v2rayConfig); - await GenOutbound(node, v2rayConfig.outbounds.First()); await GenMoreOutbounds(node, v2rayConfig); + await GenRouting(v2rayConfig); + await GenDns(node, v2rayConfig); await GenStatistic(v2rayConfig); @@ -556,6 +556,8 @@ public class CoreConfigV2rayService { return 0; } + rule.outboundTag = await GenRoutingUserRuleOutbound(rule.outboundTag, v2rayConfig); + if (rule.port.IsNullOrEmpty()) { rule.port = null; @@ -627,6 +629,31 @@ public class CoreConfigV2rayService return await Task.FromResult(0); } + private async Task GenRoutingUserRuleOutbound(string outboundTag, V2rayConfig v2rayConfig) + { + if (outboundTag is Global.ProxyTag or Global.ProxyTag or Global.BlockTag) + { + return outboundTag; + } + + var node = await AppHandler.Instance.GetProfileItemViaRemarks(outboundTag); + if (node == null + || node.ConfigType == EConfigType.Custom + || node.ConfigType == EConfigType.Hysteria2 + || node.ConfigType == EConfigType.TUIC) + { + return Global.ProxyTag; + } + + var txtOutbound = EmbedUtils.GetEmbedText(Global.V2raySampleOutbound); + var outbound = JsonUtils.Deserialize(txtOutbound); + await GenOutbound(node, outbound); + outbound.tag = Global.ProxyTag + node.IndexId.ToString(); + v2rayConfig.outbounds.Add(outbound); + + return outbound.tag; + } + private async Task GenOutbound(ProfileItem node, Outbounds4Ray outbound) { try @@ -659,7 +686,7 @@ public class CoreConfigV2rayService { usersItem = vnextItem.users.First(); } - + usersItem.id = node.Id; usersItem.alterId = node.AlterId; usersItem.email = Global.UserEMail; @@ -1318,7 +1345,7 @@ public class CoreConfigV2rayService //Previous proxy var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); - string? prevOutboundTag = null; + string? prevOutboundTag = null; if (prevNode is not null && prevNode.ConfigType != EConfigType.Custom && prevNode.ConfigType != EConfigType.Hysteria2 diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml b/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml index 85ea58e8..460f0107 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml @@ -2,6 +2,7 @@ x:Class="v2rayN.Desktop.Views.RoutingRuleDetailsWindow" xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:ctrls="clr-namespace:v2rayN.Desktop.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib" @@ -22,86 +23,95 @@ + Width="300" + Margin="{StaticResource Margin4}" + HorizontalAlignment="Left" /> + VerticalAlignment="Center" /> - + Text="{Binding SelectedSource.OutboundTag, Mode=TwoWay}" /> + HorizontalAlignment="Left" + VerticalAlignment="Center" + Text="{x:Static resx:ResUI.TbRuleOutboundTagTip}" /> + Width="300" + Margin="{StaticResource Margin4}" + HorizontalAlignment="Left" /> + Text="{x:Static resx:ResUI.TbRuleMatchingTips}" /> + + + + - - - - { Global.ProxyTag, Global.DirectTag, Global.BlockTag }; Global.RuleProtocols.ForEach(it => { clbProtocol.Items.Add(it); @@ -54,7 +52,7 @@ public partial class RoutingRuleDetailsWindow : WindowBase { this.Bind(ViewModel, vm => vm.SelectedSource.Remarks, v => v.txtRemarks.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.OutboundTag, v => v.cmbOutboundTag.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.OutboundTag, v => v.cmbOutboundTag.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Port, v => v.txtPort.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Network, v => v.cmbNetwork.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Enabled, v => v.togEnabled.IsChecked).DisposeWith(disposables); @@ -80,7 +78,7 @@ public partial class RoutingRuleDetailsWindow : WindowBase + HorizontalAlignment="Left" + VerticalAlignment="Center" /> + Text="{x:Static resx:ResUI.TbRuleOutboundTagTip}" /> - - - - - + Style="{StaticResource ToolbarTextBlock}" + Text="{x:Static resx:ResUI.TbRuleMatchingTips}" /> + + + + + + @@ -164,6 +176,7 @@ Grid.Column="2" Margin="{StaticResource Margin4}" HorizontalAlignment="Left" + VerticalAlignment="Center" Style="{StaticResource ToolbarTextBlock}" Text="{x:Static resx:ResUI.TbRoutingTips}" /> diff --git a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs index 58e47c95..72146781 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs @@ -74,7 +74,7 @@ public partial class RoutingRuleDetailsWindow private void Window_Loaded(object sender, RoutedEventArgs e) { - cmbOutboundTag.Focus(); + txtRemarks.Focus(); } private void ClbProtocol_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)