diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index 05a3f2fa..f275a8bd 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -51,6 +51,7 @@ namespace v2rayN.Forms { statistics = new StatisticsHandler(config, UpdateStatisticsHandler); } + MainFormHandler.Instance.UpdateTask(config, UpdateTaskHandler); } private void MainForm_VisibleChanged(object sender, EventArgs e) @@ -962,7 +963,10 @@ namespace v2rayN.Forms /// private void ClearMsg() { - this.txtMsgBox.Clear(); + txtMsgBox.Invoke((Action)delegate + { + txtMsgBox.Clear(); + }); } /// @@ -1085,6 +1089,15 @@ namespace v2rayN.Forms } } + private void UpdateTaskHandler(bool success, string msg) + { + AppendText(false, msg); + if (success) + { + Global.reloadV2ray = true; + LoadV2ray(); + } + } #endregion #region 移动服务器 @@ -1213,8 +1226,7 @@ namespace v2rayN.Forms { CloseV2ray(); - string fileName = Global.DownloadFileName; - fileName = Utils.GetPath(fileName); + string fileName = Utils.GetPath(Utils.GetDownloadFileName(msg)); FileManager.ZipExtractToFile(fileName, config.ignoreGeoUpdateCore ? "geo" : ""); AppendText(false, UIRes.I18N("MsgUpdateV2rayCoreSuccessfullyMore")); diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs b/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs index 2d895f88..65e88bcf 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs @@ -69,6 +69,8 @@ this.txtKcpmtu = new System.Windows.Forms.TextBox(); this.label6 = new System.Windows.Forms.Label(); this.tabPage7 = new System.Windows.Forms.TabPage(); + this.txtautoUpdateInterval = new System.Windows.Forms.TextBox(); + this.label15 = new System.Windows.Forms.Label(); this.chkIgnoreGeoUpdateCore = new System.Windows.Forms.CheckBox(); this.cmbCoreType = new System.Windows.Forms.ComboBox(); this.label4 = new System.Windows.Forms.Label(); @@ -372,6 +374,8 @@ // tabPage7 // resources.ApplyResources(this.tabPage7, "tabPage7"); + this.tabPage7.Controls.Add(this.txtautoUpdateInterval); + this.tabPage7.Controls.Add(this.label15); this.tabPage7.Controls.Add(this.chkIgnoreGeoUpdateCore); this.tabPage7.Controls.Add(this.cmbCoreType); this.tabPage7.Controls.Add(this.label4); @@ -384,6 +388,16 @@ this.tabPage7.Name = "tabPage7"; this.tabPage7.UseVisualStyleBackColor = true; // + // txtautoUpdateInterval + // + resources.ApplyResources(this.txtautoUpdateInterval, "txtautoUpdateInterval"); + this.txtautoUpdateInterval.Name = "txtautoUpdateInterval"; + // + // label15 + // + resources.ApplyResources(this.label15, "label15"); + this.label15.Name = "label15"; + // // chkIgnoreGeoUpdateCore // resources.ApplyResources(this.chkIgnoreGeoUpdateCore, "chkIgnoreGeoUpdateCore"); @@ -579,5 +593,7 @@ private System.Windows.Forms.Label label12; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.Label label13; + private System.Windows.Forms.TextBox txtautoUpdateInterval; + private System.Windows.Forms.Label label15; } } \ No newline at end of file diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.cs b/v2rayN/v2rayN/Forms/OptionSettingForm.cs index e6acb0d8..d104d927 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.cs +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.cs @@ -123,6 +123,7 @@ namespace v2rayN.Forms chkIgnoreGeoUpdateCore.Checked = config.ignoreGeoUpdateCore; cmbCoreType.SelectedIndex = (int)config.coreType; + txtautoUpdateInterval.Text = config.autoUpdateInterval.ToString(); } private void btnOK_Click(object sender, EventArgs e) { @@ -290,6 +291,7 @@ namespace v2rayN.Forms config.ignoreGeoUpdateCore = chkIgnoreGeoUpdateCore.Checked; config.coreType = (ECoreType)cmbCoreType.SelectedIndex; + config.autoUpdateInterval = Utils.ToInt(txtautoUpdateInterval.Text); return 0; } diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.resx b/v2rayN/v2rayN/Forms/OptionSettingForm.resx index 1cec3650..8015fffe 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.resx +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.resx @@ -127,16 +127,16 @@ 11 - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 107, 12 Keep older when deduplication - 2 + 4 - 6, 283 @@ -159,7 +159,7 @@ groupBox1 - 5 + 7 tti @@ -185,15 +185,18 @@ groupBox1 - - 662, 523 + + label15 + + + txtautoUpdateInterval + + + 2 35 - - 111, 24 - 468, 60 @@ -204,9 +207,6 @@ 102, 16 - - cmbprotocol - 6 @@ -216,6 +216,9 @@ tabPage3 + + 2 + 5 @@ -240,6 +243,9 @@ 40 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + True @@ -249,17 +255,14 @@ True - - tabPage6 - - - tabPage6 + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 36 - - 75, 23 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 7 @@ -291,18 +294,15 @@ tabPage6 + + tabPage6 + 317, 12 15, 63 - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 0 - 2 @@ -324,8 +324,14 @@ 654, 427 - - 654, 427 + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + NoControl System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -333,14 +339,14 @@ Settings - - True + + txtKcpreadBufferSize System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - label4 + + tabPage2 42 @@ -366,8 +372,8 @@ True - - Turn on Sniffing + + tabPage6 0, 10 @@ -390,20 +396,14 @@ 3 - - none - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 NoControl - - 6 - - - tabPage7 + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 0 @@ -414,9 +414,6 @@ Fill - - 576, 16 - 18 @@ -432,12 +429,12 @@ NoControl + + 15, 16 + System.Windows.Forms.Button, 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 - 89, 12 @@ -456,21 +453,18 @@ System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - groupBox1 - 12 - - NoControl - 10 32 + + label6 + 6, 12 @@ -501,11 +495,8 @@ txtKcptti - - Vertical - - - 15, 160 + + Turn on Sniffing 281, 12 @@ -513,12 +504,15 @@ Ignore Geo files when updating core - - 2 + + 355, 16 3, 3, 3, 3 + + 97, 20 + 3 @@ -534,23 +528,20 @@ 325, 130 - - 124, 60 - 78, 21 - - Log level - tabControl1 + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 59, 12 - - cmbCoreType + + 654, 427 v2rayN.Forms.BaseForm, v2rayN, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null @@ -564,24 +555,15 @@ 4 - - True - Statistics freshrate - - 107, 12 - 120, 16 89, 12 - - btnOK - 18, 66 @@ -606,20 +588,29 @@ Turn on Sniffing + + cmbloglevel + groupBox1 + + 345, 100 + 18, 28 System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + tabPage7 + 20 - - 29 + + 10 System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -658,7 +649,7 @@ groupBox1 - 0 + 2 18, 104 @@ -666,8 +657,8 @@ tabPage2 - - mtu + + 97, 20 socks @@ -675,27 +666,30 @@ tabPage1 - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 576, 16 System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - groupBox1 - True panel1 + + readBufferSize + 30 53, 12 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 13 @@ -717,17 +711,14 @@ 345, 62 - - 15, 16 - - - 3, 3, 3, 3 + + 11 chkudpEnabled - 1 + 3 True @@ -762,20 +753,26 @@ False - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + label7 + + + allowInsecure txtlocalPort - - 236, 28 + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tabPage7 - - 19 + + tabPage7 + + + True 4, 22 @@ -795,29 +792,41 @@ protocol - - 84, 16 + + Turn on Mux Multiplexing 23, 12 + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 638, 356 True + + 5 + 3, 3 System.Windows.Forms.Label, 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 + chkAllowLANConn - - True + + 84, 16 + + + tabControl1 True @@ -831,6 +840,9 @@ 1 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + tabPage6 @@ -846,17 +858,23 @@ NoControl + + 654, 427 + chkEnableStatistics - - socks + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 4 - - 355, 16 + + 7 + + + 1 53, 12 @@ -867,8 +885,8 @@ True - - 369, 27 + + 124, 60 System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -885,11 +903,14 @@ False + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 9 - - 8 + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 0 @@ -898,7 +919,7 @@ 101, 12 - 6 + 8 12 @@ -906,8 +927,8 @@ 20 - - allowInsecure + + cmbprotocol groupBox2 @@ -915,44 +936,38 @@ Enable Statistics (Realtime netspeed and traffic records. Require restart the v2rayN client) - - 107, 12 - - - 204, 16 + + cmbCoreType 662, 453 - - $this - 4 Listening port - - protocol - Fill 41 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 257, 60 - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + groupBox1 tabControl1 - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True 34 @@ -960,6 +975,9 @@ cmbprotocol2 + + NoControl + chkKeepOlderDedupl @@ -970,7 +988,7 @@ 16 - 7 + 9 True @@ -993,9 +1011,6 @@ tabPage2 - - tabControl1 - listening port 2 @@ -1005,12 +1020,15 @@ chkAllowIn2 - - System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - tabPage3 + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + panel2 @@ -1026,8 +1044,8 @@ 4, 22 - - 9 + + v2fly_core label1 @@ -1038,17 +1056,26 @@ 10 + + 29 + error + + 15, 160 + + + groupBox1 + 59, 12 NoControl - - txtKcpdownlinkCapacity + + 38 System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -1059,8 +1086,8 @@ downlinkCapacity - - tabControl1 + + 120, 16 662, 10 @@ -1071,9 +1098,6 @@ True - - 246, 16 - True @@ -1092,6 +1116,9 @@ False + + Custom DNS (multiple, separated by commas (,)) + 206, 29 @@ -1131,29 +1158,29 @@ 8 + + 35 + linkDnsObjectDoc System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Bottom + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - txtKcpreadBufferSize + + tabPage7 System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - groupBox1 + + Log level - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Fill + + tabControl1 638, 219 @@ -1164,11 +1191,14 @@ 2 - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 251, 12 + + + 15, 64 - 8 + 10 groupBox2 @@ -1191,15 +1221,15 @@ 8, 52 - - 9 - - - True - 78, 21 + + 9 + + + True + tabPage7 @@ -1209,23 +1239,23 @@ True - - v2fly_core + + System.Windows.Forms.TabControl, 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 + + 1 - - 6 + + 40 23, 12 - - 11 + + 8 8 @@ -1233,17 +1263,20 @@ Exception - - Use semicolon (;) + + NoControl - - 345, 100 + + 37 + + + groupBox1 94, 21 - - NoControl + + 0 654, 427 @@ -1257,15 +1290,9 @@ 17 - - 23 - 94, 21 - - debug - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -1275,32 +1302,35 @@ 0, 463 - - 0 - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tabPage1 - - 3 + + 6 - - http + + 125, 12 0 - - 97, 20 + + Use semicolon (;) - - label7 + + mtu - - 7 + + 32 + + + tabPage6 + + + 6 False @@ -1326,8 +1356,8 @@ txtKcpuplinkCapacity - - tabPage2 + + 23 chklogEnabled @@ -1344,23 +1374,32 @@ System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 325, 156 + groupBox2 4, 22 - - 40 + + True - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 5 + + + Automatic update interval of Geo(minutes) + + + groupBox1 4, 22 - - groupBox1 + + socks NoControl @@ -1368,8 +1407,8 @@ 6 - - Custom DNS (multiple, separated by commas (,)) + + protocol tabPage7 @@ -1380,11 +1419,11 @@ System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 15, 132 + + True - - 3 + + $this 8 @@ -1395,8 +1434,8 @@ 0, 0 - - True + + 19 True @@ -1404,14 +1443,14 @@ 3 - - 1 + + writeBufferSize 11 - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True 89, 12 @@ -1425,11 +1464,14 @@ 31 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 369, 27 - - groupBox1 + + http + + + Fill groupBox1 @@ -1437,11 +1479,11 @@ groupBox1 - - 32 + + groupBox1 - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 15, 132 True @@ -1449,9 +1491,6 @@ 345, 24 - - tabPage7 - Core: DNS settings @@ -1461,11 +1500,11 @@ label3 - - 125, 12 + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - NoControl + + 204, 16 System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -1473,11 +1512,8 @@ 94, 21 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - writeBufferSize + + 75, 23 System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -1485,32 +1521,35 @@ 8, 41 - - 0, 0, 0, 0 - uplinkCapacity - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 0, 0, 0, 0 - - 35 + + 662, 523 - - 5 + + label4 - - 4 + + Vertical + + + 6 + + + 236, 66 3, 3, 3, 3 - - 10 + + 97, 21 - - cmbloglevel + + 107, 12 label5 @@ -1518,26 +1557,29 @@ 15, 192 - - tabPage6 + + btnOK False - - tabPage6 + + debug System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + chkmuxEnabled - - True + + none - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + tabPage6 False @@ -1545,17 +1587,20 @@ 253, 134 + + 342, 17 + 0, 0 Enable UDP - - 15, 64 + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - True + + 3, 3, 3, 3 groupBox1 @@ -1578,38 +1623,44 @@ groupBox1 - - 120, 16 + + NoControl - - readBufferSize + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 2 + + 9 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 0 + + + txtKcpdownlinkCapacity groupBox1 - - 342, 17 + + 0 94, 21 - - 97, 20 + + 3 3 - - groupBox1 + + 30, 162 - - 654, 427 + + 236, 28 + + + Bottom 11 @@ -1638,17 +1689,17 @@ cbFreshrate - - Turn on Mux Multiplexing + + 246, 16 tabPage6 - - label6 + + tabPage7 - - 236, 66 + + 111, 24 NoControl diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx b/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx index 1740c11e..673c26af 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx @@ -139,30 +139,63 @@ Core:KCP设置 + + 255, 156 + + + 191, 12 + + + 自动更新Geo文件的间隔(单位分钟) + + + 150, 16 + + + 更新Core时忽略Geo文件 + + + 53, 12 + + + Core类型 + + + 156, 16 + + + 去重时保留序号较小的项 + + + 77, 12 + + + 统计刷新频率 + + + 372, 16 + + + 启用统计(实时网速显示和使用流量显示,需要重启v2rayN客户端) + + + 144, 16 + + + 允许来自局域网的连接 + + + 180, 16 + + + 开机自动启动(可能会不成功) + 654, 443 v2rayN设置 - - 95, 12 - - - 使用分号(;)分隔 - - - 239, 12 - - - 对于下列字符开头的地址不使用代理服务器: - - - 654, 443 - - - 例外 - 654, 443 @@ -259,47 +292,23 @@ 自定义DNS(可多个,用逗号(,)隔开) - - 150, 16 + + 654, 443 - - 更新Core时忽略Geo文件 + + 例外 - - 53, 12 + + 95, 12 - - Core类型 + + 使用分号(;)分隔 - - 156, 16 + + 239, 12 - - 去重时保留序号较小的项 - - - 77, 12 - - - 统计刷新频率 - - - 372, 16 - - - 启用统计(实时网速显示和使用流量显示,需要重启v2rayN客户端) - - - 144, 16 - - - 允许来自局域网的连接 - - - 180, 16 - - - 开机自动启动(可能会不成功) + + 对于下列字符开头的地址不使用代理服务器: 0, 479 diff --git a/v2rayN/v2rayN/Global.cs b/v2rayN/v2rayN/Global.cs index a44cc1ee..0a37c2c6 100644 --- a/v2rayN/v2rayN/Global.cs +++ b/v2rayN/v2rayN/Global.cs @@ -7,7 +7,7 @@ namespace v2rayN { #region 常量 - public const string DownloadFileName = "v2ray-windows.zip"; + //public const string DownloadFileName = "v2ray-windows.zip"; public const string v2rayWebsiteUrl = @"https://www.v2fly.org/"; public const string AboutUrl = @"https://github.com/2dust/v2rayN"; public const string UpdateUrl = AboutUrl + @"/releases"; diff --git a/v2rayN/v2rayN/Handler/DownloadHandle.cs b/v2rayN/v2rayN/Handler/DownloadHandle.cs index 0bdde6c2..e2970659 100644 --- a/v2rayN/v2rayN/Handler/DownloadHandle.cs +++ b/v2rayN/v2rayN/Handler/DownloadHandle.cs @@ -52,7 +52,7 @@ namespace v2rayN.Handler ws.DownloadFileCompleted += ws_DownloadFileCompleted; ws.DownloadProgressChanged += ws_DownloadProgressChanged; - ws.DownloadFileAsync(new Uri(url), Utils.GetPath(Global.DownloadFileName)); + ws.DownloadFileAsync(new Uri(url), Utils.GetPath(Utils.GetDownloadFileName(url))); } catch (Exception ex) { diff --git a/v2rayN/v2rayN/Handler/MainFormHandler.cs b/v2rayN/v2rayN/Handler/MainFormHandler.cs index 054cf476..6052e79d 100644 --- a/v2rayN/v2rayN/Handler/MainFormHandler.cs +++ b/v2rayN/v2rayN/Handler/MainFormHandler.cs @@ -1,5 +1,7 @@ using System; using System.Drawing; +using System.Threading; +using System.Threading.Tasks; using System.Windows.Forms; using v2rayN.Base; using v2rayN.Mode; @@ -9,7 +11,7 @@ namespace v2rayN.Handler class MainFormHandler { private static MainFormHandler instance; - Action updateUI; + Action _updateUI; //private DownloadHandle downloadHandle2; //private Config _config; @@ -166,77 +168,6 @@ namespace v2rayN.Handler return counter; } - - public void UpdateSubscriptionProcess(Config config, Action update) - { - updateUI = update; - - updateUI(false, UIRes.I18N("MsgUpdateSubscriptionStart")); - - if (config.subItem == null || config.subItem.Count <= 0) - { - updateUI(false, UIRes.I18N("MsgNoValidSubscription")); - return; - } - - for (int k = 1; k <= config.subItem.Count; k++) - { - string id = config.subItem[k - 1].id.TrimEx(); - string url = config.subItem[k - 1].url.TrimEx(); - string hashCode = $"{k}->"; - if (config.subItem[k - 1].enabled == false) - { - continue; - } - if (Utils.IsNullOrEmpty(id) || Utils.IsNullOrEmpty(url)) - { - updateUI(false, $"{hashCode}{UIRes.I18N("MsgNoValidSubscription")}"); - continue; - } - - DownloadHandle downloadHandle3 = new DownloadHandle(); - downloadHandle3.UpdateCompleted += (sender2, args) => - { - if (args.Success) - { - updateUI(false, $"{hashCode}{UIRes.I18N("MsgGetSubscriptionSuccessfully")}"); - string result = Utils.Base64Decode(args.Msg); - if (Utils.IsNullOrEmpty(result)) - { - updateUI(false, $"{hashCode}{UIRes.I18N("MsgSubscriptionDecodingFailed")}"); - return; - } - - ConfigHandler.RemoveServerViaSubid(ref config, id); - updateUI(false, $"{hashCode}{UIRes.I18N("MsgClearSubscription")}"); - // RefreshServers(); - int ret = MainFormHandler.Instance.AddBatchServers(config, result, id); - if (ret > 0) - { - // RefreshServers(); - } - else - { - updateUI(false, $"{hashCode}{UIRes.I18N("MsgFailedImportSubscription")}"); - } - updateUI(true, $"{hashCode}{UIRes.I18N("MsgUpdateSubscriptionEnd")}"); - } - else - { - updateUI(false, args.Msg); - } - }; - downloadHandle3.Error += (sender2, args) => - { - updateUI(false, args.GetException().Message); - }; - - downloadHandle3.WebDownloadString(url); - updateUI(false, $"{hashCode}{UIRes.I18N("MsgStartGettingSubscriptions")}"); - } - - } - public void BackupGuiNConfig(Config config, bool auto = false) { string fileName = string.Empty; @@ -277,5 +208,42 @@ namespace v2rayN.Handler } } + public void UpdateTask(Config config, Action update) + { + _updateUI = update; + Task.Run(() => UpdateTaskRun(config)); + } + + private void UpdateTaskRun(Config config) + { + var updateHandle = new UpdateHandle(); + while (true) + { + Utils.SaveLog("UpdateTaskRun"); + Thread.Sleep(60000); + if (config.autoUpdateInterval <= 0) + { + continue; + } + + updateHandle.UpdateGeoFile("geosite", config, (bool success, string msg) => + { + _updateUI(false, msg); + if (success) + Utils.SaveLog("geosite" + msg); + }); + + Thread.Sleep(60000); + + updateHandle.UpdateGeoFile("geoip", config, (bool success, string msg) => + { + _updateUI(false, msg); + if (success) + Utils.SaveLog("geoip" + msg); + }); + + Thread.Sleep(60000 * config.autoUpdateInterval); + } + } } -} +} \ No newline at end of file diff --git a/v2rayN/v2rayN/Handler/UpdateHandle.cs b/v2rayN/v2rayN/Handler/UpdateHandle.cs index e0e54269..ee7e09a0 100644 --- a/v2rayN/v2rayN/Handler/UpdateHandle.cs +++ b/v2rayN/v2rayN/Handler/UpdateHandle.cs @@ -41,8 +41,9 @@ namespace v2rayN.Handler { _config = config; _updateFunc = update; + var url = string.Empty; - DownloadHandle downloadHandle = null; + DownloadHandle downloadHandle = null; if (downloadHandle == null) { downloadHandle = new DownloadHandle(); @@ -55,7 +56,7 @@ namespace v2rayN.Handler try { - string fileName = Utils.GetPath(Global.DownloadFileName); + string fileName = Utils.GetPath(Utils.GetDownloadFileName(url)); fileName = Utils.UrlEncode(fileName); Process process = new Process { @@ -93,8 +94,8 @@ namespace v2rayN.Handler { _updateFunc(false, string.Format(UIRes.I18N("MsgParsingSuccessfully"), "v2rayN")); - string url = args.Msg; - askToDownload(downloadHandle, url); + url = args.Msg; + askToDownload(downloadHandle, url, true); } else { @@ -110,6 +111,7 @@ namespace v2rayN.Handler { _config = config; _updateFunc = update; + var url = string.Empty; DownloadHandle downloadHandle = null; if (downloadHandle == null) @@ -124,7 +126,7 @@ namespace v2rayN.Handler try { - _updateFunc(true, ""); + _updateFunc(true, url); } catch (Exception ex) { @@ -147,8 +149,8 @@ namespace v2rayN.Handler if (args.Success) { _updateFunc(false, string.Format(UIRes.I18N("MsgParsingSuccessfully"), "Core")); - string url = args.Msg; - askToDownload(downloadHandle, url); + url = args.Msg; + askToDownload(downloadHandle, url, true); } else { @@ -236,6 +238,7 @@ namespace v2rayN.Handler { _config = config; _updateFunc = update; + var url = string.Format(geoUrl, geoName); DownloadHandle downloadHandle = null; if (downloadHandle == null) @@ -250,7 +253,7 @@ namespace v2rayN.Handler try { - string fileName = Utils.GetPath(Global.DownloadFileName); + string fileName = Utils.GetPath(Utils.GetDownloadFileName(url)); if (File.Exists(fileName)) { string targetPath = Utils.GetPath($"{geoName}.dat"); @@ -278,8 +281,7 @@ namespace v2rayN.Handler }; } - var url = string.Format(geoUrl, geoName); - askToDownload(downloadHandle, url); + askToDownload(downloadHandle, url, false); } #region private @@ -433,9 +435,21 @@ namespace v2rayN.Handler } } - private void askToDownload(DownloadHandle downloadHandle, string url) + private void askToDownload(DownloadHandle downloadHandle, string url, bool blAsk) { - if (UI.ShowYesNo(string.Format(UIRes.I18N("DownloadYesNo"), url)) == DialogResult.Yes) + bool blDownload = false; + if (blAsk) + { + if (UI.ShowYesNo(string.Format(UIRes.I18N("DownloadYesNo"), url)) == DialogResult.Yes) + { + blDownload = true; + } + } + else + { + blDownload = true; + } + if (blDownload) { if (httpProxyTest() > 0) { diff --git a/v2rayN/v2rayN/Mode/Config.cs b/v2rayN/v2rayN/Mode/Config.cs index 67bafaea..a8a54cb2 100644 --- a/v2rayN/v2rayN/Mode/Config.cs +++ b/v2rayN/v2rayN/Mode/Config.cs @@ -195,6 +195,11 @@ namespace v2rayN.Mode get; set; } + public int autoUpdateInterval + { + get; set; + } = 0; + #region 函数 public string address() diff --git a/v2rayN/v2rayN/Properties/AssemblyInfo.cs b/v2rayN/v2rayN/Properties/AssemblyInfo.cs index b270cd10..4a4693f9 100644 --- a/v2rayN/v2rayN/Properties/AssemblyInfo.cs +++ b/v2rayN/v2rayN/Properties/AssemblyInfo.cs @@ -32,4 +32,4 @@ using System.Runtime.InteropServices; // 方法是按如下所示使用“*”: //[assembly: AssemblyVersion("1.0.*")] //[assembly: AssemblyVersion("1.0.0")] -[assembly: AssemblyFileVersion("4.21")] +[assembly: AssemblyFileVersion("4.22")] diff --git a/v2rayN/v2rayN/Tool/Utils.cs b/v2rayN/v2rayN/Tool/Utils.cs index 928ebd87..5eed9f09 100644 --- a/v2rayN/v2rayN/Tool/Utils.cs +++ b/v2rayN/v2rayN/Tool/Utils.cs @@ -833,6 +833,14 @@ namespace v2rayN { i.SubItems.Add(new ListViewItem.ListViewSubItem() { Name = name, Text = text }); } + + public static string GetDownloadFileName(string url) + { + var fileName = System.IO.Path.GetFileName(url); + fileName += "_temp"; + + return fileName; + } #endregion #region TempPath