From 5dffb30b27d24adfd47a33b81ee583aacda338fc Mon Sep 17 00:00:00 2001 From: YFdyh000 Date: Sun, 15 Mar 2020 01:56:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=81=E8=AE=B8=E8=AE=BE=E7=BD=AE=E5=8E=BB?= =?UTF-8?q?=E9=87=8D=E4=BF=9D=E7=95=99=E8=BE=83=E6=97=A9=E6=88=96=E8=BE=83?= =?UTF-8?q?=E6=99=9A=E7=9A=84=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v2rayN/v2rayN/Forms/MainForm.cs | 3 +- .../Forms/OptionSettingForm.Designer.cs | 9 ++++++ v2rayN/v2rayN/Forms/OptionSettingForm.cs | 5 ++-- v2rayN/v2rayN/Forms/OptionSettingForm.resx | 30 +++++++++++++++++++ .../Forms/OptionSettingForm.zh-Hans.resx | 3 ++ v2rayN/v2rayN/Mode/Config.cs | 8 +++++ v2rayN/v2rayN/Tool/Utils.cs | 6 ++-- 7 files changed, 57 insertions(+), 7 deletions(-) diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index af4b26d1..b4fe2be4 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -558,8 +558,7 @@ namespace v2rayN.Forms private void menuRemoveDuplicateServer_Click(object sender, EventArgs e) { - List servers = null; - Utils.DedupServerList(config.vmess, out servers); + Utils.DedupServerList(config.vmess, out List servers, config.keepOlderDedupl); int oldCount = config.vmess.Count; int newCount = servers.Count; if (servers != null) diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs b/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs index 8799a79c..797915f1 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs @@ -84,6 +84,7 @@ this.txtKcpmtu = new System.Windows.Forms.TextBox(); this.label6 = new System.Windows.Forms.Label(); this.tabPage7 = new System.Windows.Forms.TabPage(); + this.chkKeepOlderDedupl = new System.Windows.Forms.CheckBox(); this.cbFreshrate = new System.Windows.Forms.ComboBox(); this.lbFreshrate = new System.Windows.Forms.Label(); this.chkEnableStatistics = new System.Windows.Forms.CheckBox(); @@ -510,6 +511,7 @@ // tabPage7 // resources.ApplyResources(this.tabPage7, "tabPage7"); + this.tabPage7.Controls.Add(this.chkKeepOlderDedupl); this.tabPage7.Controls.Add(this.cbFreshrate); this.tabPage7.Controls.Add(this.lbFreshrate); this.tabPage7.Controls.Add(this.chkEnableStatistics); @@ -520,6 +522,12 @@ this.tabPage7.Name = "tabPage7"; this.tabPage7.UseVisualStyleBackColor = true; // + // chkKeepOlderDedupl + // + resources.ApplyResources(this.chkKeepOlderDedupl, "chkKeepOlderDedupl"); + this.chkKeepOlderDedupl.Name = "chkKeepOlderDedupl"; + this.chkKeepOlderDedupl.UseVisualStyleBackColor = true; + // // cbFreshrate // resources.ApplyResources(this.cbFreshrate, "cbFreshrate"); @@ -714,5 +722,6 @@ private System.Windows.Forms.TextBox txtuserPacRule; private System.Windows.Forms.Panel panel4; private System.Windows.Forms.Label label4; + private System.Windows.Forms.CheckBox chkKeepOlderDedupl; } } \ No newline at end of file diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.cs b/v2rayN/v2rayN/Forms/OptionSettingForm.cs index 890041ab..5a717b26 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.cs +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.cs @@ -112,10 +112,10 @@ namespace v2rayN.Forms txturlGFWList.Text = config.urlGFWList; chkAllowLANConn.Checked = config.allowLANConn; + chkEnableStatistics.Checked = config.enableStatistics; + chkKeepOlderDedupl.Checked = config.keepOlderDedupl; - var enableStatistics = config.enableStatistics; - chkEnableStatistics.Checked = enableStatistics; var cbSource = new ComboItem[] @@ -343,6 +343,7 @@ namespace v2rayN.Forms var lastEnableStatistics = config.enableStatistics; config.enableStatistics = chkEnableStatistics.Checked; config.statisticsFreshRate = (int)cbFreshrate.SelectedValue; + config.keepOlderDedupl = chkKeepOlderDedupl.Checked; //if(lastEnableStatistics != config.enableStatistics) //{ diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.resx b/v2rayN/v2rayN/Forms/OptionSettingForm.resx index 0bf6ffbf..5a5b07d7 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.resx +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.resx @@ -1305,6 +1305,36 @@ Allow connections from the LAN + + True + + + NoControl + + + 15, 110 + + + 198, 16 + + + 33 + + + Keep older when deduplication + + + chkKeepOlderDedupl + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage7 + + + 0 + 161, 84 diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx b/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx index 97b2cf9d..4d3d5c37 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx @@ -369,4 +369,7 @@ 参数设置 + + 去重时保留序号较小的项 + \ No newline at end of file diff --git a/v2rayN/v2rayN/Mode/Config.cs b/v2rayN/v2rayN/Mode/Config.cs index 76c6e04f..0674a3f0 100644 --- a/v2rayN/v2rayN/Mode/Config.cs +++ b/v2rayN/v2rayN/Mode/Config.cs @@ -138,6 +138,14 @@ namespace v2rayN.Mode get; set; } + /// + /// 去重时优先保留较旧(顶部)节点 + /// + public bool keepOlderDedupl + { + get; set; + } + /// /// 视图刷新率 /// diff --git a/v2rayN/v2rayN/Tool/Utils.cs b/v2rayN/v2rayN/Tool/Utils.cs index 232d5cff..49474bad 100644 --- a/v2rayN/v2rayN/Tool/Utils.cs +++ b/v2rayN/v2rayN/Tool/Utils.cs @@ -320,10 +320,10 @@ namespace v2rayN return $"{string.Format("{0:f1}", result)} {unit}"; } - public static void DedupServerList(List source, out List result) + public static void DedupServerList(List source, out List result, bool keepOlder) { var list = new List(); - source.Reverse(); // Remove the early items first + if (!keepOlder) source.Reverse(); // Remove the early items first bool _isAdded(Mode.VmessItem o, Mode.VmessItem n) { @@ -348,7 +348,7 @@ namespace v2rayN list.Add(item); } } - list.Reverse(); + if (!keepOlder) list.Reverse(); result = list; }