Compare commits

...

6 Commits
4.22 ... 4.24

Author SHA1 Message Date
2dust
c29ccf76d5 Update AssemblyInfo.cs 2021-11-17 20:54:40 +08:00
2dust
5907bf388c Speed test via memory storage 2021-11-17 20:54:19 +08:00
2dust
54adaffb92 Optimize performance 2021-11-17 20:52:45 +08:00
2dust
3bc7812e1a Update AssemblyInfo.cs 2021-10-16 20:50:27 +08:00
2dust
16cd9706f9 Automatically update the geo file time from minutes to hours 2021-10-16 20:49:28 +08:00
2dust
839d07870c Loading GUI configuration file is abnormal 2021-10-16 20:16:50 +08:00
10 changed files with 1670 additions and 1604 deletions

View File

@@ -41,7 +41,12 @@ namespace v2rayN.Forms
private void MainForm_Load(object sender, EventArgs e) private void MainForm_Load(object sender, EventArgs e)
{ {
ConfigHandler.LoadConfig(ref config); if (ConfigHandler.LoadConfig(ref config) != 0)
{
UI.ShowWarning($"Loading GUI configuration file is abnormal,please restart the application{Environment.NewLine}加载GUI配置文件异常,请重启应用");
Environment.Exit(0);
return;
}
ConfigHandler.InitBuiltinRouting(ref config); ConfigHandler.InitBuiltinRouting(ref config);
MainFormHandler.Instance.BackupGuiNConfig(config, true); MainFormHandler.Instance.BackupGuiNConfig(config, true);
v2rayHandler = new V2rayHandler(); v2rayHandler = new V2rayHandler();
@@ -573,13 +578,11 @@ namespace v2rayN.Forms
{ {
return; return;
} }
for (int k = lvSelecteds.Count - 1; k >= 0; k--)
{ ConfigHandler.RemoveServer(ref config, lvSelecteds);
ConfigHandler.RemoveServer(ref config, lvSelecteds[k]);
}
RefreshServers(); RefreshServers();
LoadV2ray(); LoadV2ray();
} }
private void menuRemoveDuplicateServer_Click(object sender, EventArgs e) private void menuRemoveDuplicateServer_Click(object sender, EventArgs e)

View File

@@ -101,33 +101,32 @@
// //
// btnClose // btnClose
// //
resources.ApplyResources(this.btnClose, "btnClose");
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
resources.ApplyResources(this.btnClose, "btnClose");
this.btnClose.Name = "btnClose"; this.btnClose.Name = "btnClose";
this.btnClose.UseVisualStyleBackColor = true; this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click); this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
// //
// tabControl1 // tabControl1
// //
resources.ApplyResources(this.tabControl1, "tabControl1");
this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2); this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage6); this.tabControl1.Controls.Add(this.tabPage6);
this.tabControl1.Controls.Add(this.tabPage7); this.tabControl1.Controls.Add(this.tabPage7);
this.tabControl1.Controls.Add(this.tabPage3); this.tabControl1.Controls.Add(this.tabPage3);
resources.ApplyResources(this.tabControl1, "tabControl1");
this.tabControl1.Name = "tabControl1"; this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0; this.tabControl1.SelectedIndex = 0;
// //
// tabPage1 // tabPage1
// //
resources.ApplyResources(this.tabPage1, "tabPage1");
this.tabPage1.Controls.Add(this.groupBox1); this.tabPage1.Controls.Add(this.groupBox1);
resources.ApplyResources(this.tabPage1, "tabPage1");
this.tabPage1.Name = "tabPage1"; this.tabPage1.Name = "tabPage1";
this.tabPage1.UseVisualStyleBackColor = true; this.tabPage1.UseVisualStyleBackColor = true;
// //
// groupBox1 // groupBox1
// //
resources.ApplyResources(this.groupBox1, "groupBox1");
this.groupBox1.Controls.Add(this.chkdefAllowInsecure); this.groupBox1.Controls.Add(this.chkdefAllowInsecure);
this.groupBox1.Controls.Add(this.chksniffingEnabled2); this.groupBox1.Controls.Add(this.chksniffingEnabled2);
this.groupBox1.Controls.Add(this.chksniffingEnabled); this.groupBox1.Controls.Add(this.chksniffingEnabled);
@@ -145,6 +144,7 @@
this.groupBox1.Controls.Add(this.label5); this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.txtlocalPort); this.groupBox1.Controls.Add(this.txtlocalPort);
this.groupBox1.Controls.Add(this.label2); this.groupBox1.Controls.Add(this.label2);
resources.ApplyResources(this.groupBox1, "groupBox1");
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
// //
@@ -187,12 +187,12 @@
// //
// cmbprotocol2 // cmbprotocol2
// //
resources.ApplyResources(this.cmbprotocol2, "cmbprotocol2");
this.cmbprotocol2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbprotocol2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbprotocol2.FormattingEnabled = true; this.cmbprotocol2.FormattingEnabled = true;
this.cmbprotocol2.Items.AddRange(new object[] { this.cmbprotocol2.Items.AddRange(new object[] {
resources.GetString("cmbprotocol2.Items"), resources.GetString("cmbprotocol2.Items"),
resources.GetString("cmbprotocol2.Items1")}); resources.GetString("cmbprotocol2.Items1")});
resources.ApplyResources(this.cmbprotocol2, "cmbprotocol2");
this.cmbprotocol2.Name = "cmbprotocol2"; this.cmbprotocol2.Name = "cmbprotocol2";
// //
// label3 // label3
@@ -207,8 +207,8 @@
// //
// cmbprotocol // cmbprotocol
// //
resources.ApplyResources(this.cmbprotocol, "cmbprotocol");
this.cmbprotocol.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbprotocol.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
resources.ApplyResources(this.cmbprotocol, "cmbprotocol");
this.cmbprotocol.FormattingEnabled = true; this.cmbprotocol.FormattingEnabled = true;
this.cmbprotocol.Items.AddRange(new object[] { this.cmbprotocol.Items.AddRange(new object[] {
resources.GetString("cmbprotocol.Items"), resources.GetString("cmbprotocol.Items"),
@@ -234,7 +234,6 @@
// //
// cmbloglevel // cmbloglevel
// //
resources.ApplyResources(this.cmbloglevel, "cmbloglevel");
this.cmbloglevel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbloglevel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbloglevel.FormattingEnabled = true; this.cmbloglevel.FormattingEnabled = true;
this.cmbloglevel.Items.AddRange(new object[] { this.cmbloglevel.Items.AddRange(new object[] {
@@ -243,6 +242,7 @@
resources.GetString("cmbloglevel.Items2"), resources.GetString("cmbloglevel.Items2"),
resources.GetString("cmbloglevel.Items3"), resources.GetString("cmbloglevel.Items3"),
resources.GetString("cmbloglevel.Items4")}); resources.GetString("cmbloglevel.Items4")});
resources.ApplyResources(this.cmbloglevel, "cmbloglevel");
this.cmbloglevel.Name = "cmbloglevel"; this.cmbloglevel.Name = "cmbloglevel";
// //
// label5 // label5
@@ -262,10 +262,10 @@
// //
// tabPage2 // tabPage2
// //
resources.ApplyResources(this.tabPage2, "tabPage2");
this.tabPage2.Controls.Add(this.linkDnsObjectDoc); this.tabPage2.Controls.Add(this.linkDnsObjectDoc);
this.tabPage2.Controls.Add(this.txtremoteDNS); this.tabPage2.Controls.Add(this.txtremoteDNS);
this.tabPage2.Controls.Add(this.label14); this.tabPage2.Controls.Add(this.label14);
resources.ApplyResources(this.tabPage2, "tabPage2");
this.tabPage2.Name = "tabPage2"; this.tabPage2.Name = "tabPage2";
this.tabPage2.UseVisualStyleBackColor = true; this.tabPage2.UseVisualStyleBackColor = true;
// //
@@ -288,7 +288,6 @@
// //
// tabPage6 // tabPage6
// //
resources.ApplyResources(this.tabPage6, "tabPage6");
this.tabPage6.Controls.Add(this.chkKcpcongestion); this.tabPage6.Controls.Add(this.chkKcpcongestion);
this.tabPage6.Controls.Add(this.txtKcpwriteBufferSize); this.tabPage6.Controls.Add(this.txtKcpwriteBufferSize);
this.tabPage6.Controls.Add(this.label10); this.tabPage6.Controls.Add(this.label10);
@@ -302,6 +301,7 @@
this.tabPage6.Controls.Add(this.label7); this.tabPage6.Controls.Add(this.label7);
this.tabPage6.Controls.Add(this.txtKcpmtu); this.tabPage6.Controls.Add(this.txtKcpmtu);
this.tabPage6.Controls.Add(this.label6); this.tabPage6.Controls.Add(this.label6);
resources.ApplyResources(this.tabPage6, "tabPage6");
this.tabPage6.Name = "tabPage6"; this.tabPage6.Name = "tabPage6";
this.tabPage6.UseVisualStyleBackColor = true; this.tabPage6.UseVisualStyleBackColor = true;
// //
@@ -373,7 +373,6 @@
// //
// tabPage7 // tabPage7
// //
resources.ApplyResources(this.tabPage7, "tabPage7");
this.tabPage7.Controls.Add(this.txtautoUpdateInterval); this.tabPage7.Controls.Add(this.txtautoUpdateInterval);
this.tabPage7.Controls.Add(this.label15); this.tabPage7.Controls.Add(this.label15);
this.tabPage7.Controls.Add(this.chkIgnoreGeoUpdateCore); this.tabPage7.Controls.Add(this.chkIgnoreGeoUpdateCore);
@@ -385,6 +384,7 @@
this.tabPage7.Controls.Add(this.chkEnableStatistics); this.tabPage7.Controls.Add(this.chkEnableStatistics);
this.tabPage7.Controls.Add(this.chkAllowLANConn); this.tabPage7.Controls.Add(this.chkAllowLANConn);
this.tabPage7.Controls.Add(this.chkAutoRun); this.tabPage7.Controls.Add(this.chkAutoRun);
resources.ApplyResources(this.tabPage7, "tabPage7");
this.tabPage7.Name = "tabPage7"; this.tabPage7.Name = "tabPage7";
this.tabPage7.UseVisualStyleBackColor = true; this.tabPage7.UseVisualStyleBackColor = true;
// //
@@ -406,12 +406,12 @@
// //
// cmbCoreType // cmbCoreType
// //
resources.ApplyResources(this.cmbCoreType, "cmbCoreType");
this.cmbCoreType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbCoreType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbCoreType.FormattingEnabled = true; this.cmbCoreType.FormattingEnabled = true;
this.cmbCoreType.Items.AddRange(new object[] { this.cmbCoreType.Items.AddRange(new object[] {
resources.GetString("cmbCoreType.Items"), resources.GetString("cmbCoreType.Items"),
resources.GetString("cmbCoreType.Items1")}); resources.GetString("cmbCoreType.Items1")});
resources.ApplyResources(this.cmbCoreType, "cmbCoreType");
this.cmbCoreType.Name = "cmbCoreType"; this.cmbCoreType.Name = "cmbCoreType";
// //
// label4 // label4
@@ -427,9 +427,9 @@
// //
// cbFreshrate // cbFreshrate
// //
resources.ApplyResources(this.cbFreshrate, "cbFreshrate");
this.cbFreshrate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbFreshrate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbFreshrate.FormattingEnabled = true; this.cbFreshrate.FormattingEnabled = true;
resources.ApplyResources(this.cbFreshrate, "cbFreshrate");
this.cbFreshrate.Name = "cbFreshrate"; this.cbFreshrate.Name = "cbFreshrate";
// //
// lbFreshrate // lbFreshrate
@@ -457,17 +457,17 @@
// //
// tabPage3 // tabPage3
// //
resources.ApplyResources(this.tabPage3, "tabPage3");
this.tabPage3.Controls.Add(this.groupBox2); this.tabPage3.Controls.Add(this.groupBox2);
resources.ApplyResources(this.tabPage3, "tabPage3");
this.tabPage3.Name = "tabPage3"; this.tabPage3.Name = "tabPage3";
this.tabPage3.UseVisualStyleBackColor = true; this.tabPage3.UseVisualStyleBackColor = true;
// //
// groupBox2 // groupBox2
// //
resources.ApplyResources(this.groupBox2, "groupBox2");
this.groupBox2.Controls.Add(this.label13); this.groupBox2.Controls.Add(this.label13);
this.groupBox2.Controls.Add(this.label12); this.groupBox2.Controls.Add(this.label12);
this.groupBox2.Controls.Add(this.txtsystemProxyExceptions); this.groupBox2.Controls.Add(this.txtsystemProxyExceptions);
resources.ApplyResources(this.groupBox2, "groupBox2");
this.groupBox2.Name = "groupBox2"; this.groupBox2.Name = "groupBox2";
this.groupBox2.TabStop = false; this.groupBox2.TabStop = false;
// //
@@ -488,9 +488,9 @@
// //
// panel2 // panel2
// //
resources.ApplyResources(this.panel2, "panel2");
this.panel2.Controls.Add(this.btnClose); this.panel2.Controls.Add(this.btnClose);
this.panel2.Controls.Add(this.btnOK); this.panel2.Controls.Add(this.btnOK);
resources.ApplyResources(this.panel2, "panel2");
this.panel2.Name = "panel2"; this.panel2.Name = "panel2";
// //
// btnOK // btnOK

File diff suppressed because it is too large Load Diff

View File

@@ -121,90 +121,15 @@
<value>取消(&amp;C)</value> <value>取消(&amp;C)</value>
</data> </data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="tabControl1.Size" type="System.Drawing.Size, System.Drawing">
<value>662, 469</value>
</data>
<data name="tabPage1.Size" type="System.Drawing.Size, System.Drawing"> <data name="tabPage1.Size" type="System.Drawing.Size, System.Drawing">
<value>654, 443</value> <value>654, 443</value>
</data> </data>
<data name="tabPage1.Text" xml:space="preserve"> <data name="tabPage1.Text" xml:space="preserve">
<value> Core:基础设置 </value> <value> Core:基础设置 </value>
</data> </data>
<data name="tabPage2.Size" type="System.Drawing.Size, System.Drawing">
<value>654, 443</value>
</data>
<data name="tabPage2.Text" xml:space="preserve">
<value> Core:DNS设置 </value>
</data>
<data name="tabPage6.Size" type="System.Drawing.Size, System.Drawing">
<value>654, 443</value>
</data>
<data name="tabPage6.Text" xml:space="preserve">
<value> Core:KCP设置 </value>
</data>
<data name="txtautoUpdateInterval.Location" type="System.Drawing.Point, System.Drawing">
<value>255, 156</value>
</data>
<data name="label15.Size" type="System.Drawing.Size, System.Drawing">
<value>191, 12</value>
</data>
<data name="label15.Text" xml:space="preserve">
<value>自动更新Geo文件的间隔(单位分钟)</value>
</data>
<data name="chkIgnoreGeoUpdateCore.Size" type="System.Drawing.Size, System.Drawing">
<value>150, 16</value>
</data>
<data name="chkIgnoreGeoUpdateCore.Text" xml:space="preserve">
<value>更新Core时忽略Geo文件</value>
</data>
<data name="label4.Size" type="System.Drawing.Size, System.Drawing">
<value>53, 12</value>
</data>
<data name="label4.Text" xml:space="preserve">
<value>Core类型</value>
</data>
<data name="chkKeepOlderDedupl.Size" type="System.Drawing.Size, System.Drawing">
<value>156, 16</value>
</data>
<data name="chkKeepOlderDedupl.Text" xml:space="preserve">
<value>去重时保留序号较小的项</value>
</data>
<data name="lbFreshrate.Size" type="System.Drawing.Size, System.Drawing">
<value>77, 12</value>
</data>
<data name="lbFreshrate.Text" xml:space="preserve">
<value>统计刷新频率</value>
</data>
<data name="chkEnableStatistics.Size" type="System.Drawing.Size, System.Drawing">
<value>372, 16</value>
</data>
<data name="chkEnableStatistics.Text" xml:space="preserve">
<value>启用统计(实时网速显示和使用流量显示需要重启v2rayN客户端)</value>
</data>
<data name="chkAllowLANConn.Size" type="System.Drawing.Size, System.Drawing">
<value>144, 16</value>
</data>
<data name="chkAllowLANConn.Text" xml:space="preserve">
<value>允许来自局域网的连接</value>
</data>
<data name="chkAutoRun.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 16</value>
</data>
<data name="chkAutoRun.Text" xml:space="preserve">
<value>开机自动启动(可能会不成功)</value>
</data>
<data name="tabPage7.Size" type="System.Drawing.Size, System.Drawing">
<value>654, 443</value>
</data>
<data name="tabPage7.Text" xml:space="preserve">
<value> v2rayN设置 </value>
</data>
<data name="tabPage3.Size" type="System.Drawing.Size, System.Drawing">
<value>654, 443</value>
</data>
<data name="tabPage3.Text" xml:space="preserve">
<value> 系统代理设置 </value>
</data>
<data name="tabControl1.Size" type="System.Drawing.Size, System.Drawing">
<value>662, 469</value>
</data>
<data name="groupBox1.Size" type="System.Drawing.Size, System.Drawing"> <data name="groupBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>648, 437</value> <value>648, 437</value>
</data> </data>
@@ -280,6 +205,12 @@
<data name="label2.Text" xml:space="preserve"> <data name="label2.Text" xml:space="preserve">
<value>本地监听端口</value> <value>本地监听端口</value>
</data> </data>
<data name="tabPage2.Size" type="System.Drawing.Size, System.Drawing">
<value>654, 443</value>
</data>
<data name="tabPage2.Text" xml:space="preserve">
<value> Core:DNS设置 </value>
</data>
<data name="linkDnsObjectDoc.Size" type="System.Drawing.Size, System.Drawing"> <data name="linkDnsObjectDoc.Size" type="System.Drawing.Size, System.Drawing">
<value>161, 12</value> <value>161, 12</value>
</data> </data>
@@ -292,6 +223,75 @@
<data name="label14.Text" xml:space="preserve"> <data name="label14.Text" xml:space="preserve">
<value>自定义DNS(可多个,用逗号(,)隔开)</value> <value>自定义DNS(可多个,用逗号(,)隔开)</value>
</data> </data>
<data name="tabPage6.Size" type="System.Drawing.Size, System.Drawing">
<value>654, 443</value>
</data>
<data name="tabPage6.Text" xml:space="preserve">
<value> Core:KCP设置 </value>
</data>
<data name="tabPage7.Size" type="System.Drawing.Size, System.Drawing">
<value>654, 443</value>
</data>
<data name="tabPage7.Text" xml:space="preserve">
<value> v2rayN设置 </value>
</data>
<data name="txtautoUpdateInterval.Location" type="System.Drawing.Point, System.Drawing">
<value>255, 156</value>
</data>
<data name="label15.Size" type="System.Drawing.Size, System.Drawing">
<value>191, 12</value>
</data>
<data name="label15.Text" xml:space="preserve">
<value>自动更新Geo文件的间隔(单位小时)</value>
</data>
<data name="chkIgnoreGeoUpdateCore.Size" type="System.Drawing.Size, System.Drawing">
<value>150, 16</value>
</data>
<data name="chkIgnoreGeoUpdateCore.Text" xml:space="preserve">
<value>更新Core时忽略Geo文件</value>
</data>
<data name="label4.Size" type="System.Drawing.Size, System.Drawing">
<value>53, 12</value>
</data>
<data name="label4.Text" xml:space="preserve">
<value>Core类型</value>
</data>
<data name="chkKeepOlderDedupl.Size" type="System.Drawing.Size, System.Drawing">
<value>156, 16</value>
</data>
<data name="chkKeepOlderDedupl.Text" xml:space="preserve">
<value>去重时保留序号较小的项</value>
</data>
<data name="lbFreshrate.Size" type="System.Drawing.Size, System.Drawing">
<value>77, 12</value>
</data>
<data name="lbFreshrate.Text" xml:space="preserve">
<value>统计刷新频率</value>
</data>
<data name="chkEnableStatistics.Size" type="System.Drawing.Size, System.Drawing">
<value>372, 16</value>
</data>
<data name="chkEnableStatistics.Text" xml:space="preserve">
<value>启用统计(实时网速显示和使用流量显示需要重启v2rayN客户端)</value>
</data>
<data name="chkAllowLANConn.Size" type="System.Drawing.Size, System.Drawing">
<value>144, 16</value>
</data>
<data name="chkAllowLANConn.Text" xml:space="preserve">
<value>允许来自局域网的连接</value>
</data>
<data name="chkAutoRun.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 16</value>
</data>
<data name="chkAutoRun.Text" xml:space="preserve">
<value>开机自动启动(可能会不成功)</value>
</data>
<data name="tabPage3.Size" type="System.Drawing.Size, System.Drawing">
<value>654, 443</value>
</data>
<data name="tabPage3.Text" xml:space="preserve">
<value> 系统代理设置 </value>
</data>
<data name="groupBox2.Size" type="System.Drawing.Size, System.Drawing"> <data name="groupBox2.Size" type="System.Drawing.Size, System.Drawing">
<value>654, 443</value> <value>654, 443</value>
</data> </data>

View File

@@ -32,6 +32,15 @@ namespace v2rayN.Handler
//转成Json //转成Json
config = Utils.FromJson<Config>(result); config = Utils.FromJson<Config>(result);
} }
else
{
if (File.Exists(Utils.GetPath(configRes)))
{
Utils.SaveLog("LoadConfig Exception");
return -1;
}
}
if (config == null) if (config == null)
{ {
config = new Config config = new Config
@@ -227,19 +236,27 @@ namespace v2rayN.Handler
/// <param name="config"></param> /// <param name="config"></param>
/// <param name="index"></param> /// <param name="index"></param>
/// <returns></returns> /// <returns></returns>
public static int RemoveServer(ref Config config, int index) public static int RemoveServer(ref Config config, List<int> indexs)
{ {
if (index < 0 || index > config.vmess.Count - 1) var itemId = config.getItemId();
for (int k = indexs.Count - 1; k >= 0; k--)
{ {
return -1; var index = indexs[k];
if (index < 0 || index > config.vmess.Count - 1)
{
continue;
}
config.vmess.RemoveAt(index);
} }
//删除 var index_ = config.vmess.FindIndex(it => it.getItemId() == itemId);
config.vmess.RemoveAt(index); if (index_ >= 0)
{
config.index = index_;
//移除的是活动的 }
if (config.index.Equals(index)) else
{ {
if (config.vmess.Count > 0) if (config.vmess.Count > 0)
{ {
@@ -249,13 +266,8 @@ namespace v2rayN.Handler
{ {
config.index = -1; config.index = -1;
} }
Global.reloadV2ray = true;
}
else if (index < config.index)//移除活动之前的
{
config.index--;
Global.reloadV2ray = true;
} }
Global.reloadV2ray = true;
ToJsonFile(config); ToJsonFile(config);

View File

@@ -62,7 +62,7 @@ namespace v2rayN.Handler
} }
return ws; return ws;
} }
void ws_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) void ws_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{ {
if (UpdateCompleted != null) if (UpdateCompleted != null)
@@ -108,7 +108,7 @@ namespace v2rayN.Handler
if (e.Error == null if (e.Error == null
|| Utils.IsNullOrEmpty(e.Error.ToString())) || Utils.IsNullOrEmpty(e.Error.ToString()))
{ {
((WebClientEx)sender).Dispose();
TimeSpan ts = (DateTime.Now - totalDatetime); TimeSpan ts = (DateTime.Now - totalDatetime);
string speed = string.Format("{0} M/s", (totalBytesToReceive / ts.TotalMilliseconds / 1000).ToString("#0.0")); string speed = string.Format("{0} M/s", (totalBytesToReceive / ts.TotalMilliseconds / 1000).ToString("#0.0"));
UpdateCompleted(this, new ResultEventArgs(true, speed.PadLeft(8, ' '))); UpdateCompleted(this, new ResultEventArgs(true, speed.PadLeft(8, ' ')));
@@ -189,5 +189,34 @@ namespace v2rayN.Handler
} }
} }
public WebClientEx DownloadDataAsync(string url, WebProxy webProxy, int downloadTimeout)
{
WebClientEx ws = new WebClientEx();
try
{
Utils.SetSecurityProtocol();
UpdateCompleted?.Invoke(this, new ResultEventArgs(false, UIRes.I18N("Downloading")));
progressPercentage = -1;
totalBytesToReceive = 0;
DownloadTimeout = downloadTimeout;
if (webProxy != null)
{
ws.Proxy = webProxy;
}
ws.DownloadProgressChanged += ws_DownloadProgressChanged;
ws.DownloadDataCompleted += ws_DownloadFileCompleted;
ws.DownloadDataAsync(new Uri(url));
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
Error?.Invoke(this, new ErrorEventArgs(ex));
}
return ws;
}
} }
} }

View File

@@ -242,7 +242,7 @@ namespace v2rayN.Handler
Utils.SaveLog("geoip" + msg); Utils.SaveLog("geoip" + msg);
}); });
Thread.Sleep(60000 * config.autoUpdateInterval); Thread.Sleep(1000 * 3600 * config.autoUpdateInterval);
} }
} }
} }

View File

@@ -220,11 +220,12 @@ namespace v2rayN.Handler
int httpPort = _config.GetLocalPort("speedtest"); int httpPort = _config.GetLocalPort("speedtest");
WebProxy webProxy = new WebProxy(Global.Loopback, httpPort + itemIndex); WebProxy webProxy = new WebProxy(Global.Loopback, httpPort + itemIndex);
var ws = downloadHandle2.DownloadFileAsync(url, webProxy, timeout - 2); var ws = downloadHandle2.DownloadDataAsync(url, webProxy, timeout - 2);
Thread.Sleep(1000 * timeout); Thread.Sleep(1000 * timeout);
ws.CancelAsync(); ws.CancelAsync();
ws.Dispose();
Thread.Sleep(1000 * 2); Thread.Sleep(1000 * 2);
} }

View File

@@ -32,4 +32,4 @@ using System.Runtime.InteropServices;
// 方法是按如下所示使用“*”: // 方法是按如下所示使用“*”:
//[assembly: AssemblyVersion("1.0.*")] //[assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0")] //[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("4.22")] [assembly: AssemblyFileVersion("4.24")]

View File

@@ -47,8 +47,9 @@ namespace v2rayN
result = reader.ReadToEnd(); result = reader.ReadToEnd();
} }
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
} }
return result; return result;
} }
@@ -69,8 +70,9 @@ namespace v2rayN
result = reader.ReadToEnd(); result = reader.ReadToEnd();
} }
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
} }
return result; return result;
} }
@@ -108,8 +110,9 @@ namespace v2rayN
Formatting.Indented, Formatting.Indented,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
} }
return result; return result;
} }
@@ -141,8 +144,9 @@ namespace v2rayN
} }
result = 0; result = 0;
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
result = -1; result = -1;
} }
return result; return result;
@@ -155,8 +159,10 @@ namespace v2rayN
JObject obj = JObject.Parse(strJson); JObject obj = JObject.Parse(strJson);
return obj; return obj;
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
return null; return null;
} }
} }
@@ -182,8 +188,9 @@ namespace v2rayN
return string.Join(",", lst.ToArray()); return string.Join(",", lst.ToArray());
} }
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
return string.Empty; return string.Empty;
} }
} }
@@ -199,8 +206,9 @@ namespace v2rayN
str = str.Replace(Environment.NewLine, ""); str = str.Replace(Environment.NewLine, "");
return new List<string>(str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)); return new List<string>(str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
return new List<string>(); return new List<string>();
} }
} }
@@ -265,8 +273,9 @@ namespace v2rayN
{ {
return Convert.ToInt32(obj); return Convert.ToInt32(obj);
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
return 0; return 0;
} }
} }
@@ -277,8 +286,9 @@ namespace v2rayN
{ {
return (obj == null ? string.Empty : obj.ToString()); return (obj == null ? string.Empty : obj.ToString());
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
return string.Empty; return string.Empty;
} }
} }
@@ -395,8 +405,9 @@ namespace v2rayN
int var1 = ToInt(oText); int var1 = ToInt(oText);
return true; return true;
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
return false; return false;
} }
} }
@@ -538,8 +549,9 @@ namespace v2rayN
string exePath = GetExePath(); string exePath = GetExePath();
RegWriteValue(autoRunRegPath, autoRunName, run ? $"\"{exePath}\"" : ""); RegWriteValue(autoRunRegPath, autoRunName, run ? $"\"{exePath}\"" : "");
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
} }
} }
@@ -558,8 +570,9 @@ namespace v2rayN
return true; return true;
} }
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
} }
return false; return false;
} }
@@ -608,8 +621,9 @@ namespace v2rayN
return value; return value;
} }
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
} }
finally finally
{ {
@@ -633,8 +647,9 @@ namespace v2rayN
regKey?.SetValue(name, value); regKey?.SetValue(name, value);
} }
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
} }
finally finally
{ {
@@ -674,8 +689,9 @@ namespace v2rayN
} }
} }
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
return -1; return -1;
} }
return roundtripTime; return roundtripTime;
@@ -697,8 +713,9 @@ namespace v2rayN
lstIPAddress.Add(ipa.ToString()); lstIPAddress.Add(ipa.ToString());
} }
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
} }
return lstIPAddress; return lstIPAddress;
} }
@@ -729,8 +746,9 @@ namespace v2rayN
FileVersionInfo.GetVersionInfo(location).FileVersion.ToString(), FileVersionInfo.GetVersionInfo(location).FileVersion.ToString(),
File.GetLastWriteTime(location).ToString("yyyy/MM/dd")); File.GetLastWriteTime(location).ToString("yyyy/MM/dd"));
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
return string.Empty; return string.Empty;
} }
} }
@@ -773,8 +791,9 @@ namespace v2rayN
} }
return strData; return strData;
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
} }
return strData; return strData;
} }
@@ -804,8 +823,9 @@ namespace v2rayN
{ {
return Guid.NewGuid().ToString("D"); return Guid.NewGuid().ToString("D");
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
} }
return string.Empty; return string.Empty;
} }
@@ -823,8 +843,9 @@ namespace v2rayN
//WindowsBuiltInRole可以枚举出很多权限例如系统用户、User、Guest等等 //WindowsBuiltInRole可以枚举出很多权限例如系统用户、User、Guest等等
return windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator); return windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator);
} }
catch catch (Exception ex)
{ {
SaveLog(ex.Message, ex);
return false; return false;
} }
} }
@@ -963,7 +984,10 @@ namespace v2rayN
} }
} }
} }
catch { } catch (Exception ex)
{
SaveLog(ex.Message, ex);
}
return string.Empty; return string.Empty;
} }