允许设置去重保留较早或较晚的项

pull/542/head
YFdyh000 2020-03-15 01:56:05 +08:00
parent cf195c7694
commit 5dffb30b27
7 changed files with 57 additions and 7 deletions

View File

@ -558,8 +558,7 @@ namespace v2rayN.Forms
private void menuRemoveDuplicateServer_Click(object sender, EventArgs e)
{
List<Mode.VmessItem> servers = null;
Utils.DedupServerList(config.vmess, out servers);
Utils.DedupServerList(config.vmess, out List<VmessItem> servers, config.keepOlderDedupl);
int oldCount = config.vmess.Count;
int newCount = servers.Count;
if (servers != null)

View File

@ -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;
}
}

View File

@ -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)
//{

View File

@ -1305,6 +1305,36 @@
<data name="chkAllowLANConn.Text" xml:space="preserve">
<value>Allow connections from the LAN</value>
</data>
<data name="chkKeepOlderDedupl.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="chkKeepOlderDedupl.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="chkKeepOlderDedupl.Location" type="System.Drawing.Point, System.Drawing">
<value>15, 110</value>
</data>
<data name="chkKeepOlderDedupl.Size" type="System.Drawing.Size, System.Drawing">
<value>198, 16</value>
</data>
<data name="chkKeepOlderDedupl.TabIndex" type="System.Int32, mscorlib">
<value>33</value>
</data>
<data name="chkKeepOlderDedupl.Text" xml:space="preserve">
<value>Keep older when deduplication</value>
</data>
<data name="&gt;&gt;chkKeepOlderDedupl.Name" xml:space="preserve">
<value>chkKeepOlderDedupl</value>
</data>
<data name="&gt;&gt;chkKeepOlderDedupl.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;chkKeepOlderDedupl.Parent" xml:space="preserve">
<value>tabPage7</value>
</data>
<data name="&gt;&gt;chkKeepOlderDedupl.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="cbFreshrate.Location" type="System.Drawing.Point, System.Drawing">
<value>161, 84</value>
</data>

View File

@ -369,4 +369,7 @@
<data name="$this.Text" xml:space="preserve">
<value>参数设置</value>
</data>
<data name="chkKeepOlderDedupl.Text" xml:space="preserve">
<value>去重时保留序号较小的项</value>
</data>
</root>

View File

@ -138,6 +138,14 @@ namespace v2rayN.Mode
get; set;
}
/// <summary>
/// 去重时优先保留较旧(顶部)节点
/// </summary>
public bool keepOlderDedupl
{
get; set;
}
/// <summary>
/// 视图刷新率
/// </summary>

View File

@ -320,10 +320,10 @@ namespace v2rayN
return $"{string.Format("{0:f1}", result)} {unit}";
}
public static void DedupServerList(List<Mode.VmessItem> source, out List<Mode.VmessItem> result)
public static void DedupServerList(List<Mode.VmessItem> source, out List<Mode.VmessItem> result, bool keepOlder)
{
var list = new List<Mode.VmessItem>();
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;
}