From eac7361a0ba789d5183515d763ac2b915198354b Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sun, 3 Oct 2021 20:19:54 +0800 Subject: [PATCH] rule add enabled --- .../RoutingRuleSettingDetailsForm.Designer.cs | 29 +- .../Forms/RoutingRuleSettingDetailsForm.cs | 3 + .../Forms/RoutingRuleSettingDetailsForm.resx | 978 +++++++++--------- ...RoutingRuleSettingDetailsForm.zh-Hans.resx | 3 + v2rayN/v2rayN/Forms/RoutingRuleSettingForm.cs | 10 +- v2rayN/v2rayN/Handler/ConfigHandler.cs | 6 +- v2rayN/v2rayN/Handler/V2rayConfigHandler.cs | 5 +- v2rayN/v2rayN/Mode/RulesItem.cs | 4 +- v2rayN/v2rayUpgrade/v2rayUpgrade.csproj.user | 2 +- 9 files changed, 547 insertions(+), 493 deletions(-) diff --git a/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.Designer.cs b/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.Designer.cs index 504b60ea..3f0f1e40 100644 --- a/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.Designer.cs +++ b/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.Designer.cs @@ -31,6 +31,7 @@ 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.chkEnabled = new System.Windows.Forms.CheckBox(); this.clbInboundTag = new System.Windows.Forms.CheckedListBox(); this.label2 = new System.Windows.Forms.Label(); this.clbProtocol = new System.Windows.Forms.CheckedListBox(); @@ -62,6 +63,8 @@ // // panel3 // + resources.ApplyResources(this.panel3, "panel3"); + this.panel3.Controls.Add(this.chkEnabled); this.panel3.Controls.Add(this.clbInboundTag); this.panel3.Controls.Add(this.label2); this.panel3.Controls.Add(this.clbProtocol); @@ -71,13 +74,18 @@ this.panel3.Controls.Add(this.labRoutingTips); this.panel3.Controls.Add(this.label4); this.panel3.Controls.Add(this.cmbOutboundTag); - resources.ApplyResources(this.panel3, "panel3"); this.panel3.Name = "panel3"; // + // chkEnabled + // + resources.ApplyResources(this.chkEnabled, "chkEnabled"); + this.chkEnabled.Name = "chkEnabled"; + this.chkEnabled.UseVisualStyleBackColor = true; + // // clbInboundTag // - this.clbInboundTag.CheckOnClick = true; resources.ApplyResources(this.clbInboundTag, "clbInboundTag"); + this.clbInboundTag.CheckOnClick = true; this.clbInboundTag.FormattingEnabled = true; this.clbInboundTag.Items.AddRange(new object[] { resources.GetString("clbInboundTag.Items"), @@ -92,8 +100,8 @@ // // clbProtocol // - this.clbProtocol.CheckOnClick = true; resources.ApplyResources(this.clbProtocol, "clbProtocol"); + this.clbProtocol.CheckOnClick = true; this.clbProtocol.FormattingEnabled = true; this.clbProtocol.Items.AddRange(new object[] { resources.GetString("clbProtocol.Items"), @@ -119,8 +127,8 @@ // // labRoutingTips // - this.labRoutingTips.ForeColor = System.Drawing.Color.Brown; resources.ApplyResources(this.labRoutingTips, "labRoutingTips"); + this.labRoutingTips.ForeColor = System.Drawing.Color.Brown; this.labRoutingTips.Name = "labRoutingTips"; // // label4 @@ -130,26 +138,26 @@ // // cmbOutboundTag // + resources.ApplyResources(this.cmbOutboundTag, "cmbOutboundTag"); this.cmbOutboundTag.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbOutboundTag.FormattingEnabled = true; this.cmbOutboundTag.Items.AddRange(new object[] { resources.GetString("cmbOutboundTag.Items"), resources.GetString("cmbOutboundTag.Items1"), resources.GetString("cmbOutboundTag.Items2")}); - resources.ApplyResources(this.cmbOutboundTag, "cmbOutboundTag"); this.cmbOutboundTag.Name = "cmbOutboundTag"; // // panel4 // + resources.ApplyResources(this.panel4, "panel4"); this.panel4.Controls.Add(this.btnClose); this.panel4.Controls.Add(this.btnOK); - resources.ApplyResources(this.panel4, "panel4"); this.panel4.Name = "panel4"; // // btnClose // - this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; resources.ApplyResources(this.btnClose, "btnClose"); + this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.btnClose.Name = "btnClose"; this.btnClose.UseVisualStyleBackColor = true; this.btnClose.Click += new System.EventHandler(this.btnClose_Click); @@ -163,15 +171,15 @@ // // panel2 // + resources.ApplyResources(this.panel2, "panel2"); this.panel2.Controls.Add(this.groupBox2); this.panel2.Controls.Add(this.groupBox1); - resources.ApplyResources(this.panel2, "panel2"); this.panel2.Name = "panel2"; // // groupBox2 // - this.groupBox2.Controls.Add(this.txtIP); resources.ApplyResources(this.groupBox2, "groupBox2"); + this.groupBox2.Controls.Add(this.txtIP); this.groupBox2.Name = "groupBox2"; this.groupBox2.TabStop = false; // @@ -182,8 +190,8 @@ // // groupBox1 // - this.groupBox1.Controls.Add(this.txtDomain); resources.ApplyResources(this.groupBox1, "groupBox1"); + this.groupBox1.Controls.Add(this.txtDomain); this.groupBox1.Name = "groupBox1"; this.groupBox1.TabStop = false; // @@ -236,5 +244,6 @@ private System.Windows.Forms.CheckedListBox clbProtocol; private System.Windows.Forms.CheckedListBox clbInboundTag; private System.Windows.Forms.Label label2; + private System.Windows.Forms.CheckBox chkEnabled; } } \ No newline at end of file diff --git a/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.cs b/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.cs index 8b861f08..a08e872b 100644 --- a/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.cs +++ b/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.cs @@ -59,6 +59,7 @@ namespace v2rayN.Forms } } rulesItem.protocol = protocol; + rulesItem.enabled = chkEnabled.Checked; } } private void BindingData() @@ -91,6 +92,7 @@ namespace v2rayN.Forms } } } + chkEnabled.Checked = rulesItem.enabled; } } private void ClearBind() @@ -99,6 +101,7 @@ namespace v2rayN.Forms cmbOutboundTag.Text = Global.agentTag; txtDomain.Text = string.Empty; txtIP.Text = string.Empty; + chkEnabled.Checked = true; } private void btnOK_Click(object sender, EventArgs e) { diff --git a/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.resx b/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.resx index 23589990..fe5c1095 100644 --- a/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.resx +++ b/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.resx @@ -117,547 +117,577 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Top - - - 0, 0 - - - 742, 10 - - - - 7 - - - panel1 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 - - - 80 - - - socks - - - http - - - 347, 16 - - - 245, 20 - - - 41 - - - clbInboundTag + + 53, 12 System.Windows.Forms.CheckedListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - panel3 - - - 0 - - - True - - - NoControl - - - 274, 20 - - - 65, 12 - - - 40 - - - inboundTag - - - label2 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 1 - - - 80 - - - http - - - tls - - - bittorrent - - - 347, 43 + + + 32 245, 20 - - 39 - - - clbProtocol - - - System.Windows.Forms.CheckedListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 2 - - - True - - - NoControl - - - 274, 47 - - - 53, 12 - - - 36 - - - Protocol - - - label3 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 3 - - - 107, 43 - - - 119, 21 - - - 35 - - - txtPort - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 4 - - - True - - - NoControl - - - 19, 47 - - - 29, 12 - - - 34 - - - Port - - - label1 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 5 - - - NoControl - - - 19, 82 - - - 598, 16 - - - 33 - - - *Set the rules, separated by commas (,); The comma in the regular is replaced by <COMMA> - - - labRoutingTips - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 6 - - - True - - - NoControl - - - 19, 20 - - - 71, 12 - - - 32 - - - outboundTag - - - label4 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 7 - - - proxy - - - direct - - - block - - - 107, 16 - - - 119, 20 + + 80 31 - - cmbOutboundTag + + proxy - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 4, 4, 4, 4 - - panel3 + + Fill - - 8 + + panel1 - - Top + + 3 - - 0, 10 + + clbProtocol - - 742, 111 + + Protocol - - 8 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - panel3 + + 7 - + + NoControl + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + 3 + + + Left + + + 80 + + + NoControl + + + 0 + + + 29, 12 + + + 1 + + + http + + + panel2 + + + tls + + + RoutingSettingDetailsForm + + + NoControl + + + System.Windows.Forms.CheckedListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 6 + + + Fill + + + 411, 15 + + + 119, 20 + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 36 + + + Bottom + + + 0 + + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 344, 375 + $this - + + 598, 16 + + + groupBox1 + + + NoControl + + 2 + + 5 + + + label1 + + + 742, 395 + + + 0, 0 + + + 9 + + + True + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel3 + + + True + + + 3 + + + panel4 + + + 5 + + + bittorrent + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + socks + + + panel3 + + + 19, 82 + + + 25 + + + 347, 16 + + + 3, 17 + + + panel3 + + + 19, 20 + + + labRoutingTips + + + 19, 47 + + + 39 + + + groupBox1 + + + 1 + + + RoutingRuleSettingDetailsForm + + + panel2 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel3 + + + 107, 43 + + + groupBox2 + + + 8 + + + 1 + + + 386, 375 + + + panel3 + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel2 + + + Fill + + + panel4 + NoControl - - 504, 15 + + Top + + + $this + + + 42 + + + groupBox2 + + + panel3 + + + panel3 + + + System.Windows.Forms.Panel, 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 + + + txtPort + + + 3, 17 + + + 1 + + + 742, 10 + + + 0, 0 + + + 24 + + + Port + + + Enable + + + label4 + + + &OK + + + 75, 23 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel4 + + + 34 + + + 274, 47 + + + 40 + + + block + + + 33 + + + 347, 43 + + + 0 + + + panel3 + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + btnOK + + + 2 + + + 119, 21 + + + 4 + + + 7 + + + 0 + + + 11 + + + 0 + + + panel3 + + + 8 + + + v2rayN.Forms.BaseForm, v2rayN, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + + + label3 + + + inboundTag + + + Top + + + 742, 60 + + + 0, 121 + + + $this + + + *Set the rules, separated by commas (,); The comma in the regular is replaced by <COMMA> + + + 245, 20 + + + 65, 12 + + + btnClose + + + 392, 0 + + + 742, 111 + + + True + + + 6, 12 + + + 0 + + + 617, 19 + + + 0, 10 + + + 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 + + + True + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + txtIP + + + direct + + + label2 + + + 60, 16 + + + cmbOutboundTag + + + chkEnabled + + + True + + + 274, 20 + + + NoControl + + + 742, 576 + + + 10 + + + $this + + + 392, 395 75, 23 - + + clbInboundTag + + 4 &Cancel - - btnClose - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel4 - - - 0 - - + NoControl - - 411, 15 + + NoControl - - 75, 23 - - - 5 - - - &OK - - - btnOK - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel4 - - - 1 - - - Bottom - - - 0, 516 - - - 742, 60 - - - 10 - - - panel4 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - - - Fill - - - 3, 17 - - + True - - 344, 375 - - - 25 - - - txtIP - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox2 - - - 0 - - - Fill - - - 392, 0 - - - 350, 395 - - + 4 - - IP - - - groupBox2 - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel2 - - - 0 - - - Fill - - - 3, 17 - - - True - - - 386, 375 - - - 24 - txtDomain - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 41 - - groupBox1 + + IP - - 0 + + panel3 - - Left + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 0, 0 + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 392, 395 + + 0, 516 - - 3 + + 71, 12 + + + 350, 395 + + + panel3 Domain - - groupBox1 + + Fill + + + 504, 15 + + + 107, 16 + + + outboundTag System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - panel2 - - - 1 - - - Fill - - - 0, 121 - - - 742, 395 - - - 11 - - - panel2 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 + + 35 True - - 6, 12 - - - 742, 576 - - - 4, 4, 4, 4 - - - RoutingSettingDetailsForm - - - RoutingRuleSettingDetailsForm - - - v2rayN.Forms.BaseForm, v2rayN, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - \ No newline at end of file diff --git a/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.zh-Hans.resx b/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.zh-Hans.resx index 15246bd3..f050d4f5 100644 --- a/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.zh-Hans.resx +++ b/v2rayN/v2rayN/Forms/RoutingRuleSettingDetailsForm.zh-Hans.resx @@ -118,6 +118,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 670, 18 + 372, 16 diff --git a/v2rayN/v2rayN/Forms/RoutingRuleSettingForm.cs b/v2rayN/v2rayN/Forms/RoutingRuleSettingForm.cs index 6376feb8..f7957ca2 100644 --- a/v2rayN/v2rayN/Forms/RoutingRuleSettingForm.cs +++ b/v2rayN/v2rayN/Forms/RoutingRuleSettingForm.cs @@ -55,12 +55,13 @@ namespace v2rayN.Forms lvRoutings.HeaderStyle = ColumnHeaderStyle.Clickable; lvRoutings.Columns.Add("", 30); - lvRoutings.Columns.Add("outboundTag", 100); + lvRoutings.Columns.Add("outboundTag", 80); lvRoutings.Columns.Add("port", 80); - lvRoutings.Columns.Add("protocol", 100); - lvRoutings.Columns.Add("inboundTag", 100); + lvRoutings.Columns.Add("protocol", 80); + lvRoutings.Columns.Add("inboundTag", 80); lvRoutings.Columns.Add("domain", 160); - lvRoutings.Columns.Add("ip", 160); + lvRoutings.Columns.Add("ip", 160); + lvRoutings.Columns.Add("enable", 60); lvRoutings.EndUpdate(); } @@ -81,6 +82,7 @@ namespace v2rayN.Forms Utils.AddSubItem(lvItem, "inboundTag", Utils.List2String(item.inboundTag)); Utils.AddSubItem(lvItem, "domain", Utils.List2String(item.domain)); Utils.AddSubItem(lvItem, "ip", Utils.List2String(item.ip)); + Utils.AddSubItem(lvItem, "enable", item.enabled.ToString()); if (lvItem != null) lvRoutings.Items.Add(lvItem); } diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs index 2381a77a..2e11d90f 100644 --- a/v2rayN/v2rayN/Handler/ConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs @@ -51,7 +51,9 @@ namespace v2rayN.Handler enableStatistics = false, // 默认中等刷新率 - statisticsFreshRate = (int)Global.StatisticsFreshRate.medium + statisticsFreshRate = (int)Global.StatisticsFreshRate.medium, + + enableRoutingAdvanced = true }; } @@ -559,7 +561,7 @@ namespace v2rayN.Handler Global.reloadV2ray = true; } } - + if (toFile) { ToJsonFile(config); diff --git a/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs b/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs index 3712c228..61df26d0 100644 --- a/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs @@ -197,7 +197,10 @@ namespace v2rayN.Handler { foreach (var item in config.routings[config.routingIndex].rules) { - routingUserRule(item, ref v2rayConfig); + if (item.enabled) + { + routingUserRule(item, ref v2rayConfig); + } } } } diff --git a/v2rayN/v2rayN/Mode/RulesItem.cs b/v2rayN/v2rayN/Mode/RulesItem.cs index 738a889f..823e970b 100644 --- a/v2rayN/v2rayN/Mode/RulesItem.cs +++ b/v2rayN/v2rayN/Mode/RulesItem.cs @@ -19,7 +19,9 @@ namespace v2rayN.Mode public List domain { get; set; } public List protocol { get; set; } - + + public bool enabled { get; set; } = true; + } } diff --git a/v2rayN/v2rayUpgrade/v2rayUpgrade.csproj.user b/v2rayN/v2rayUpgrade/v2rayUpgrade.csproj.user index 91242901..4890b148 100644 --- a/v2rayN/v2rayUpgrade/v2rayUpgrade.csproj.user +++ b/v2rayN/v2rayUpgrade/v2rayUpgrade.csproj.user @@ -1,6 +1,6 @@  - C:\Githubb\v2rayN\v2rayN\新建ee 文件夹\bin\Debug\v2ray-windows.zip + C:\Githubb\v2rayN\v2rayN\v2rayUpgrade\bin\Debug\v2ray-windows.zip \ No newline at end of file