From bcd051e5a38f52a80ed480229706978d47d6ad72 Mon Sep 17 00:00:00 2001 From: windfallw <51202308+windfallw@users.noreply.github.com> Date: Sun, 23 May 2021 16:14:10 +0800 Subject: [PATCH] routing rule: add inboundTag --- .../RoutingRuleSettingDetailsForm.Designer.cs | 22 ++ .../Forms/RoutingRuleSettingDetailsForm.cs | 21 ++ .../Forms/RoutingRuleSettingDetailsForm.resx | 250 +++++++++++++----- ...RoutingRuleSettingDetailsForm.zh-Hans.resx | 106 +++++++- v2rayN/v2rayN/Forms/RoutingRuleSettingForm.cs | 4 +- 5 files changed, 339 insertions(+), 64 deletions(-) diff --git a/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.Designer.cs b/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.Designer.cs index 9f70e165..81a54d06 100644 --- a/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.Designer.cs +++ b/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.Designer.cs @@ -31,6 +31,8 @@ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RoutingRuleSettingDetailsForm)); this.panel1 = new System.Windows.Forms.Panel(); this.panel3 = new System.Windows.Forms.Panel(); + this.clbInboundTag = new System.Windows.Forms.CheckedListBox(); + this.label2 = new System.Windows.Forms.Label(); this.clbProtocol = new System.Windows.Forms.CheckedListBox(); this.label3 = new System.Windows.Forms.Label(); this.txtPort = new System.Windows.Forms.TextBox(); @@ -61,6 +63,8 @@ // panel3 // resources.ApplyResources(this.panel3, "panel3"); + this.panel3.Controls.Add(this.clbInboundTag); + this.panel3.Controls.Add(this.label2); this.panel3.Controls.Add(this.clbProtocol); this.panel3.Controls.Add(this.label3); this.panel3.Controls.Add(this.txtPort); @@ -70,6 +74,22 @@ this.panel3.Controls.Add(this.cmbOutboundTag); this.panel3.Name = "panel3"; // + // clbInboundTag + // + resources.ApplyResources(this.clbInboundTag, "clbInboundTag"); + this.clbInboundTag.CheckOnClick = true; + this.clbInboundTag.FormattingEnabled = true; + this.clbInboundTag.Items.AddRange(new object[] { + resources.GetString("clbInboundTag.Items"), + resources.GetString("clbInboundTag.Items1")}); + this.clbInboundTag.MultiColumn = true; + this.clbInboundTag.Name = "clbInboundTag"; + // + // label2 + // + resources.ApplyResources(this.label2, "label2"); + this.label2.Name = "label2"; + // // clbProtocol // resources.ApplyResources(this.clbProtocol, "clbProtocol"); @@ -214,5 +234,7 @@ private System.Windows.Forms.TextBox txtPort; private System.Windows.Forms.Label label3; private System.Windows.Forms.CheckedListBox clbProtocol; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.CheckedListBox clbInboundTag; } } \ No newline at end of file diff --git a/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.cs b/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.cs index a11e589d..8b861f08 100644 --- a/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.cs +++ b/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.cs @@ -36,6 +36,16 @@ namespace v2rayN.Forms if (rulesItem != null) { rulesItem.port = txtPort.Text.TrimEx(); + + var inboundTag = new List(); + for (int i = 0; i < clbInboundTag.Items.Count; i++) + { + if (clbInboundTag.GetItemChecked(i)) + { + inboundTag.Add(clbInboundTag.Items[i].ToString()); + } + } + rulesItem.inboundTag = inboundTag; rulesItem.outboundTag = cmbOutboundTag.Text; rulesItem.domain = Utils.String2List(txtDomain.Text); rulesItem.ip = Utils.String2List(txtIP.Text); @@ -60,6 +70,17 @@ namespace v2rayN.Forms txtDomain.Text = Utils.List2String(rulesItem.domain, true); txtIP.Text = Utils.List2String(rulesItem.ip, true); + if (rulesItem.inboundTag != null) + { + for (int i = 0; i < clbInboundTag.Items.Count; i++) + { + if (rulesItem.inboundTag.Contains(clbInboundTag.Items[i].ToString())) + { + clbInboundTag.SetItemChecked(i, true); + } + } + } + if (rulesItem.protocol != null) { for (int i = 0; i < clbProtocol.Items.Count; i++) diff --git a/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.resx b/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.resx index 9070a6d9..b64b2d4f 100644 --- a/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.resx +++ b/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.resx @@ -124,6 +124,9 @@ System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + System.Windows.Forms.CheckedListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 32 @@ -147,8 +150,8 @@ Fill - - panel1 + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 3 @@ -156,20 +159,20 @@ clbProtocol - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 0 - 4 + 6 NoControl - - 3, 17 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 0 + + socks Left @@ -186,8 +189,11 @@ 29, 12 - - 742, 576 + + 0 + + + tls panel2 @@ -198,14 +204,20 @@ RoutingSettingDetailsForm + + socks + NoControl - - Fill + + System.Windows.Forms.CheckedListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 40 - 3 + 5 Fill @@ -222,6 +234,9 @@ 36 + + Bottom + 0 @@ -234,8 +249,8 @@ $this - - 598, 16 + + groupBox1 groupBox1 @@ -243,6 +258,9 @@ NoControl + + 1 + 0, 121 @@ -256,17 +274,23 @@ Protocol - 6 + 8 panel3 + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + True 3 + + 40 + panel4 @@ -276,15 +300,30 @@ bittorrent + + http + + + True + 19, 82 25 + + 372, 20 + + + 3, 17 + panel3 + + 1 + 0, 0 @@ -303,6 +342,9 @@ Fill + + direct + 1 @@ -318,17 +360,17 @@ panel3 - - 107, 43 + + proxy groupBox2 - 5 + 7 - - Bottom + + 1 386, 375 @@ -339,8 +381,11 @@ 392, 0 - - 8 + + panel3 + + + http System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -348,17 +393,20 @@ panel2 + + Fill + panel4 - - System.Windows.Forms.CheckedListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - NoControl - - Top + + bittorrent + + + 598, 16 $this @@ -366,12 +414,27 @@ groupBox2 + + panel3 + + + panel3 + + + 1 + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + panel3 + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 2 + http @@ -390,26 +453,26 @@ 0, 0 - - groupBox1 - 24 + + cmbinboundTag + 11 label4 + + panel3 + &OK - - 75, 23 - - - btnClose + + block System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -420,17 +483,23 @@ 34 + + 71, 12 + 274, 47 + + 41 + block - - 33 + + null - - 1 + + 367, 16 347, 43 @@ -456,11 +525,8 @@ 7 - - 0 - - - label3 + + 1 0 @@ -468,29 +534,41 @@ panel3 - - panel3 + + 8 v2rayN.Forms.BaseForm, v2rayN, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - 0, 10 + + label3 80 + + comboBox1 + + + 504, 15 + 742, 60 System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + null + $this - - &Cancel + + label2 + + + btnClose *Set the rules, separated by commas (,); The comma in the regular is replaced by <COMMA> @@ -507,12 +585,24 @@ Port + + 0, 10 + + + 40 + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + http + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -520,34 +610,55 @@ txtIP - 2 + 4 + + + 107, 43 cmbOutboundTag - - True + + panel1 + + + 279, 20 NoControl - - Domain + + 742, 576 10 + + 367, 16 + $this 392, 395 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 75, 23 + + clbInboundTag + - 1 + 3 + + + Top + + + &Cancel True @@ -555,12 +666,21 @@ 4 + + 75, 23 + txtDomain + + 42 + IP + + panel3 + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -570,8 +690,11 @@ 0, 516 - - 71, 12 + + 33 + + + cmbInboundTag 350, 395 @@ -579,8 +702,11 @@ panel3 - - 504, 15 + + Domain + + + 367, 16 True diff --git a/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.zh-Hans.resx b/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.zh-Hans.resx index 80928b68..a1eb9933 100644 --- a/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.zh-Hans.resx +++ b/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.zh-Hans.resx @@ -117,25 +117,129 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 989, 10 + + + + 80 + + + socks + + + http + + + 372, 15 + + + 272, 24 + + + True + + + + NoControl + + + 87, 15 + + + inboundTag + + + 372, 47 + + + 272, 24 + + + 279, 46 + + + 71, 15 + + + 120, 46 + + + 119, 25 + + + 19, 46 + + + 39, 15 + *设置的路由规则,用逗号(,)分隔;正则中的逗号用<COMMA>替代 + + 95, 15 + OutboundTag + + 120, 16 + + + 119, 23 + + + 989, 111 + 取消(&C) 确定(&O) - + + 0, 660 + + + 989, 60 + + + 3, 21 + Vertical + + 591, 515 + + + 597, 539 + + + 3, 21 + Vertical + + 386, 515 + + + 392, 539 + + + 989, 539 + + + 8, 15 + + + 989, 720 + + + 5, 5, 5, 5 + 路由规则详情设置 diff --git a/v2rayN/v2rayN/Forms/RoutingRuleSettingForm.cs b/v2rayN/v2rayN/Forms/RoutingRuleSettingForm.cs index b4384682..ca703f77 100644 --- a/v2rayN/v2rayN/Forms/RoutingRuleSettingForm.cs +++ b/v2rayN/v2rayN/Forms/RoutingRuleSettingForm.cs @@ -55,7 +55,8 @@ namespace v2rayN.Forms lvRoutings.HeaderStyle = ColumnHeaderStyle.Clickable; lvRoutings.Columns.Add("", 30); - lvRoutings.Columns.Add("outboundTag", 80); + lvRoutings.Columns.Add("inboundTag", 100); + lvRoutings.Columns.Add("outboundTag", 100); lvRoutings.Columns.Add("port", 80); lvRoutings.Columns.Add("protocol", 100); lvRoutings.Columns.Add("domain", 160); @@ -74,6 +75,7 @@ namespace v2rayN.Forms var item = routingItem.rules[k]; ListViewItem lvItem = new ListViewItem(""); + Utils.AddSubItem(lvItem, "inboundTag", Utils.List2String(item.inboundTag)); Utils.AddSubItem(lvItem, "outboundTag", item.outboundTag); Utils.AddSubItem(lvItem, "port", item.port); Utils.AddSubItem(lvItem, "protocol", Utils.List2String(item.protocol));