diff --git a/v2rayN/v2rayN/Forms/MainForm.Designer.cs b/v2rayN/v2rayN/Forms/MainForm.Designer.cs index dd2ce2b2..0e3b713d 100644 --- a/v2rayN/v2rayN/Forms/MainForm.Designer.cs +++ b/v2rayN/v2rayN/Forms/MainForm.Designer.cs @@ -107,6 +107,7 @@ this.tsbCheckUpdateN = new System.Windows.Forms.ToolStripMenuItem(); this.tsbCheckUpdateCore = new System.Windows.Forms.ToolStripMenuItem(); this.tsbCheckUpdatePACList = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator13 = new System.Windows.Forms.ToolStripSeparator(); this.tsbCheckClearPACList = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator(); this.tsbHelp = new System.Windows.Forms.ToolStripDropDownButton(); @@ -117,7 +118,7 @@ this.tsbPromotion = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator(); this.tsbClose = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator13 = new System.Windows.Forms.ToolStripSeparator(); + this.tsbV2rayWebsite = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -162,7 +163,7 @@ this.lvServers.SelectedIndexChanged += new System.EventHandler(this.lvServers_SelectedIndexChanged); this.lvServers.Click += new System.EventHandler(this.lvServers_Click); this.lvServers.DoubleClick += new System.EventHandler(this.lvServers_DoubleClick); - this.lvServers.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lvServers_KeyDown); + this.lvServers.KeyUp += new System.Windows.Forms.KeyEventHandler(this.lvServers_KeyUp); // // cmsLv // @@ -196,7 +197,6 @@ this.menuExport2ShareUrl, this.menuExport2SubContent}); this.cmsLv.Name = "cmsLv"; - this.cmsLv.OwnerItem = this.tsbServer; resources.ApplyResources(this.cmsLv, "cmsLv"); // // menuAddVmessServer @@ -684,6 +684,11 @@ resources.ApplyResources(this.tsbCheckUpdatePACList, "tsbCheckUpdatePACList"); this.tsbCheckUpdatePACList.Click += new System.EventHandler(this.tsbCheckUpdatePACList_Click); // + // toolStripSeparator13 + // + this.toolStripSeparator13.Name = "toolStripSeparator13"; + resources.ApplyResources(this.toolStripSeparator13, "toolStripSeparator13"); + // // tsbCheckClearPACList // this.tsbCheckClearPACList.Name = "tsbCheckClearPACList"; @@ -698,6 +703,7 @@ // tsbHelp // this.tsbHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.tsbV2rayWebsite, this.tsbAbout, this.toolStripSeparator12, this.tsbLanguageDef, @@ -748,10 +754,11 @@ this.tsbClose.Name = "tsbClose"; this.tsbClose.Click += new System.EventHandler(this.tsbClose_Click); // - // toolStripSeparator13 + // tsbV2rayWebsite // - this.toolStripSeparator13.Name = "toolStripSeparator13"; - resources.ApplyResources(this.toolStripSeparator13, "toolStripSeparator13"); + this.tsbV2rayWebsite.Name = "tsbV2rayWebsite"; + resources.ApplyResources(this.tsbV2rayWebsite, "tsbV2rayWebsite"); + this.tsbV2rayWebsite.Click += new System.EventHandler(this.tsbV2rayWebsite_Click); // // MainForm // @@ -877,6 +884,7 @@ private System.Windows.Forms.ToolStripMenuItem menuRealPingServer; private System.Windows.Forms.ToolStripMenuItem menuNotEnabledHttp; private System.Windows.Forms.ToolStripSeparator toolStripSeparator13; + private System.Windows.Forms.ToolStripMenuItem tsbV2rayWebsite; } } diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index 8ab48a1d..2a2f214a 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -167,10 +167,10 @@ namespace v2rayN.Forms if (statistics != null && statistics.Enable) { - lvServers.Columns.Add(UIRes.I18N("LvTotalUploadDataAmount"), 70, HorizontalAlignment.Left); - lvServers.Columns.Add(UIRes.I18N("LvTotalDownloadDataAmount"), 70, HorizontalAlignment.Left); - lvServers.Columns.Add(UIRes.I18N("LvTodayUploadDataAmount"), 70, HorizontalAlignment.Left); lvServers.Columns.Add(UIRes.I18N("LvTodayDownloadDataAmount"), 70, HorizontalAlignment.Left); + lvServers.Columns.Add(UIRes.I18N("LvTodayUploadDataAmount"), 70, HorizontalAlignment.Left); + lvServers.Columns.Add(UIRes.I18N("LvTotalDownloadDataAmount"), 70, HorizontalAlignment.Left); + lvServers.Columns.Add(UIRes.I18N("LvTotalUploadDataAmount"), 70, HorizontalAlignment.Left); } } @@ -198,13 +198,13 @@ namespace v2rayN.Forms ListViewItem lvItem = null; if (statistics != null && statistics.Enable) { - var index = statistics.Statistic.FindIndex(item_ => item_.itemId == item.getItemId()); - if (index != -1) + var sItem = statistics.Statistic.Find(item_ => item_.itemId == item.getItemId()); + if (sItem != null) { - totalUp = Utils.HumanFy(statistics.Statistic[index].totalUp); - totalDown = Utils.HumanFy(statistics.Statistic[index].totalDown); - todayUp = Utils.HumanFy(statistics.Statistic[index].todayUp); - todayDown = Utils.HumanFy(statistics.Statistic[index].todayDown); + totalUp = Utils.HumanFy(sItem.totalUp); + totalDown = Utils.HumanFy(sItem.totalDown); + todayUp = Utils.HumanFy(sItem.todayUp); + todayDown = Utils.HumanFy(sItem.todayDown); } lvItem = new ListViewItem(new string[] @@ -220,10 +220,10 @@ namespace v2rayN.Forms item.network, item.getSubRemarks(config), item.testResult, - totalUp, - totalDown, + todayDown, todayUp, - todayDown + totalDown, + totalUp }); } else @@ -241,10 +241,6 @@ namespace v2rayN.Forms item.network, item.getSubRemarks(config), item.testResult - //totalUp, - //totalDown, - //todayUp, - //todayDown, }); } @@ -324,7 +320,7 @@ namespace v2rayN.Forms { toolSslSocksPort.Text = toolSslHttpPort.Text = - toolSslPacPort.Text = "NONE"; + toolSslPacPort.Text = "OFF"; toolSslSocksPort.Text = $"{Global.Loopback}:{config.inbound[0].localPort}"; @@ -468,7 +464,7 @@ namespace v2rayN.Forms } } - private void lvServers_KeyDown(object sender, KeyEventArgs e) + private void lvServers_KeyUp(object sender, KeyEventArgs e) { if (e.Control) { @@ -477,6 +473,18 @@ namespace v2rayN.Forms case Keys.A: menuSelectAll_Click(null, null); break; + case Keys.C: + menuExport2ShareUrl_Click(null, null); + break; + case Keys.V: + menuAddServers_Click(null, null); + break; + case Keys.U: + menuMoveTop_Click(null, null); + break; + case Keys.D: + menuMoveBottom_Click(null, null); + break; case Keys.P: menuPingServer_Click(null, null); break; @@ -491,20 +499,23 @@ namespace v2rayN.Forms break; } } - switch (e.KeyCode) + else { - case Keys.Enter: - menuSetDefaultServer_Click(null, null); - break; - case Keys.Delete: - menuRemoveServer_Click(null, null); - break; - case Keys.U: - menuMoveUp_Click(null, null); - break; - case Keys.D: - menuMoveDown_Click(null, null); - break; + switch (e.KeyCode) + { + case Keys.Enter: + menuSetDefaultServer_Click(null, null); + break; + case Keys.Delete: + menuRemoveServer_Click(null, null); + break; + case Keys.U: + menuMoveUp_Click(null, null); + break; + case Keys.D: + menuMoveDown_Click(null, null); + break; + } } } @@ -546,6 +557,8 @@ namespace v2rayN.Forms { List servers = null; Utils.DedupServerList(config.vmess, out servers); + int oldCount = config.vmess.Count; + int newCount = servers.Count; if (servers != null) { config.vmess = servers; @@ -553,6 +566,7 @@ namespace v2rayN.Forms //刷新 RefreshServers(); LoadV2ray(); + UI.Show(string.Format(UIRes.I18N("RemoveDuplicateServerResult"), oldCount, newCount)); } private void menuCopyServer_Click(object sender, EventArgs e) @@ -638,9 +652,9 @@ namespace v2rayN.Forms GetLvSelectedIndex(); StringBuilder sb = new StringBuilder(); - for (int k = 0; k < lvSelecteds.Count; k++) + foreach (int v in lvSelecteds) { - string url = ConfigHandler.GetVmessQRCode(config, lvSelecteds[k]); + string url = ConfigHandler.GetVmessQRCode(config, v); if (Utils.IsNullOrEmpty(url)) { continue; @@ -660,9 +674,9 @@ namespace v2rayN.Forms GetLvSelectedIndex(); StringBuilder sb = new StringBuilder(); - for (int k = 0; k < lvSelecteds.Count; k++) + foreach (int v in lvSelecteds) { - string url = ConfigHandler.GetVmessQRCode(config, lvSelecteds[k]); + string url = ConfigHandler.GetVmessQRCode(config, v); if (Utils.IsNullOrEmpty(url)) { continue; @@ -809,9 +823,10 @@ namespace v2rayN.Forms private void menuAddServers_Click(object sender, EventArgs e) { string clipboardData = Utils.GetClipboardData(); - if (AddBatchServers(clipboardData) == 0) + int result = AddBatchServers(clipboardData); + if (result > 0) { - UI.Show(UIRes.I18N("SuccessfullyImportedServerViaClipboard")); + UI.Show(string.Format(UIRes.I18N("SuccessfullyImportedServerViaClipboard"), result)); } } @@ -823,16 +838,19 @@ namespace v2rayN.Forms private int AddBatchServers(string clipboardData, string subid = "") { - if (ConfigHandler.AddBatchServers(ref config, clipboardData, subid) != 0) + int counter; + int _Add() + { + return ConfigHandler.AddBatchServers(ref config, clipboardData, subid); + } + counter = _Add(); + if (counter < 1) { clipboardData = Utils.Base64Decode(clipboardData); - if (ConfigHandler.AddBatchServers(ref config, clipboardData, subid) != 0) - { - return -1; - } + counter = _Add(); } RefreshServers(); - return 0; + return counter; } #endregion @@ -970,9 +988,9 @@ namespace v2rayN.Forms } private void ClearTestResult() { - for (int k = 0; k < lvSelecteds.Count; k++) + foreach (int s in lvSelecteds) { - SetTestResult(lvSelecteds[k], ""); + SetTestResult(s, ""); } } private void UpdateSpeedtestHandler(int index, string msg) @@ -1006,10 +1024,10 @@ namespace v2rayN.Forms lvServers.SuspendLayout(); var indexStart = 9; - lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].totalUp); - lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].totalDown); - lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].todayUp); lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].todayDown); + lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].todayUp); + lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].totalDown); + lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].totalUp); lvServers.ResumeLayout(); }); @@ -1056,7 +1074,7 @@ namespace v2rayN.Forms } if (ConfigHandler.MoveServer(ref config, index, eMove) == 0) { - //刷新 + //TODO: reload is not good. RefreshServers(); LoadV2ray(); } @@ -1199,7 +1217,7 @@ namespace v2rayN.Forms } AppendText(false, UIRes.I18N("MsgStartUpdatingV2rayCore")); - downloadHandle.AbsoluteV2rayN(config); + downloadHandle.CheckUpdateAsync("v2rayN"); } private void tsbCheckUpdateCore_Click(object sender, EventArgs e) @@ -1272,7 +1290,7 @@ namespace v2rayN.Forms } AppendText(false, UIRes.I18N("MsgStartUpdatingV2rayCore")); - downloadHandle.AbsoluteV2rayCore(config); + downloadHandle.CheckUpdateAsync("Core"); } private void tsbCheckUpdatePACList_Click(object sender, EventArgs e) @@ -1356,7 +1374,7 @@ namespace v2rayN.Forms } else { - if (AddBatchServers(result) == 0) + if (AddBatchServers(result) > 0) { UI.Show(UIRes.I18N("SuccessfullyImportedServerViaScan")); } @@ -1416,7 +1434,7 @@ namespace v2rayN.Forms ConfigHandler.RemoveServerViaSubid(ref config, id); AppendText(false, $"{hashCode}{UIRes.I18N("MsgClearSubscription")}"); RefreshServers(); - if (AddBatchServers(result, id) == 0) + if (AddBatchServers(result, id) > 0) { } else @@ -1456,10 +1474,15 @@ namespace v2rayN.Forms private void SetCurrentLanguage(string value) { Utils.RegWriteValue(Global.MyRegPath, Global.MyRegKeyLanguage, value); + Application.Restart(); } + #endregion - + private void tsbV2rayWebsite_Click(object sender, EventArgs e) + { + System.Diagnostics.Process.Start(Global.v2rayWebsiteUrl); + } } } diff --git a/v2rayN/v2rayN/Forms/MainForm.resx b/v2rayN/v2rayN/Forms/MainForm.resx index cde6dfff..18ad432d 100644 --- a/v2rayN/v2rayN/Forms/MainForm.resx +++ b/v2rayN/v2rayN/Forms/MainForm.resx @@ -156,7 +156,7 @@ 447, 22 - Import bulk URL from clipboard + Import bulk URL from clipboard (Ctrl+V) 447, 22 @@ -171,19 +171,19 @@ 447, 22 - Remove selected server (multiple choice) (Delete) + Remove selected servers (Delete) 447, 22 - Remove duplicate server + Remove duplicate servers 447, 22 - Copy selected server + Clone selected server 447, 22 @@ -198,7 +198,7 @@ 447, 22 - Up to top + Move to top (Ctrl+U) 447, 22 @@ -216,7 +216,7 @@ 447, 22 - Moves down to the bottom + Move to bottom (Ctrl+D) 447, 22 @@ -231,25 +231,25 @@ 447, 22 - Test server ping (multiple choice)(Ctrl+P) + Test servers ping (Ctrl+P) 447, 22 - Test server tcping (multiple choice)(Ctrl+O) + Test servers with tcping (Ctrl+O) 447, 22 - Test server real ping (multiple choice)(Ctrl+R) + Test servers real delay (Ctrl+R) 447, 22 - Test server speed (multiple choice)(Ctrl+T) + Test servers download speed (Ctrl+T) 444, 6 @@ -270,13 +270,13 @@ 447, 22 - Batch export share URL to clipboard (multiple choice) + Export share URLs to clipboard (Ctrl+C) 447, 22 - Batch export subscription content to clipboard (multiple choice) + Export subscription (base64) share to clipboard Magenta @@ -291,7 +291,7 @@ ImageAboveText - 448, 534 + 448, 556 cmsLv @@ -422,27 +422,6 @@ NoControl - - 265, 142 - - - cmsMain - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - v2rayN - - - True - - - 264, 22 - - - Http proxy - 547, 22 @@ -473,6 +452,12 @@ Only open PAC, do not automatically configure PAC + + 264, 22 + + + Http proxy + 264, 22 @@ -506,6 +491,21 @@ Exit + + 265, 142 + + + cmsMain + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + v2rayN + + + True + 498, 17 @@ -522,7 +522,7 @@ 2 - Server list + Servers list groupBox1 @@ -536,60 +536,6 @@ 2 - - 228, 18 - - - txtMsgBox - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox2 - - - 0 - - - ssMain - - - System.Windows.Forms.StatusStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox2 - - - 1 - - - Bottom - - - 0, 417 - - - 952, 176 - - - 4 - - - Information - - - groupBox2 - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 - Fill @@ -626,6 +572,81 @@ 228, 18 + + 微软雅黑, 8pt + + + 52, 17 + + + SOCKS5: + + + 0, 17 + + + 微软雅黑, 8pt + + + 195, 17 + + + 微软雅黑, 8pt + + + 39, 17 + + + HTTP: + + + 0, 17 + + + 微软雅黑, 8pt + + + 195, 17 + + + 微软雅黑, 8pt + + + 33, 17 + + + PAC: + + + 0, 17 + + + 微软雅黑, 8pt + + + 195, 17 + + + False + + + 微软雅黑, 8pt + + + No + + + 220, 17 + + + SPEED Disabled + + + MiddleRight + + + 0, 17 + 3, 151 @@ -650,80 +671,32 @@ 1 - - 微软雅黑, 8pt + + Bottom - - 49, 17 + + 0, 417 - - SOCKS5 + + 952, 176 - - 0, 17 + + 4 - - 微软雅黑, 8pt + + Informations - - 198, 17 + + groupBox2 - - 微软雅黑, 8pt + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 36, 17 + + $this - - HTTP - - - 0, 17 - - - 微软雅黑, 8pt - - - 198, 17 - - - 微软雅黑, 8pt - - - 30, 17 - - - PAC - - - 0, 17 - - - 微软雅黑, 8pt - - - 198, 17 - - - False - - - 微软雅黑, 8pt - - - No - - - 220, 17 - - - SPEED Disabled - - - MiddleRight - - - 0, 17 + + 3 Top @@ -755,14 +728,26 @@ 6, 56 + + 125, 22 + + + Settings + + + 125, 22 + + + Updates + Magenta - 93, 53 + 99, 53 - Subscription + Subscriptions ImageAboveText @@ -774,10 +759,10 @@ Magenta - 52, 53 + 58, 53 - Setting + Settings ImageAboveText @@ -803,10 +788,10 @@ Magenta - 97, 53 + 98, 53 - Restart service + Restart Service ImageAboveText @@ -815,31 +800,31 @@ 6, 56 - 338, 22 + 393, 22 - Check for updates to v2rayN + v2rayN (this software) - 338, 22 + 393, 22 - Check for updates to v2rayCore + Update v2rayCore - 338, 22 + 393, 22 - Check for updated PAC (requires Http proxy) + Check for updated PAC (need the HTTP proxy are ON) - 335, 6 + 390, 6 - 338, 22 + 393, 22 - Simplify PAC (please set Core route) + Simplify PAC (need to set Core route) Magenta @@ -856,6 +841,33 @@ 6, 56 + + 187, 22 + + + V2Ray Website + + + 187, 22 + + + v2rayN Project + + + 184, 6 + + + 187, 22 + + + Language-[English] + + + 187, 22 + + + 语言-[中文简体] + Magenta @@ -923,39 +935,6 @@ 5 - - 197, 22 - - - Subscription settings - - - 197, 22 - - - Update subscription - - - 187, 22 - - - About - - - 184, 6 - - - 187, 22 - - - Language-[English] - - - 187, 22 - - - 语言-[中文简体] - True @@ -1370,6 +1349,12 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + toolStripSeparator13 + + + System.Windows.Forms.ToolStripSeparator, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + tsbCheckClearPACList @@ -1430,11 +1415,11 @@ System.Windows.Forms.ToolStripButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - toolStripSeparator13 + + tsbV2rayWebsite - - System.Windows.Forms.ToolStripSeparator, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 MainForm diff --git a/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx b/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx index 1659d54e..3ff52395 100644 --- a/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx +++ b/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx @@ -146,7 +146,7 @@ 278, 22 - 从剪贴板导入批量URL + 从剪贴板导入批量URL (Ctrl+V) 278, 22 @@ -161,7 +161,7 @@ 278, 22 - 移除所选服务器(多选) (Delete) + 移除所选服务器(多选) (Delete) 278, 22 @@ -173,13 +173,13 @@ 278, 22 - 复制所选服务器 + 克隆所选服务器 278, 22 - 设为活动服务器 (Enter) + 设为活动服务器 (Enter) 275, 6 @@ -188,31 +188,31 @@ 278, 22 - 上移至顶 + 上移至顶 (Ctrl+U) 278, 22 - 上移 (U) + 上移 (U) 278, 22 - 下移 (D) + 下移 (D) 278, 22 - 下移至底 + 下移至底 (Ctrl+D) 278, 22 - 全选 (Ctrl+A) + 全选 (Ctrl+A) 275, 6 @@ -221,25 +221,25 @@ 278, 22 - 测试服务器延迟Ping(多选)(Ctrl+P) + 测试服务器延迟Ping(多选) (Ctrl+P) 278, 22 - 测试服务器延迟Tcping(多选)(Ctrl+O) + 测试服务器延迟Tcping(多选) (Ctrl+O) 278, 22 - 测试服务器真连接延迟(多选)(Ctrl+R) + 测试服务器真连接延迟(多选) (Ctrl+R) 278, 22 - 测试服务器速度(多选)(Ctrl+T) + 测试服务器速度(多选) (Ctrl+T) 275, 6 @@ -260,7 +260,7 @@ 278, 22 - 批量导出分享URL至剪贴板(多选) + 批量导出分享URL至剪贴板(多选) (Ctrl+C) 278, 22 @@ -420,19 +420,19 @@ 232, 22 - 检查更新v2rayN + v2rayN 232, 22 - 检查更新v2rayCore + v2rayCore 232, 22 - 检查更新PAC + PAC 232, 22 @@ -446,8 +446,11 @@ 检查更新 + + V2Ray 官网 + - 关于 + v2rayN 项目 69, 53 @@ -469,6 +472,6 @@ - 关闭 + 关闭窗口 \ No newline at end of file diff --git a/v2rayN/v2rayN/Forms/QRCodeControl.resx b/v2rayN/v2rayN/Forms/QRCodeControl.resx index ef0c4f04..29882d55 100644 --- a/v2rayN/v2rayN/Forms/QRCodeControl.resx +++ b/v2rayN/v2rayN/Forms/QRCodeControl.resx @@ -132,7 +132,7 @@ 0 - Show shared content + Sharing panel System.Windows.Forms.UserControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 diff --git a/v2rayN/v2rayN/Forms/SubSettingControl.cs b/v2rayN/v2rayN/Forms/SubSettingControl.cs index a3f09593..9836be5d 100644 --- a/v2rayN/v2rayN/Forms/SubSettingControl.cs +++ b/v2rayN/v2rayN/Forms/SubSettingControl.cs @@ -54,10 +54,7 @@ namespace v2rayN.Forms subItem.url = string.Empty; } - if (OnButtonClicked != null) - { - OnButtonClicked(sender, e); - } + OnButtonClicked?.Invoke(sender, e); } } } diff --git a/v2rayN/v2rayN/Forms/SubSettingForm.cs b/v2rayN/v2rayN/Forms/SubSettingForm.cs index 14b5fbf6..25ac20e6 100644 --- a/v2rayN/v2rayN/Forms/SubSettingForm.cs +++ b/v2rayN/v2rayN/Forms/SubSettingForm.cs @@ -47,9 +47,8 @@ namespace v2rayN.Forms } } - for (int k = 0; k < config.subItem.Count; k++) + foreach (var item in config.subItem) { - var item = config.subItem[k]; SubSettingControl control = new SubSettingControl(); control.OnButtonClicked += Control_OnButtonClicked; control.subItem = item; diff --git a/v2rayN/v2rayN/Global.cs b/v2rayN/v2rayN/Global.cs index f64cef38..68bef5ae 100644 --- a/v2rayN/v2rayN/Global.cs +++ b/v2rayN/v2rayN/Global.cs @@ -6,6 +6,7 @@ namespace v2rayN #region 常量 + public const string v2rayWebsiteUrl = @"https://www.v2ray.com/"; public const string AboutUrl = @"https://github.com/2dust/v2rayN"; public const string UpdateUrl = AboutUrl + @"/releases"; diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs index 3db74a47..bd9d16df 100644 --- a/v2rayN/v2rayN/Handler/ConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs @@ -247,7 +247,7 @@ namespace v2rayN.Handler } /// - /// 复制服务器 + /// 克隆服务器 /// /// /// @@ -274,7 +274,7 @@ namespace v2rayN.Handler vmessItem.streamSecurity = config.vmess[index].streamSecurity; vmessItem.remarks = string.Format("{0}-clone", config.vmess[index].remarks); - config.vmess.Add(vmessItem); + config.vmess.Insert(index + 1, vmessItem); // 插入到下一项 ToJsonFile(config); @@ -724,7 +724,7 @@ namespace v2rayN.Handler /// /// /// - /// + /// 成功导入的数量 public static int AddBatchServers(ref Config config, string clipboardData, string subid = "") { if (Utils.IsNullOrEmpty(clipboardData)) @@ -779,11 +779,7 @@ namespace v2rayN.Handler } } } - if (countServers > 0) - { - return 0; - } - return -1; + return countServers; } /// diff --git a/v2rayN/v2rayN/Handler/DownloadHandle.cs b/v2rayN/v2rayN/Handler/DownloadHandle.cs index cfbc9ab8..15aaf93b 100644 --- a/v2rayN/v2rayN/Handler/DownloadHandle.cs +++ b/v2rayN/v2rayN/Handler/DownloadHandle.cs @@ -4,7 +4,10 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Net; +using System.Net.Http; using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; using v2rayN.Base; using v2rayN.Mode; using v2rayN.Properties; @@ -47,98 +50,119 @@ namespace v2rayN.Handler private DateTime totalDatetime = new DateTime(); private int DownloadTimeout = -1; + #region Check for updates - - #region v2rayN - - private string nLatestUrl = "https://github.com/2dust/v2rayN/releases/latest"; + private readonly string nLatestUrl = "https://github.com/2dust/v2rayN/releases/latest"; private const string nUrl = "https://github.com/2dust/v2rayN/releases/download/{0}/v2rayN.zip"; + private readonly string coreLatestUrl = "https://github.com/v2ray/v2ray-core/releases/latest"; + private const string coreUrl = "https://github.com/v2ray/v2ray-core/releases/download/{0}/v2ray-windows-{1}.zip"; - public void AbsoluteV2rayN(Config config) + public async Task CheckUpdateAsync(string type) { Utils.SetSecurityProtocol(); - WebRequest request = WebRequest.Create(nLatestUrl); - request.BeginGetResponse(new AsyncCallback(OnResponseV2rayN), request); + WebRequestHandler webRequestHandler = new WebRequestHandler(); + webRequestHandler.AllowAutoRedirect = false; + HttpClient httpClient = new HttpClient(webRequestHandler); + + string url; + if (type == "Core") + { + url = coreLatestUrl; + } + else if (type == "v2rayN") + { + url = nLatestUrl; + } + else + { + throw new ArgumentException("Type"); + } + HttpResponseMessage response = await httpClient.GetAsync(url); + if (response.StatusCode.ToString() == "Redirect") + { + responseHandler(type, response.Headers.Location.ToString()); + } + else + { + Utils.SaveLog("StatusCode error: " + url); + return; + } } - private void OnResponseV2rayN(IAsyncResult ar) + /// + /// 获取V2RayCore版本 + /// + public string getV2rayVersion() { try { - HttpWebRequest request = (HttpWebRequest)ar.AsyncState; - HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(ar); - string redirectUrl = response.ResponseUri.AbsoluteUri; - string version = redirectUrl.Substring(redirectUrl.LastIndexOf("/", StringComparison.Ordinal) + 1); - - var curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString(); - if (curVersion == version) + string filePath = Utils.GetPath("V2ray.exe"); + if (!File.Exists(filePath)) { - if (AbsoluteCompleted != null) - { - AbsoluteCompleted(this, new ResultEventArgs(false, "Already the latest version")); - } - return; + string msg = string.Format(UIRes.I18N("NotFoundCore"), @"https://github.com/v2ray/v2ray-core/releases"); + //ShowMsg(true, msg); + return ""; } - string url = string.Format(nUrl, version); - if (AbsoluteCompleted != null) - { - AbsoluteCompleted(this, new ResultEventArgs(true, url)); - } + Process p = new Process(); + p.StartInfo.FileName = filePath; + p.StartInfo.Arguments = "-version"; + p.StartInfo.WorkingDirectory = Utils.StartupPath(); + p.StartInfo.UseShellExecute = false; + p.StartInfo.RedirectStandardOutput = true; + p.StartInfo.CreateNoWindow = true; + p.StartInfo.StandardOutputEncoding = Encoding.UTF8; + p.Start(); + p.WaitForExit(5000); + string echo = p.StandardOutput.ReadToEnd(); + string version = Regex.Match(echo, "V2Ray ([0-9.]+) \\(").Groups[1].Value; + return version; } + catch (Exception ex) { Utils.SaveLog(ex.Message, ex); - - if (Error != null) - Error(this, new ErrorEventArgs(ex)); + return ""; } } - - #endregion - - #region Core - - private string coreLatestUrl = "https://github.com/v2ray/v2ray-core/releases/latest"; - private const string coreUrl = "https://github.com/v2ray/v2ray-core/releases/download/{0}/v2ray-windows-{1}.zip"; - - public void AbsoluteV2rayCore(Config config) - { - Utils.SetSecurityProtocol(); - WebRequest request = WebRequest.Create(coreLatestUrl); - request.BeginGetResponse(new AsyncCallback(OnResponseV2rayCore), request); - } - - private void OnResponseV2rayCore(IAsyncResult ar) + private void responseHandler(string type, string redirectUrl) { try { - HttpWebRequest request = (HttpWebRequest)ar.AsyncState; - HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(ar); - string redirectUrl = response.ResponseUri.AbsoluteUri; string version = redirectUrl.Substring(redirectUrl.LastIndexOf("/", StringComparison.Ordinal) + 1); - string osBit = string.Empty; - if (Environment.Is64BitProcess) - { - osBit = "64"; + string curVersion; + string message; + string url; + if (type == "Core") { + curVersion = "v" + getV2rayVersion(); + message = string.Format(UIRes.I18N("IsLatestCore"), curVersion); + string osBit = Environment.Is64BitProcess ? "64" : "32"; + url = string.Format(coreUrl, version, osBit); + } + else if (type == "v2rayN") { + curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString(); + message = string.Format(UIRes.I18N("IsLatestN"), curVersion); + url = string.Format(nUrl, version); } else { - osBit = "32"; + throw new ArgumentException("Type"); } - string url = string.Format(coreUrl, version, osBit); - if (AbsoluteCompleted != null) + + if (curVersion == version) { - AbsoluteCompleted(this, new ResultEventArgs(true, url)); + AbsoluteCompleted?.Invoke(this, new ResultEventArgs(false, message)); + return; } + + AbsoluteCompleted?.Invoke(this, new ResultEventArgs(true, url)); } catch (Exception ex) { Utils.SaveLog(ex.Message, ex); - if (Error != null) - Error(this, new ErrorEventArgs(ex)); + Error?.Invoke(this, new ErrorEventArgs(ex)); } } @@ -151,10 +175,7 @@ namespace v2rayN.Handler try { Utils.SetSecurityProtocol(); - if (UpdateCompleted != null) - { - UpdateCompleted(this, new ResultEventArgs(false, "Downloading...")); - } + UpdateCompleted?.Invoke(this, new ResultEventArgs(false, "Downloading...")); progressPercentage = -1; totalBytesToReceive = 0; @@ -174,8 +195,7 @@ namespace v2rayN.Handler { Utils.SaveLog(ex.Message, ex); - if (Error != null) - Error(this, new ErrorEventArgs(ex)); + Error?.Invoke(this, new ErrorEventArgs(ex)); } } @@ -240,8 +260,7 @@ namespace v2rayN.Handler { Utils.SaveLog(ex.Message, ex); - if (Error != null) - Error(this, new ErrorEventArgs(ex)); + Error?.Invoke(this, new ErrorEventArgs(ex)); } } @@ -274,10 +293,7 @@ namespace v2rayN.Handler || Utils.IsNullOrEmpty(e.Error.ToString())) { string source = e.Result; - if (UpdateCompleted != null) - { - UpdateCompleted(this, new ResultEventArgs(true, source)); - } + UpdateCompleted?.Invoke(this, new ResultEventArgs(true, source)); } else { @@ -288,8 +304,7 @@ namespace v2rayN.Handler { Utils.SaveLog(ex.Message, ex); - if (Error != null) - Error(this, new ErrorEventArgs(ex)); + Error?.Invoke(this, new ErrorEventArgs(ex)); } } diff --git a/v2rayN/v2rayN/Handler/SpeedtestHandler.cs b/v2rayN/v2rayN/Handler/SpeedtestHandler.cs index 295650b0..69bc5a9c 100644 --- a/v2rayN/v2rayN/Handler/SpeedtestHandler.cs +++ b/v2rayN/v2rayN/Handler/SpeedtestHandler.cs @@ -72,9 +72,8 @@ namespace v2rayN.Handler { try { - for (int k = 0; k < _selecteds.Count; k++) + foreach (int index in _selecteds) { - int index = _selecteds[k]; if (_config.vmess[index].configType == (int)EConfigType.Custom) { continue; @@ -103,9 +102,8 @@ namespace v2rayN.Handler { try { - for (int k = 0; k < _selecteds.Count; k++) + foreach (int index in _selecteds) { - int index = _selecteds[k]; if (_config.vmess[index].configType == (int)EConfigType.Custom) { continue; @@ -121,7 +119,7 @@ namespace v2rayN.Handler } } - Thread.Sleep(100); + Thread.Sleep(10); } catch (Exception ex) @@ -142,9 +140,8 @@ namespace v2rayN.Handler Thread.Sleep(5000); var httpPort = _config.GetLocalPort("speedtest"); - for (int k = 0; k < _selecteds.Count; k++) + foreach (int index in _selecteds) { - int index = _selecteds[k]; if (_config.vmess[index].configType == (int)EConfigType.Custom) { continue; @@ -256,14 +253,24 @@ namespace v2rayN.Handler try { - IPHostEntry ipHostInfo = System.Net.Dns.GetHostEntry(url); - IPAddress ipAddress = ipHostInfo.AddressList[0]; + IPAddress ipAddress; + if (!System.Net.IPAddress.TryParse(url, out ipAddress)) + { + IPHostEntry ipHostInfo = System.Net.Dns.GetHostEntry(url); + ipAddress = ipHostInfo.AddressList[0]; + } var timer = new Stopwatch(); timer.Start(); - Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - clientSocket.Connect(new IPEndPoint(ipAddress, port)); + var endPoint = new IPEndPoint(ipAddress, port); + Socket clientSocket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); + + IAsyncResult result = clientSocket.BeginConnect(endPoint, null, null); + if (!result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(5))) + throw new TimeoutException("connect timeout (5s): " + url); + clientSocket.EndConnect(result); + timer.Stop(); responseTime = timer.Elapsed.Milliseconds; clientSocket.Close(); diff --git a/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs b/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs index 8c3a81f3..ec3ecbc0 100644 --- a/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs @@ -237,9 +237,9 @@ namespace v2rayN.Handler rulesIP.outboundTag = tag; rulesIP.ip = new List(); - for (int k = 0; k < userRule.Count; k++) + foreach (string u in userRule) { - string url = userRule[k].TrimEx(); + string url = u.TrimEx(); if (Utils.IsNullOrEmpty(url)) { continue; @@ -1424,9 +1424,8 @@ namespace v2rayN.Handler var httpPort = configCopy.GetLocalPort("speedtest"); - for (int k = 0; k < selecteds.Count; k++) + foreach (int index in selecteds) { - int index = selecteds[k]; if (configCopy.vmess[index].configType == (int)EConfigType.Custom) { continue; diff --git a/v2rayN/v2rayN/Handler/V2rayHandler.cs b/v2rayN/v2rayN/Handler/V2rayHandler.cs index 653efece..61d59bf6 100644 --- a/v2rayN/v2rayN/Handler/V2rayHandler.cs +++ b/v2rayN/v2rayN/Handler/V2rayHandler.cs @@ -152,9 +152,9 @@ namespace v2rayN.Handler { //查找v2ray文件是否存在 string fileName = string.Empty; - for (int k = 0; k < lstV2ray.Count; k++) + foreach (string name in lstV2ray) { - string vName = string.Format("{0}.exe", lstV2ray[k]); + string vName = string.Format("{0}.exe", name); vName = Utils.GetPath(vName); if (File.Exists(vName)) { @@ -202,14 +202,11 @@ namespace v2rayN.Handler /// /// 消息委托 /// - /// - /// - private void ShowMsg(bool notify, string msg) + /// 是否更新托盘图标的工具提示 + /// 输出到日志框 + private void ShowMsg(bool updateToTrayTooltip, string msg) { - if (ProcessEvent != null) - { - ProcessEvent(notify, msg); - } + ProcessEvent?.Invoke(updateToTrayTooltip, msg); } private void KillProcess(Process p) diff --git a/v2rayN/v2rayN/Program.cs b/v2rayN/v2rayN/Program.cs index 61797937..e40749ef 100644 --- a/v2rayN/v2rayN/Program.cs +++ b/v2rayN/v2rayN/Program.cs @@ -1,6 +1,7 @@ using System; using System.Diagnostics; using System.Reflection; +using System.Threading; using System.Windows.Forms; using v2rayN.Forms; using v2rayN.Properties; @@ -31,6 +32,7 @@ namespace v2rayN //AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; + Thread.Sleep(300); // 尽量避免切换语言后提示“已经运行” Process instance = RunningInstance(); if (instance == null) { diff --git a/v2rayN/v2rayN/Resx/ResUI.Designer.cs b/v2rayN/v2rayN/Resx/ResUI.Designer.cs index e80f0555..ae78335f 100644 --- a/v2rayN/v2rayN/Resx/ResUI.Designer.cs +++ b/v2rayN/v2rayN/Resx/ResUI.Designer.cs @@ -19,7 +19,7 @@ namespace v2rayN.Resx { // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen // (以 /str 作为命令选项),或重新生成 VS 项目。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class ResUI { @@ -267,6 +267,24 @@ namespace v2rayN.Resx { } } + /// + /// 查找类似 {0} already up to date. 的本地化字符串。 + /// + internal static string IsLatestCore { + get { + return ResourceManager.GetString("IsLatestCore", resourceCulture); + } + } + + /// + /// 查找类似 {0} already up to date. 的本地化字符串。 + /// + internal static string IsLatestN { + get { + return ResourceManager.GetString("IsLatestN", resourceCulture); + } + } + /// /// 查找类似 Address 的本地化字符串。 /// @@ -574,7 +592,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 V2ray-core not found, download address: {0} 的本地化字符串。 + /// 查找类似 V2ray-core not found, please download: {0} 的本地化字符串。 /// internal static string NotFoundCore { get { @@ -645,6 +663,15 @@ namespace v2rayN.Resx { } } + /// + /// 查找类似 Servers deduplication completed. Old: {0}, New: {1}. 的本地化字符串。 + /// + internal static string RemoveDuplicateServerResult { + get { + return ResourceManager.GetString("RemoveDuplicateServerResult", resourceCulture); + } + } + /// /// 查找类似 Are you sure to remove the server? 的本地化字符串。 /// @@ -691,7 +718,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 PAC failed to start. Pls with an administrator. 的本地化字符串。 + /// 查找类似 PAC failed to start. Run it with Admin right. 的本地化字符串。 /// internal static string StartPacFailed { get { @@ -700,7 +727,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Start service ({0})...... 的本地化字符串。 + /// 查找类似 Start service ({0})... 的本地化字符串。 /// internal static string StartService { get { @@ -728,7 +755,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Imported bulk URL from clipboard successfully 的本地化字符串。 + /// 查找类似 {0} servers have been imported from clipboard. 的本地化字符串。 /// internal static string SuccessfullyImportedServerViaClipboard { get { diff --git a/v2rayN/v2rayN/Resx/ResUI.resx b/v2rayN/v2rayN/Resx/ResUI.resx index 74280a36..0767dc8c 100644 --- a/v2rayN/v2rayN/Resx/ResUI.resx +++ b/v2rayN/v2rayN/Resx/ResUI.resx @@ -175,7 +175,7 @@ Successfully imported custom configuration server - Imported bulk URL from clipboard successfully + {0} servers have been imported from clipboard. Note that custom configuration relies entirely on your own configuration and does not work with all settings. The system agent is available when the socks port is equal to the port in the settings in the custom configuration inbound. @@ -236,10 +236,16 @@ {0} - V2ray-core not found, download address: {0} + V2ray-core not found, please download: {0} + + + {0} already up to date. + + + {0} already up to date. - Start service ({0})...... + Start service ({0})... Address @@ -344,6 +350,9 @@ Total upload traffic - PAC failed to start. Pls with an administrator. + PAC failed to start. Run it with Admin right. + + + Servers deduplication completed. Old: {0}, New: {1}. \ No newline at end of file diff --git a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx index cf7cab26..5a3a465a 100644 --- a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx @@ -175,7 +175,7 @@ 成功导入自定义配置服务器 - 从剪贴板导入批量URL成功 + 成功从剪贴板导入 {0} 个服务器 注意,自定义配置完全依赖您自己的配置,不能使用所有设置功能。在自定义配置inbound中有socks port等于设置中的port时,系统代理才可用 @@ -236,10 +236,16 @@ {0} - 未找到v2ray-core,下载地址:{0} + 找不到 v2ray-core,下载地址: {0} + + + {0} 已是最新版本。 + + + {0} 已是最新版本。 - 启动服务({0})...... + 启动服务({0})... 地址 @@ -254,7 +260,7 @@ 端口 - 服务类型 + 类型 订阅 @@ -346,4 +352,7 @@ PAC服务启动失败,请用管理员启动 + + 服务器去重完成。原数量: {0},现数量: {1} + \ No newline at end of file diff --git a/v2rayN/v2rayN/Tool/UI.cs b/v2rayN/v2rayN/Tool/UI.cs index 8225a291..267c8366 100644 --- a/v2rayN/v2rayN/Tool/UI.cs +++ b/v2rayN/v2rayN/Tool/UI.cs @@ -7,7 +7,7 @@ namespace v2rayN { public static void Show(string msg) { - MessageBox.Show(msg); + MessageBox.Show(msg, "v2rayN", MessageBoxButtons.OK, MessageBoxIcon.Information); } public static DialogResult ShowYesNo(string msg) diff --git a/v2rayN/v2rayN/Tool/Utils.cs b/v2rayN/v2rayN/Tool/Utils.cs index 2e840ecd..b7da94e8 100644 --- a/v2rayN/v2rayN/Tool/Utils.cs +++ b/v2rayN/v2rayN/Tool/Utils.cs @@ -317,7 +317,7 @@ namespace v2rayN double result; string unit; ToHumanReadable(amount, out result, out unit); - return $"{string.Format("{0:f1}", result)}{unit}"; + return $"{string.Format("{0:f1}", result)} {unit}"; } public static void DedupServerList(List source, out List result) diff --git a/v2rayN/v2rayN/v2rayN.csproj b/v2rayN/v2rayN/v2rayN.csproj index b9bb5a70..002d99e3 100644 --- a/v2rayN/v2rayN/v2rayN.csproj +++ b/v2rayN/v2rayN/v2rayN.csproj @@ -116,6 +116,8 @@ + + False LIB\System.Runtime.CompilerServices.Unsafe.dll