From 025a4491edeb32fb9e479daa8b2f5b97e6e7fc0f Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Fri, 23 Aug 2019 15:51:37 +0800 Subject: [PATCH 1/8] Add ping and speedtest hotkeys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加测速快捷键 --- v2rayN/v2rayN/Forms/MainForm.Designer.cs | 25 +- v2rayN/v2rayN/Forms/MainForm.cs | 22 +- v2rayN/v2rayN/Forms/MainForm.resx | 180 +-- .../Forms/OptionSettingForm.Designer.cs | 9 + v2rayN/v2rayN/Forms/OptionSettingForm.cs | 3 + v2rayN/v2rayN/Forms/OptionSettingForm.resx | 1182 +++++------------ .../Forms/OptionSettingForm.zh-Hans.resx | 3 + v2rayN/v2rayN/Mode/Config.cs | 5 + 8 files changed, 490 insertions(+), 939 deletions(-) diff --git a/v2rayN/v2rayN/Forms/MainForm.Designer.cs b/v2rayN/v2rayN/Forms/MainForm.Designer.cs index c6e1bba8..92bca0ba 100644 --- a/v2rayN/v2rayN/Forms/MainForm.Designer.cs +++ b/v2rayN/v2rayN/Forms/MainForm.Designer.cs @@ -82,8 +82,10 @@ this.toolSslSocksPortLab = new System.Windows.Forms.ToolStripStatusLabel(); this.toolSslSocksPort = new System.Windows.Forms.ToolStripStatusLabel(); this.toolSslBlank1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolSslHttpPortLab = new System.Windows.Forms.ToolStripStatusLabel(); this.toolSslHttpPort = new System.Windows.Forms.ToolStripStatusLabel(); this.toolSslBlank2 = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolSslPacPortLab = new System.Windows.Forms.ToolStripStatusLabel(); this.toolSslPacPort = new System.Windows.Forms.ToolStripStatusLabel(); this.toolSslBlank3 = new System.Windows.Forms.ToolStripStatusLabel(); this.panel1 = new System.Windows.Forms.Panel(); @@ -111,8 +113,6 @@ this.tsbPromotion = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator(); this.tsbClose = new System.Windows.Forms.ToolStripButton(); - this.toolSslHttpPortLab = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolSslPacPortLab = new System.Windows.Forms.ToolStripStatusLabel(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -147,6 +147,7 @@ this.lvServers.FullRowSelect = true; this.lvServers.GridLines = true; this.lvServers.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.lvServers.HideSelection = false; this.lvServers.Items.AddRange(new System.Windows.Forms.ListViewItem[] { ((System.Windows.Forms.ListViewItem)(resources.GetObject("lvServers.Items")))}); this.lvServers.MultiSelect = false; @@ -507,6 +508,11 @@ resources.ApplyResources(this.toolSslBlank1, "toolSslBlank1"); this.toolSslBlank1.Spring = true; // + // toolSslHttpPortLab + // + this.toolSslHttpPortLab.Name = "toolSslHttpPortLab"; + resources.ApplyResources(this.toolSslHttpPortLab, "toolSslHttpPortLab"); + // // toolSslHttpPort // this.toolSslHttpPort.Name = "toolSslHttpPort"; @@ -518,6 +524,11 @@ resources.ApplyResources(this.toolSslBlank2, "toolSslBlank2"); this.toolSslBlank2.Spring = true; // + // toolSslPacPortLab + // + this.toolSslPacPortLab.Name = "toolSslPacPortLab"; + resources.ApplyResources(this.toolSslPacPortLab, "toolSslPacPortLab"); + // // toolSslPacPort // this.toolSslPacPort.Name = "toolSslPacPort"; @@ -702,16 +713,6 @@ this.tsbClose.Name = "tsbClose"; this.tsbClose.Click += new System.EventHandler(this.tsbClose_Click); // - // toolSslHttpPortLab - // - this.toolSslHttpPortLab.Name = "toolSslHttpPortLab"; - resources.ApplyResources(this.toolSslHttpPortLab, "toolSslHttpPortLab"); - // - // toolSslPacPortLab - // - this.toolSslPacPortLab.Name = "toolSslPacPortLab"; - resources.ApplyResources(this.toolSslPacPortLab, "toolSslPacPortLab"); - // // MainForm // resources.ApplyResources(this, "$this"); diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index b96cc3a7..1ba50537 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -80,7 +80,7 @@ namespace v2rayN.Forms { //config.uiItem.mainQRCodeWidth = splitContainer1.SplitterDistance; } - + private const int WM_QUERYENDSESSION = 0x0011; protected override void WndProc(ref Message m) { @@ -360,6 +360,22 @@ namespace v2rayN.Forms menuSelectAll_Click(null, null); break; } + if (config.enableHotkey) + { + if (e.KeyCode == Keys.T) + { + // Speed test selected servers + GetLvSelectedIndex(); + ServerSpeedTest(); + } + else if (e.KeyCode == Keys.P) + { + // Ping selected servers + GetLvSelectedIndex(); + ClearTestResult(); + bgwPing.RunWorkerAsync(); + } + } } switch (e.KeyCode) { @@ -884,6 +900,7 @@ namespace v2rayN.Forms } catch { + } } @@ -1394,8 +1411,7 @@ namespace v2rayN.Forms Utils.RegWriteValue(Global.MyRegPath, Global.MyRegKeyLanguage, value); } + #endregion - - } } diff --git a/v2rayN/v2rayN/Forms/MainForm.resx b/v2rayN/v2rayN/Forms/MainForm.resx index 61cfde87..d2f676fc 100644 --- a/v2rayN/v2rayN/Forms/MainForm.resx +++ b/v2rayN/v2rayN/Forms/MainForm.resx @@ -404,33 +404,12 @@ NoControl - - 265, 164 - - - cmsMain - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - v2rayN - - - True - 264, 22 Enable Http proxy - - 264, 22 - - - Http proxy mode - 547, 22 @@ -455,6 +434,12 @@ Only open PAC, do not automatically configure PAC + + 264, 22 + + + Http proxy mode + 264, 22 @@ -488,6 +473,21 @@ Exit + + 265, 164 + + + cmsMain + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + v2rayN + + + True + 232, 17 @@ -567,7 +567,7 @@ 0, 17 - 238, 17 + 282, 17 38, 17 @@ -579,7 +579,7 @@ 0, 17 - 238, 17 + 282, 17 31, 17 @@ -591,7 +591,7 @@ 0, 17 - 238, 17 + 282, 17 3, 151 @@ -671,42 +671,9 @@ 409, 17 - - 0, 0 - - - 992, 56 - - - 6 - - - tsMain - - - System.Windows.Forms.ToolStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 5 - 6, 56 - - Magenta - - - 93, 53 - - - Subscription - - - ImageAboveText - 197, 22 @@ -719,6 +686,18 @@ Update subscription + + Magenta + + + 93, 53 + + + Subscription + + + ImageAboveText + 6, 56 @@ -766,18 +745,6 @@ 6, 56 - - Magenta - - - 128, 53 - - - Check for updates - - - ImageAboveText - 338, 22 @@ -802,21 +769,21 @@ Simplify PAC (please set Core route) - - 6, 56 - - + Magenta - - 48, 53 + + 128, 53 - - Help + + Check for updates - + ImageAboveText + + 6, 56 + 187, 22 @@ -838,6 +805,18 @@ 语言-[中文简体] + + Magenta + + + 48, 53 + + + Help + + + ImageAboveText + Magenta @@ -872,6 +851,27 @@ ImageAboveText + + 0, 0 + + + 992, 56 + + + 6 + + + tsMain + + + System.Windows.Forms.ToolStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 5 + True @@ -1148,6 +1148,12 @@ System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + toolSslHttpPortLab + + + System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + toolSslHttpPort @@ -1160,6 +1166,12 @@ System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + toolSslPacPortLab + + + System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + toolSslPacPort @@ -1310,18 +1322,6 @@ System.Windows.Forms.ToolStripButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - toolSslHttpPortLab - - - System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - toolSslPacPortLab - - - System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - MainForm diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs b/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs index 8c5eb9b9..59060468 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs @@ -82,6 +82,7 @@ this.txtKcpmtu = new System.Windows.Forms.TextBox(); this.label6 = new System.Windows.Forms.Label(); this.tabPage7 = new System.Windows.Forms.TabPage(); + this.chkEnableHotkey = new System.Windows.Forms.CheckBox(); this.chkAllowLANConn = new System.Windows.Forms.CheckBox(); this.txturlGFWList = new System.Windows.Forms.TextBox(); this.label13 = new System.Windows.Forms.Label(); @@ -473,6 +474,7 @@ // // tabPage7 // + this.tabPage7.Controls.Add(this.chkEnableHotkey); this.tabPage7.Controls.Add(this.chkAllowLANConn); this.tabPage7.Controls.Add(this.txturlGFWList); this.tabPage7.Controls.Add(this.label13); @@ -481,6 +483,12 @@ this.tabPage7.Name = "tabPage7"; this.tabPage7.UseVisualStyleBackColor = true; // + // chkEnableHotkey + // + resources.ApplyResources(this.chkEnableHotkey, "chkEnableHotkey"); + this.chkEnableHotkey.Name = "chkEnableHotkey"; + this.chkEnableHotkey.UseVisualStyleBackColor = true; + // // chkAllowLANConn // resources.ApplyResources(this.chkAllowLANConn, "chkAllowLANConn"); @@ -619,5 +627,6 @@ private System.Windows.Forms.CheckBox chksniffingEnabled; private System.Windows.Forms.CheckBox chksniffingEnabled2; private System.Windows.Forms.Button btnSetDefRountingRule; + private System.Windows.Forms.CheckBox chkEnableHotkey; } } \ No newline at end of file diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.cs b/v2rayN/v2rayN/Forms/OptionSettingForm.cs index e45af2b6..db858bbd 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.cs +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.cs @@ -293,6 +293,9 @@ namespace v2rayN.Forms config.allowLANConn = chkAllowLANConn.Checked; + //快捷键 + config.enableHotkey = chkEnableHotkey.Checked; + return 0; } diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.resx b/v2rayN/v2rayN/Forms/OptionSettingForm.resx index 9a4a727c..5d6fe55e 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.resx +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.resx @@ -183,273 +183,6 @@ 0 - - tabPage3 - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl2 - - - 0 - - - tabPage4 - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl2 - - - 1 - - - tabPage5 - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl2 - - - 2 - - - Fill - - - 3, 124 - - - 618, 446 - - - 12 - - - tabControl2 - - - System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox2 - - - 0 - - - 356, 43 - - - 229, 23 - - - 18 - - - Set default custom routing rules - - - btnSetDefRountingRule - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 0 - - - AsIs - - - IPIfNonMatch - - - IPOnDemand - - - 123, 13 - - - 209, 20 - - - 16 - - - cmbdomainStrategy - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 1 - - - 5, 83 - - - 598, 16 - - - 13 - - - *Set the rules, separated by commas (,); support Domain (pure string / regular / subdomain) and IP - - - labRoutingTips - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 2 - - - True - - - NoControl - - - 13, 17 - - - 95, 12 - - - 17 - - - Domain strategy - - - label15 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 3 - - - True - - - NoControl - - - 13, 50 - - - 77, 12 - - - 15 - - - Routing mode - - - label12 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 4 - - - Global - - - Bypassing the LAN address - - - Bypass mainland address - - - Bypassing LAN and mainland address - - - 123, 46 - - - 209, 20 - - - 14 - - - cmbroutingMode - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 5 - - - Top - - - 3, 17 - - - 618, 107 - - - 19 - - - panel3 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox2 - - - 1 - - - Fill - - - 3, 3 - - - 624, 573 - - - 12 - groupBox2 @@ -672,6 +405,51 @@ 2 + + True + + + NoControl + + + 15, 60 + + + 102, 16 + + + 29 + + + Enable hotkey(Ctrl+P ping servers / Ctrl+T speed test) + + + chkEnableHotkey + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage7 + + + 0 + + + True + + + 15, 38 + + + 204, 16 + + + 29 + + + Allow connections from the LAN + chkAllowLANConn @@ -682,7 +460,16 @@ tabPage7 - 0 + 1 + + + 30, 132 + + + 468, 21 + + + 28 txturlGFWList @@ -694,7 +481,22 @@ tabPage7 - 1 + 2 + + + True + + + 30, 111 + + + 431, 12 + + + 27 + + + Custom GFWList address (please fill in the blank without customization) label13 @@ -706,7 +508,22 @@ tabPage7 - 2 + 3 + + + True + + + 15, 16 + + + 132, 16 + + + 23 + + + Boot automatically chkAutoRun @@ -718,7 +535,7 @@ tabPage7 - 3 + 4 4, 22 @@ -999,18 +816,6 @@ 6 - - groupBox1 - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage1 - - - 0 - True @@ -1032,18 +837,6 @@ False - - chksniffingEnabled2 - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 0 - True @@ -1062,18 +855,6 @@ Turn on Sniffing - - chksniffingEnabled - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 1 - 33, 192 @@ -1083,18 +864,6 @@ 30 - - txtremoteDNS - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 2 - True @@ -1110,18 +879,6 @@ Custom DNS (multiple, separated by commas (,)) - - label14 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 3 - True @@ -1137,18 +894,6 @@ Turn on Mux Multiplexing - - chkmuxEnabled - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 4 - True @@ -1167,18 +912,6 @@ False - - chkAllowIn2 - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 5 - True @@ -1197,18 +930,6 @@ False - - chkudpEnabled2 - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 6 - socks @@ -1227,18 +948,6 @@ False - - cmbprotocol2 - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 7 - True @@ -1257,18 +966,6 @@ False - - label3 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 8 - 124, 60 @@ -1281,18 +978,6 @@ False - - txtlocalPort2 - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 9 - False @@ -1311,18 +996,6 @@ 12 - - cmbprotocol - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 10 - True @@ -1338,18 +1011,6 @@ protocol - - label1 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 11 - True @@ -1365,18 +1026,6 @@ Enable UDP - - chkudpEnabled - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 12 - True @@ -1392,18 +1041,6 @@ Record local logs - - chklogEnabled - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 13 - debug @@ -1428,18 +1065,6 @@ 6 - - cmbloglevel - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 14 - True @@ -1455,18 +1080,6 @@ Log level - - label5 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 15 - 124, 25 @@ -1476,18 +1089,6 @@ 3 - - txtlocalPort - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 16 - True @@ -1503,17 +1104,89 @@ Listening port - - label2 + + tabControl2 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - groupBox1 + + groupBox2 - - 17 + + 0 + + + panel3 + + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 1 + + + Fill + + + 3, 3 + + + 624, 573 + + + 12 + + + tabPage3 + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabControl2 + + + 0 + + + tabPage4 + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabControl2 + + + 1 + + + tabPage5 + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabControl2 + + + 2 + + + Fill + + + 3, 124 + + + 618, 446 + + + 12 txtUseragent @@ -1542,18 +1215,6 @@ Proxy's Domain or IP - - tabPage3 - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl2 - - - 0 - Fill @@ -1572,18 +1233,6 @@ 0 - - txtUseragent - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage3 - - - 0 - txtUserdirect @@ -1611,18 +1260,6 @@ Directly connected Domain or IP - - tabPage4 - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl2 - - - 1 - Fill @@ -1641,18 +1278,6 @@ 1 - - txtUserdirect - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage4 - - - 0 - txtUserblock @@ -1680,18 +1305,6 @@ Blocked Domain or IP - - tabPage5 - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl2 - - - 2 - Fill @@ -1710,18 +1323,189 @@ 1 - - txtUserblock + + btnSetDefRountingRule - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - tabPage5 + + panel3 - + 0 + + cmbdomainStrategy + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel3 + + + 1 + + + labRoutingTips + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel3 + + + 2 + + + label15 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel3 + + + 3 + + + label12 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel3 + + + 4 + + + cmbroutingMode + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel3 + + + 5 + + + Top + + + 3, 17 + + + 618, 107 + + + 19 + + + 356, 43 + + + 229, 23 + + + 18 + + + Set default custom routing rules + + + AsIs + + + IPIfNonMatch + + + IPOnDemand + + + 123, 13 + + + 209, 20 + + + 16 + + + 5, 83 + + + 598, 16 + + + 13 + + + *Set the rules, separated by commas (,); support Domain (pure string / regular / subdomain) and IP + + + True + + + NoControl + + + 13, 17 + + + 95, 12 + + + 17 + + + Domain strategy + + + True + + + NoControl + + + 13, 50 + + + 77, 12 + + + 15 + + + Routing mode + + + Global + + + Bypassing the LAN address + + + Bypass mainland address + + + Bypassing LAN and mainland address + + + 123, 46 + + + 209, 20 + + + 14 + True @@ -1737,18 +1521,6 @@ congestion - - chkKcpcongestion - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage6 - - - 0 - 345, 100 @@ -1758,18 +1530,6 @@ 15 - - txtKcpwriteBufferSize - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage6 - - - 1 - True @@ -1785,18 +1545,6 @@ writeBufferSize - - label10 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage6 - - - 2 - 111, 100 @@ -1806,18 +1554,6 @@ 13 - - txtKcpreadBufferSize - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage6 - - - 3 - True @@ -1833,18 +1569,6 @@ readBufferSize - - label11 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage6 - - - 4 - 345, 62 @@ -1854,18 +1578,6 @@ 11 - - txtKcpdownlinkCapacity - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage6 - - - 5 - True @@ -1881,18 +1593,6 @@ downlinkCapacity - - label8 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage6 - - - 6 - 111, 62 @@ -1902,18 +1602,6 @@ 9 - - txtKcpuplinkCapacity - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage6 - - - 7 - True @@ -1929,18 +1617,6 @@ uplinkCapacity - - label9 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage6 - - - 8 - 345, 24 @@ -1950,18 +1626,6 @@ 7 - - txtKcptti - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage6 - - - 9 - True @@ -1977,18 +1641,6 @@ tti - - label7 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage6 - - - 10 - 111, 24 @@ -1998,18 +1650,6 @@ 5 - - txtKcpmtu - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage6 - - - 11 - True @@ -2025,120 +1665,6 @@ mtu - - label6 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage6 - - - 12 - - - True - - - 15, 42 - - - 204, 16 - - - 29 - - - Allow connections from the LAN - - - chkAllowLANConn - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage7 - - - 0 - - - 30, 132 - - - 468, 21 - - - 28 - - - txturlGFWList - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage7 - - - 1 - - - True - - - 30, 111 - - - 431, 12 - - - 27 - - - Custom GFWList address (please fill in the blank without customization) - - - label13 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage7 - - - 2 - - - True - - - 15, 16 - - - 132, 16 - - - 23 - - - Boot automatically - - - chkAutoRun - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage7 - - - 3 - btnOK @@ -2187,18 +1713,6 @@ &OK - - btnOK - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel2 - - - 1 - Top @@ -2223,9 +1737,9 @@ 2 - + True - + 6, 12 diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx b/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx index d0a2519d..7eb0a790 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx @@ -288,4 +288,7 @@ 参数设置 + + 启用快捷键(Ctrl+P ping 选中服务器/ Ctrl+T 测速选中服务器) + \ No newline at end of file diff --git a/v2rayN/v2rayN/Mode/Config.cs b/v2rayN/v2rayN/Mode/Config.cs index 929efece..86b86d14 100644 --- a/v2rayN/v2rayN/Mode/Config.cs +++ b/v2rayN/v2rayN/Mode/Config.cs @@ -91,6 +91,11 @@ namespace v2rayN.Mode /// public bool allowLANConn { get; set; } + /// + /// 启用快捷键 + /// + public bool enableHotkey{ get; set; } + /// /// 自定义远程DNS /// From 649f0af6ec95f9dc3b170a0fc7e39f5feedc6f95 Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Fri, 23 Aug 2019 18:07:25 +0800 Subject: [PATCH 2/8] add Hotkeys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加测速快捷键 --- v2rayN/v2rayN/Forms/MainForm.cs | 13 +- v2rayN/v2rayN/Forms/MainForm.resx | 6 +- v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx | 24 +- .../Forms/OptionSettingForm.Designer.cs | 9 - v2rayN/v2rayN/Forms/OptionSettingForm.cs | 3 - v2rayN/v2rayN/Forms/OptionSettingForm.resx | 2212 ++++++++--------- v2rayN/v2rayN/Mode/Config.cs | 5 - 7 files changed, 1110 insertions(+), 1162 deletions(-) diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index 1ba50537..25b78410 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -359,22 +359,17 @@ namespace v2rayN.Forms case Keys.A: menuSelectAll_Click(null, null); break; - } - if (config.enableHotkey) - { - if (e.KeyCode == Keys.T) - { + case Keys.T: // Speed test selected servers GetLvSelectedIndex(); ServerSpeedTest(); - } - else if (e.KeyCode == Keys.P) - { + break; + case Keys.P: // Ping selected servers GetLvSelectedIndex(); ClearTestResult(); bgwPing.RunWorkerAsync(); - } + break; } } switch (e.KeyCode) diff --git a/v2rayN/v2rayN/Forms/MainForm.resx b/v2rayN/v2rayN/Forms/MainForm.resx index d2f676fc..20ba91e0 100644 --- a/v2rayN/v2rayN/Forms/MainForm.resx +++ b/v2rayN/v2rayN/Forms/MainForm.resx @@ -225,13 +225,13 @@ 447, 22 - Test server delay (multiple choice) + Test server delay (multiple choice)(Ctrl+P) 447, 22 - Test server speed (multiple choice) + Test server speed (multiple choice)(Ctrl+T) 444, 6 @@ -273,7 +273,7 @@ ImageAboveText - 448, 468 + 448, 490 cmsLv diff --git a/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx b/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx index 8395e525..e25e9c82 100644 --- a/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx +++ b/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx @@ -215,13 +215,13 @@ 252, 22 - 测试服务器延迟(多选) + 测试服务器延迟(多选)(Ctrl+P) 252, 22 - 测试服务器速度(多选) + 测试服务器速度(多选)(Ctrl+T) 249, 6 @@ -380,13 +380,13 @@ - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAE3SURBVFhH7ZaBDQIhDEVvBEdwBDfQDXQER3AD3cARdAPd - QDfSDbQvuSb1AicFjJrwkxcN0FIolOuamv5VE2E+gLaPayWchEcE+hhTXVPhIoQmDcFYbKpoJtwEdX4X - jgIrXfTwnzb6dBw22BaJVdjJmWQs1/SdBRtE0U5cBXW2oSFRO0HtSEeW2FZ1wsq9sjuRdTDVAXnNuWLY - 6JnAl0sYa/Q5q1dhq35ci+Bkq2HJvbZpxGeybAAuw4Fq+cnW1wPITgHFYxvBUw+qHEIL1yq1vDKhVlH3 - NQwF4JkcFRWiUAB7IVW2FFPO3YqlgPd+LJf02e8Fdi3rMdIAcLDuf9UpeT0IS0G/hvhPm305vSl7EQFY - B6zCvozvYGzRM8zEoeg5TPZwDaGvpHQni1yzSxbXPW9q+hF13ROHuJnQcjbhtQAAAABJRU5ErkJggg== + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + wwAADsMBx2+oZAAAATdJREFUWEftloENAiEMRW8ER3AEN9ANdARHcAPdwBF0A91AN9INtC+5JvUCJwWM + mvCTFw3QUiiU65qa/lUTYT6Ato9rJZyERwT6GFNdU+EihCYNwVhsqmgm3AR1fheOAitd9PCfNvp0HDbY + FolV2MmZZCzX9J0FG0TRTlwFdbahIVE7Qe1IR5bYVnXCyr2yO5F1MNUBec25YtjomcCXSxhr9DmrV2Gr + flyL4GSrYcm9tmnEZ7JsAC7DgWr5ydbXA8hOAcVjG8FTD6ocQgvXKrW8MqFWUfc1DAXgmRwVFaJQAHsh + VbYUU87diqWA934sl/TZ7wV2Lesx0gBwsO5/1Sl5PQhLQb+G+E+bfTm9KXsRAVgHrMK+jO9gbNEzzMSh + 6DlM9nANoa+kdCeLXLNLFtc9b2r6EXXdE4e4mdByNuG1AAAAAElFTkSuQmCC @@ -442,9 +442,9 @@ - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAySURBVFhH7c6xDQAgCEVBRnVTHU2ZABuMxV3yOvJDAAA/ - GqfZVG6X8mg1dfUAAPBQxAZd0SJruVXHWwAAAABJRU5ErkJggg== + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + wwAADsMBx2+oZAAAADJJREFUWEftzrENACAIRUFGdVMdTZkAG4zFXfI68kMAAD8ap9lUbpfyaDV19QAA + 8FDEBl3RImu5VcdbAAAAAElFTkSuQmCC diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs b/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs index 59060468..8c5eb9b9 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs @@ -82,7 +82,6 @@ this.txtKcpmtu = new System.Windows.Forms.TextBox(); this.label6 = new System.Windows.Forms.Label(); this.tabPage7 = new System.Windows.Forms.TabPage(); - this.chkEnableHotkey = new System.Windows.Forms.CheckBox(); this.chkAllowLANConn = new System.Windows.Forms.CheckBox(); this.txturlGFWList = new System.Windows.Forms.TextBox(); this.label13 = new System.Windows.Forms.Label(); @@ -474,7 +473,6 @@ // // tabPage7 // - this.tabPage7.Controls.Add(this.chkEnableHotkey); this.tabPage7.Controls.Add(this.chkAllowLANConn); this.tabPage7.Controls.Add(this.txturlGFWList); this.tabPage7.Controls.Add(this.label13); @@ -483,12 +481,6 @@ this.tabPage7.Name = "tabPage7"; this.tabPage7.UseVisualStyleBackColor = true; // - // chkEnableHotkey - // - resources.ApplyResources(this.chkEnableHotkey, "chkEnableHotkey"); - this.chkEnableHotkey.Name = "chkEnableHotkey"; - this.chkEnableHotkey.UseVisualStyleBackColor = true; - // // chkAllowLANConn // resources.ApplyResources(this.chkAllowLANConn, "chkAllowLANConn"); @@ -627,6 +619,5 @@ private System.Windows.Forms.CheckBox chksniffingEnabled; private System.Windows.Forms.CheckBox chksniffingEnabled2; private System.Windows.Forms.Button btnSetDefRountingRule; - private System.Windows.Forms.CheckBox chkEnableHotkey; } } \ No newline at end of file diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.cs b/v2rayN/v2rayN/Forms/OptionSettingForm.cs index db858bbd..e45af2b6 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.cs +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.cs @@ -293,9 +293,6 @@ namespace v2rayN.Forms config.allowLANConn = chkAllowLANConn.Checked; - //快捷键 - config.enableHotkey = chkEnableHotkey.Checked; - return 0; } diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.resx b/v2rayN/v2rayN/Forms/OptionSettingForm.resx index 5d6fe55e..d9d5d01a 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.resx +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.resx @@ -143,6 +143,523 @@ 0 + + True + + + + NoControl + + + 468, 60 + + + 120, 16 + + + 32 + + + Turn on Sniffing + + + False + + + chksniffingEnabled2 + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 0 + + + True + + + NoControl + + + 468, 27 + + + 120, 16 + + + 31 + + + Turn on Sniffing + + + chksniffingEnabled + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 1 + + + 33, 192 + + + 402, 21 + + + 30 + + + txtremoteDNS + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 2 + + + True + + + 33, 168 + + + 281, 12 + + + 29 + + + Custom DNS (multiple, separated by commas (,)) + + + label14 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 3 + + + True + + + 15, 93 + + + 174, 16 + + + 20 + + + Turn on Mux Multiplexing + + + chkmuxEnabled + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 4 + + + True + + + 15, 63 + + + 120, 16 + + + 19 + + + listening port 2 + + + False + + + chkAllowIn2 + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 5 + + + True + + + 369, 62 + + + 84, 16 + + + 18 + + + Enable UDP + + + False + + + chkudpEnabled2 + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 6 + + + socks + + + http + + + 257, 60 + + + 97, 20 + + + 17 + + + False + + + cmbprotocol2 + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 7 + + + True + + + 206, 64 + + + 53, 12 + + + 16 + + + protocol + + + False + + + label3 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 8 + + + 124, 60 + + + 78, 21 + + + 14 + + + False + + + txtlocalPort2 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 9 + + + False + + + socks + + + http + + + 257, 25 + + + 97, 20 + + + 12 + + + cmbprotocol + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 10 + + + True + + + 206, 29 + + + 53, 12 + + + 11 + + + protocol + + + label1 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 11 + + + True + + + 369, 27 + + + 84, 16 + + + 10 + + + Enable UDP + + + chkudpEnabled + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 12 + + + True + + + 15, 124 + + + 126, 16 + + + 9 + + + Record local logs + + + chklogEnabled + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 13 + + + debug + + + info + + + warning + + + error + + + none + + + 257, 122 + + + 97, 20 + + + 6 + + + cmbloglevel + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 14 + + + True + + + 193, 126 + + + 59, 12 + + + 8 + + + Log level + + + label5 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 15 + + + 124, 25 + + + 78, 21 + + + 3 + + + txtlocalPort + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 16 + + + True + + + 33, 29 + + + 89, 12 + + + 2 + + + Listening port + + + label2 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 17 + + + Fill + + + 3, 3 + + + 624, 573 + + + 6 + groupBox1 @@ -158,7 +675,6 @@ 4, 22 - 3, 3, 3, 3 @@ -183,6 +699,408 @@ 0 + + Fill + + + 3, 3 + + + True + + + Vertical + + + 604, 414 + + + 0 + + + txtUseragent + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage3 + + + 0 + + + 4, 22 + + + 3, 3, 3, 3 + + + 610, 420 + + + 0 + + + Proxy's Domain or IP + + + tabPage3 + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabControl2 + + + 0 + + + Fill + + + 3, 3 + + + True + + + Vertical + + + 604, 414 + + + 1 + + + txtUserdirect + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage4 + + + 0 + + + 4, 22 + + + 3, 3, 3, 3 + + + 610, 420 + + + 1 + + + Directly connected Domain or IP + + + tabPage4 + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabControl2 + + + 1 + + + Fill + + + 3, 3 + + + True + + + Vertical + + + 604, 414 + + + 1 + + + txtUserblock + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage5 + + + 0 + + + 4, 22 + + + 3, 3, 3, 3 + + + 610, 420 + + + 2 + + + Blocked Domain or IP + + + tabPage5 + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabControl2 + + + 2 + + + Fill + + + 3, 124 + + + 618, 446 + + + 12 + + + tabControl2 + + + System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 0 + + + 356, 43 + + + 229, 23 + + + 18 + + + Set default custom routing rules + + + btnSetDefRountingRule + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel3 + + + 0 + + + AsIs + + + IPIfNonMatch + + + IPOnDemand + + + 123, 13 + + + 209, 20 + + + 16 + + + cmbdomainStrategy + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel3 + + + 1 + + + 5, 83 + + + 598, 16 + + + 13 + + + *Set the rules, separated by commas (,); support Domain (pure string / regular / subdomain) and IP + + + labRoutingTips + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel3 + + + 2 + + + True + + + NoControl + + + 13, 17 + + + 95, 12 + + + 17 + + + Domain strategy + + + label15 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel3 + + + 3 + + + True + + + NoControl + + + 13, 50 + + + 77, 12 + + + 15 + + + Routing mode + + + label12 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel3 + + + 4 + + + Global + + + Bypassing the LAN address + + + Bypass mainland address + + + Bypassing LAN and mainland address + + + 123, 46 + + + 209, 20 + + + 14 + + + cmbroutingMode + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel3 + + + 5 + + + Top + + + 3, 17 + + + 618, 107 + + + 19 + + + panel3 + + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 1 + + + Fill + + + 3, 3 + + + 624, 573 + + + 12 + groupBox2 @@ -222,6 +1140,21 @@ 1 + + True + + + 20, 143 + + + 84, 16 + + + 20 + + + congestion + chkKcpcongestion @@ -234,6 +1167,15 @@ 0 + + 345, 100 + + + 94, 21 + + + 15 + txtKcpwriteBufferSize @@ -246,6 +1188,21 @@ 1 + + True + + + 236, 104 + + + 95, 12 + + + 14 + + + writeBufferSize + label10 @@ -258,6 +1215,15 @@ 2 + + 111, 100 + + + 94, 21 + + + 13 + txtKcpreadBufferSize @@ -270,6 +1236,21 @@ 3 + + True + + + 18, 104 + + + 89, 12 + + + 12 + + + readBufferSize + label11 @@ -282,6 +1263,15 @@ 4 + + 345, 62 + + + 94, 21 + + + 11 + txtKcpdownlinkCapacity @@ -294,6 +1284,21 @@ 5 + + True + + + 236, 66 + + + 101, 12 + + + 10 + + + downlinkCapacity + label8 @@ -306,6 +1311,15 @@ 6 + + 111, 62 + + + 94, 21 + + + 9 + txtKcpuplinkCapacity @@ -318,6 +1332,21 @@ 7 + + True + + + 18, 66 + + + 89, 12 + + + 8 + + + uplinkCapacity + label9 @@ -330,6 +1359,15 @@ 8 + + 345, 24 + + + 94, 21 + + + 7 + txtKcptti @@ -342,6 +1380,21 @@ 9 + + True + + + 236, 28 + + + 23, 12 + + + 6 + + + tti + label7 @@ -354,6 +1407,15 @@ 10 + + 111, 24 + + + 94, 21 + + + 5 + txtKcpmtu @@ -366,6 +1428,21 @@ 11 + + True + + + 18, 28 + + + 23, 12 + + + 4 + + + mtu + label6 @@ -405,36 +1482,6 @@ 2 - - True - - - NoControl - - - 15, 60 - - - 102, 16 - - - 29 - - - Enable hotkey(Ctrl+P ping servers / Ctrl+T speed test) - - - chkEnableHotkey - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage7 - - - 0 - True @@ -460,7 +1507,7 @@ tabPage7 - 1 + 0 30, 132 @@ -481,7 +1528,7 @@ tabPage7 - 2 + 1 True @@ -508,7 +1555,7 @@ tabPage7 - 3 + 2 True @@ -535,7 +1582,7 @@ tabPage7 - 4 + 3 4, 22 @@ -588,1082 +1635,17 @@ 0 - - chksniffingEnabled2 + + 267, 16 - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 75, 23 - - groupBox1 - - - 0 - - - chksniffingEnabled - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 1 - - - txtremoteDNS - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 2 - - - label14 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 3 - - - chkmuxEnabled - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 4 - - - chkAllowIn2 - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 5 - - - chkudpEnabled2 - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 6 - - - cmbprotocol2 - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 7 - - - label3 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - + 8 - - txtlocalPort2 - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 9 - - - cmbprotocol - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 10 - - - label1 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 11 - - - chkudpEnabled - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 12 - - - chklogEnabled - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 13 - - - cmbloglevel - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 14 - - - label5 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 15 - - - txtlocalPort - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 16 - - - label2 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 17 - - - Fill - - - 3, 3 - - - 624, 573 - - - 6 - - - True - - - NoControl - - - 468, 60 - - - 120, 16 - - - 32 - - - Turn on Sniffing - - - False - - - True - - - NoControl - - - 468, 27 - - - 120, 16 - - - 31 - - - Turn on Sniffing - - - 33, 192 - - - 402, 21 - - - 30 - - - True - - - 33, 168 - - - 281, 12 - - - 29 - - - Custom DNS (multiple, separated by commas (,)) - - - True - - - 15, 93 - - - 174, 16 - - - 20 - - - Turn on Mux Multiplexing - - - True - - - 15, 63 - - - 120, 16 - - - 19 - - - listening port 2 - - - False - - - True - - - 369, 62 - - - 84, 16 - - - 18 - - - Enable UDP - - - False - - - socks - - - http - - - 257, 60 - - - 97, 20 - - - 17 - - - False - - - True - - - 206, 64 - - - 53, 12 - - - 16 - - - protocol - - - False - - - 124, 60 - - - 78, 21 - - - 14 - - - False - - - False - - - socks - - - http - - - 257, 25 - - - 97, 20 - - - 12 - - - True - - - 206, 29 - - - 53, 12 - - - 11 - - - protocol - - - True - - - 369, 27 - - - 84, 16 - - - 10 - - - Enable UDP - - - True - - - 15, 124 - - - 126, 16 - - - 9 - - - Record local logs - - - debug - - - info - - - warning - - - error - - - none - - - 257, 122 - - - 97, 20 - - - 6 - - - True - - - 193, 126 - - - 59, 12 - - - 8 - - - Log level - - - 124, 25 - - - 78, 21 - - - 3 - - - True - - - 33, 29 - - - 89, 12 - - - 2 - - - Listening port - - - tabControl2 - - - System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox2 - - - 0 - - - panel3 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox2 - - - 1 - - - Fill - - - 3, 3 - - - 624, 573 - - - 12 - - - tabPage3 - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl2 - - - 0 - - - tabPage4 - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl2 - - - 1 - - - tabPage5 - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl2 - - - 2 - - - Fill - - - 3, 124 - - - 618, 446 - - - 12 - - - txtUseragent - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage3 - - - 0 - - - 4, 22 - - - 3, 3, 3, 3 - - - 610, 420 - - - 0 - - - Proxy's Domain or IP - - - Fill - - - 3, 3 - - - True - - - Vertical - - - 604, 414 - - - 0 - - - txtUserdirect - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage4 - - - 0 - - - 4, 22 - - - 3, 3, 3, 3 - - - 610, 420 - - - 1 - - - Directly connected Domain or IP - - - Fill - - - 3, 3 - - - True - - - Vertical - - - 604, 414 - - - 1 - - - txtUserblock - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage5 - - - 0 - - - 4, 22 - - - 3, 3, 3, 3 - - - 610, 420 - - - 2 - - - Blocked Domain or IP - - - Fill - - - 3, 3 - - - True - - - Vertical - - - 604, 414 - - - 1 - - - btnSetDefRountingRule - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 0 - - - cmbdomainStrategy - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 1 - - - labRoutingTips - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 2 - - - label15 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 3 - - - label12 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 4 - - - cmbroutingMode - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 5 - - - Top - - - 3, 17 - - - 618, 107 - - - 19 - - - 356, 43 - - - 229, 23 - - - 18 - - - Set default custom routing rules - - - AsIs - - - IPIfNonMatch - - - IPOnDemand - - - 123, 13 - - - 209, 20 - - - 16 - - - 5, 83 - - - 598, 16 - - - 13 - - - *Set the rules, separated by commas (,); support Domain (pure string / regular / subdomain) and IP - - - True - - - NoControl - - - 13, 17 - - - 95, 12 - - - 17 - - - Domain strategy - - - True - - - NoControl - - - 13, 50 - - - 77, 12 - - - 15 - - - Routing mode - - - Global - - - Bypassing the LAN address - - - Bypass mainland address - - - Bypassing LAN and mainland address - - - 123, 46 - - - 209, 20 - - - 14 - - - True - - - 20, 143 - - - 84, 16 - - - 20 - - - congestion - - - 345, 100 - - - 94, 21 - - - 15 - - - True - - - 236, 104 - - - 95, 12 - - - 14 - - - writeBufferSize - - - 111, 100 - - - 94, 21 - - - 13 - - - True - - - 18, 104 - - - 89, 12 - - - 12 - - - readBufferSize - - - 345, 62 - - - 94, 21 - - - 11 - - - True - - - 236, 66 - - - 101, 12 - - - 10 - - - downlinkCapacity - - - 111, 62 - - - 94, 21 - - - 9 - - - True - - - 18, 66 - - - 89, 12 - - - 8 - - - uplinkCapacity - - - 345, 24 - - - 94, 21 - - - 7 - - - True - - - 236, 28 - - - 23, 12 - - - 6 - - - tti - - - 111, 24 - - - 94, 21 - - - 5 - - - True - - - 18, 28 - - - 23, 12 - - - 4 - - - mtu + + &OK btnOK @@ -1701,18 +1683,6 @@ 1 - - 267, 16 - - - 75, 23 - - - 8 - - - &OK - Top @@ -1737,9 +1707,9 @@ 2 - + True - + 6, 12 diff --git a/v2rayN/v2rayN/Mode/Config.cs b/v2rayN/v2rayN/Mode/Config.cs index 86b86d14..929efece 100644 --- a/v2rayN/v2rayN/Mode/Config.cs +++ b/v2rayN/v2rayN/Mode/Config.cs @@ -91,11 +91,6 @@ namespace v2rayN.Mode /// public bool allowLANConn { get; set; } - /// - /// 启用快捷键 - /// - public bool enableHotkey{ get; set; } - /// /// 自定义远程DNS /// From f1e973708038507fd372aeb8e5958bb6ed41d727 Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Sat, 24 Aug 2019 21:32:33 +0800 Subject: [PATCH 3/8] basically completed --- v2rayN/v2rayN/Forms/MainForm.Designer.cs | 19 +- v2rayN/v2rayN/Forms/MainForm.cs | 21 ++ v2rayN/v2rayN/Forms/MainForm.resx | 32 ++- .../Forms/OptionSettingForm.Designer.cs | 51 +++++ v2rayN/v2rayN/Forms/OptionSettingForm.cs | 32 +++ v2rayN/v2rayN/Forms/OptionSettingForm.resx | 152 +++++++++++++- .../Forms/OptionSettingForm.zh-Hans.resx | 9 + v2rayN/v2rayN/Global.cs | 13 ++ v2rayN/v2rayN/Handler/ConfigHandler.cs | 9 + v2rayN/v2rayN/Handler/StatisticsHandler.cs | 159 +++++++++++++++ v2rayN/v2rayN/Handler/V2rayConfigHandler.cs | 49 +++++ v2rayN/v2rayN/Mode/Config.cs | 26 +++ v2rayN/v2rayN/Mode/V2rayConfig.cs | 64 ++++++ .../DataSources/v2rayN.Mode.Config.datasource | 10 + v2rayN/v2rayN/Resx/ResUI.Designer.cs | 189 ++++++++++-------- v2rayN/v2rayN/Resx/ResUI.resx | 9 + v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx | 9 + v2rayN/v2rayN/Sample/SampleClientConfig.txt | 68 +++++-- v2rayN/v2rayN/v2rayN.csproj | 2 + 19 files changed, 814 insertions(+), 109 deletions(-) create mode 100644 v2rayN/v2rayN/Handler/StatisticsHandler.cs create mode 100644 v2rayN/v2rayN/Properties/DataSources/v2rayN.Mode.Config.datasource diff --git a/v2rayN/v2rayN/Forms/MainForm.Designer.cs b/v2rayN/v2rayN/Forms/MainForm.Designer.cs index 92bca0ba..a48ab929 100644 --- a/v2rayN/v2rayN/Forms/MainForm.Designer.cs +++ b/v2rayN/v2rayN/Forms/MainForm.Designer.cs @@ -88,6 +88,8 @@ this.toolSslPacPortLab = new System.Windows.Forms.ToolStripStatusLabel(); this.toolSslPacPort = new System.Windows.Forms.ToolStripStatusLabel(); this.toolSslBlank3 = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolSslServerSpeed = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolSslBlank4 = new System.Windows.Forms.ToolStripStatusLabel(); this.panel1 = new System.Windows.Forms.Panel(); this.tsMain = new System.Windows.Forms.ToolStrip(); this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); @@ -487,7 +489,9 @@ this.toolSslBlank2, this.toolSslPacPortLab, this.toolSslPacPort, - this.toolSslBlank3}); + this.toolSslBlank3, + this.toolSslServerSpeed, + this.toolSslBlank4}); resources.ApplyResources(this.ssMain, "ssMain"); this.ssMain.Name = "ssMain"; this.ssMain.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.ssMain_ItemClicked); @@ -540,6 +544,16 @@ resources.ApplyResources(this.toolSslBlank3, "toolSslBlank3"); this.toolSslBlank3.Spring = true; // + // toolSslServerSpeed + // + this.toolSslServerSpeed.Name = "toolSslServerSpeed"; + resources.ApplyResources(this.toolSslServerSpeed, "toolSslServerSpeed"); + // + // toolSslBlank4 + // + this.toolSslBlank4.Name = "toolSslBlank4"; + resources.ApplyResources(this.toolSslBlank4, "toolSslBlank4"); + // // panel1 // resources.ApplyResources(this.panel1, "panel1"); @@ -727,6 +741,7 @@ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); this.Load += new System.EventHandler(this.MainForm_Load); this.Shown += new System.EventHandler(this.MainForm_Shown); + this.VisibleChanged += new System.EventHandler(this.MainForm_VisibleChanged); this.Resize += new System.EventHandler(this.MainForm_Resize); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); @@ -831,6 +846,8 @@ private System.Windows.Forms.ToolStripStatusLabel toolSslSocksPortLab; private System.Windows.Forms.ToolStripStatusLabel toolSslHttpPortLab; private System.Windows.Forms.ToolStripStatusLabel toolSslPacPortLab; + private System.Windows.Forms.ToolStripStatusLabel toolSslServerSpeed; + private System.Windows.Forms.ToolStripStatusLabel toolSslBlank4; } } diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index 25b78410..a4a7d2e5 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -18,6 +18,8 @@ namespace v2rayN.Forms private V2rayUpdateHandle v2rayUpdateHandle2; private List lvSelecteds = new List(); + private StatisticsHandler statistics; + #region Window 事件 public MainForm() @@ -39,7 +41,24 @@ namespace v2rayN.Forms ConfigHandler.LoadConfig(ref config); v2rayHandler = new V2rayHandler(); v2rayHandler.ProcessEvent += v2rayHandler_ProcessEvent; + statistics = new StatisticsHandler(config, + (ulong totalUp, ulong totalDown, ulong up, ulong down) => + { + toolSslBlank4.Text = down.ToString(); + }); + } + private void MainForm_VisibleChanged(object sender, EventArgs e) + { + if (statistics == null) return; + if((sender as Form).Visible) + { + statistics.UpdateUI = true; + } + else + { + statistics.UpdateUI = false; + } } private void MainForm_Shown(object sender, EventArgs e) @@ -90,6 +109,7 @@ namespace v2rayN.Forms Utils.SaveLog("Windows shutdown UnsetProxy"); //CloseV2ray(); ConfigHandler.ToJsonFile(config); + statistics.saveToFile(); ProxySetting.UnsetProxy(); m.Result = (IntPtr)1; break; @@ -1408,5 +1428,6 @@ namespace v2rayN.Forms #endregion + } } diff --git a/v2rayN/v2rayN/Forms/MainForm.resx b/v2rayN/v2rayN/Forms/MainForm.resx index 20ba91e0..1c8fbd92 100644 --- a/v2rayN/v2rayN/Forms/MainForm.resx +++ b/v2rayN/v2rayN/Forms/MainForm.resx @@ -273,7 +273,7 @@ ImageAboveText - 448, 490 + 448, 468 cmsLv @@ -567,7 +567,7 @@ 0, 17 - 282, 17 + 257, 17 38, 17 @@ -579,7 +579,7 @@ 0, 17 - 282, 17 + 257, 17 31, 17 @@ -591,7 +591,19 @@ 0, 17 - 282, 17 + 257, 17 + + + 45, 17 + + + SPEED + + + 31, 17 + + + N/A 3, 151 @@ -1184,6 +1196,18 @@ System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + toolSslServerSpeed + + + System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + toolSslBlank4 + + + System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + toolStripSeparator4 diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs b/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs index 8c5eb9b9..f642333e 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs @@ -28,6 +28,7 @@ /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OptionSettingForm)); this.btnClose = new System.Windows.Forms.Button(); this.tabControl1 = new System.Windows.Forms.TabControl(); @@ -82,6 +83,9 @@ this.txtKcpmtu = new System.Windows.Forms.TextBox(); this.label6 = new System.Windows.Forms.Label(); this.tabPage7 = new System.Windows.Forms.TabPage(); + this.tbCacheDays = new System.Windows.Forms.TextBox(); + this.lbCacheDays = new System.Windows.Forms.Label(); + this.chkEnableStatistics = new System.Windows.Forms.CheckBox(); this.chkAllowLANConn = new System.Windows.Forms.CheckBox(); this.txturlGFWList = new System.Windows.Forms.TextBox(); this.label13 = new System.Windows.Forms.Label(); @@ -89,6 +93,9 @@ this.panel2 = new System.Windows.Forms.Panel(); this.btnOK = new System.Windows.Forms.Button(); this.panel1 = new System.Windows.Forms.Panel(); + this.cbFreshrate = new System.Windows.Forms.ComboBox(); + this.lbFreshrate = new System.Windows.Forms.Label(); + this.configBindingSource = new System.Windows.Forms.BindingSource(this.components); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.groupBox1.SuspendLayout(); @@ -102,6 +109,7 @@ this.tabPage6.SuspendLayout(); this.tabPage7.SuspendLayout(); this.panel2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.configBindingSource)).BeginInit(); this.SuspendLayout(); // // btnClose @@ -473,6 +481,11 @@ // // tabPage7 // + this.tabPage7.Controls.Add(this.cbFreshrate); + this.tabPage7.Controls.Add(this.tbCacheDays); + this.tabPage7.Controls.Add(this.lbFreshrate); + this.tabPage7.Controls.Add(this.lbCacheDays); + this.tabPage7.Controls.Add(this.chkEnableStatistics); this.tabPage7.Controls.Add(this.chkAllowLANConn); this.tabPage7.Controls.Add(this.txturlGFWList); this.tabPage7.Controls.Add(this.label13); @@ -481,6 +494,22 @@ this.tabPage7.Name = "tabPage7"; this.tabPage7.UseVisualStyleBackColor = true; // + // tbCacheDays + // + resources.ApplyResources(this.tbCacheDays, "tbCacheDays"); + this.tbCacheDays.Name = "tbCacheDays"; + // + // lbCacheDays + // + resources.ApplyResources(this.lbCacheDays, "lbCacheDays"); + this.lbCacheDays.Name = "lbCacheDays"; + // + // chkEnableStatistics + // + resources.ApplyResources(this.chkEnableStatistics, "chkEnableStatistics"); + this.chkEnableStatistics.Name = "chkEnableStatistics"; + this.chkEnableStatistics.UseVisualStyleBackColor = true; + // // chkAllowLANConn // resources.ApplyResources(this.chkAllowLANConn, "chkAllowLANConn"); @@ -522,6 +551,21 @@ resources.ApplyResources(this.panel1, "panel1"); this.panel1.Name = "panel1"; // + // cbFreshrate + // + this.cbFreshrate.FormattingEnabled = true; + resources.ApplyResources(this.cbFreshrate, "cbFreshrate"); + this.cbFreshrate.Name = "cbFreshrate"; + // + // lbFreshrate + // + resources.ApplyResources(this.lbFreshrate, "lbFreshrate"); + this.lbFreshrate.Name = "lbFreshrate"; + // + // configBindingSource + // + this.configBindingSource.DataSource = typeof(v2rayN.Mode.Config); + // // OptionSettingForm // resources.ApplyResources(this, "$this"); @@ -553,6 +597,7 @@ this.tabPage7.ResumeLayout(false); this.tabPage7.PerformLayout(); this.panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.configBindingSource)).EndInit(); this.ResumeLayout(false); } @@ -619,5 +664,11 @@ private System.Windows.Forms.CheckBox chksniffingEnabled; private System.Windows.Forms.CheckBox chksniffingEnabled2; private System.Windows.Forms.Button btnSetDefRountingRule; + private System.Windows.Forms.CheckBox chkEnableStatistics; + private System.Windows.Forms.TextBox tbCacheDays; + private System.Windows.Forms.Label lbCacheDays; + private System.Windows.Forms.ComboBox cbFreshrate; + private System.Windows.Forms.Label lbFreshrate; + private System.Windows.Forms.BindingSource configBindingSource; } } \ No newline at end of file diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.cs b/v2rayN/v2rayN/Forms/OptionSettingForm.cs index e45af2b6..f64f9271 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.cs +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.cs @@ -106,6 +106,24 @@ namespace v2rayN.Forms chkAllowLANConn.Checked = config.allowLANConn; + + var enableStatistics = config.enableStatistics; + chkEnableStatistics.Checked = enableStatistics; + + tbCacheDays.Enabled = enableStatistics; + tbCacheDays.Text = config.CacheDays.ToString(); + + + + cbFreshrate.DataSource = new ComboItem[] + { + new ComboItem{ID = (int)Global.StatisticsFreshRate.quick, Text = UIRes.I18N("QuickFresh")}, + new ComboItem{ID = (int)Global.StatisticsFreshRate.medium, Text = UIRes.I18N("MediumFresh")}, + new ComboItem{ID = (int)Global.StatisticsFreshRate.slow, Text = UIRes.I18N("SlowFresh")}, + }; + + cbFreshrate.DisplayMember = "Text"; + cbFreshrate.ValueMember = "ID"; } private void btnOK_Click(object sender, EventArgs e) @@ -293,6 +311,14 @@ namespace v2rayN.Forms config.allowLANConn = chkAllowLANConn.Checked; + config.enableStatistics = chkEnableStatistics.Checked; + + uint days = 0; + var valid = uint.TryParse(tbCacheDays.Text, out days); + if (!valid) + days = 7; + config.CacheDays = days; + return 0; } @@ -358,4 +384,10 @@ namespace v2rayN.Forms labRoutingTips.Text = text; } } + + class ComboItem + { + public int ID { get; set; } + public string Text { get; set; } + } } diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.resx b/v2rayN/v2rayN/Forms/OptionSettingForm.resx index d9d5d01a..16622a9b 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.resx +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.resx @@ -1482,6 +1482,135 @@ 2 + + 161, 82 + + + 121, 20 + + + 32 + + + cbFreshrate + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage7 + + + 0 + + + 516, 109 + + + 60, 21 + + + 31 + + + tbCacheDays + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage7 + + + 1 + + + True + + + NoControl + + + 30, 90 + + + 125, 12 + + + 30 + + + Statistics freshrate + + + lbFreshrate + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage7 + + + 2 + + + True + + + 30, 118 + + + 455, 12 + + + 30 + + + Cache days(between 0 to 30, 0 disable cache indivitual days statistic data) + + + lbCacheDays + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage7 + + + 3 + + + True + + + NoControl + + + 15, 60 + + + 390, 16 + + + 29 + + + Enable Statistics(Realtime net speed and traffic data amount) + + + chkEnableStatistics + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage7 + + + 4 + True @@ -1507,13 +1636,13 @@ tabPage7 - 0 + 5 - 30, 132 + 32, 205 - 468, 21 + 544, 21 28 @@ -1528,13 +1657,13 @@ tabPage7 - 1 + 6 True - 30, 111 + 30, 176 431, 12 @@ -1555,7 +1684,7 @@ tabPage7 - 2 + 7 True @@ -1582,7 +1711,7 @@ tabPage7 - 3 + 8 4, 22 @@ -1707,6 +1836,9 @@ 2 + + 17, 17 + True @@ -1722,6 +1854,12 @@ Settings + + configBindingSource + + + System.Windows.Forms.BindingSource, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + OptionSettingForm diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx b/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx index 7eb0a790..1f11bc0f 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx @@ -291,4 +291,13 @@ 启用快捷键(Ctrl+P ping 选中服务器/ Ctrl+T 测速选中服务器) + + 启用统计(实时网速显示和使用流量显示) + + + 缓存天数(0-30, 0关闭缓存单独每天的数据使用情况) + + + 统计刷新频率 + \ No newline at end of file diff --git a/v2rayN/v2rayN/Global.cs b/v2rayN/v2rayN/Global.cs index 782b4d06..b854be90 100644 --- a/v2rayN/v2rayN/Global.cs +++ b/v2rayN/v2rayN/Global.cs @@ -141,6 +141,19 @@ namespace v2rayN /// public const string CustomIconName = "v2rayN.ico"; + + public const string InboundAPITagName = "api"; + public const string InboundProxyTagName = "proxy"; + public const string Loopback = "127.0.0.1"; + public const string InboundAPIProtocal = "dokodemo-door"; + public const uint InboundAPIPort = 10085; + public enum StatisticsFreshRate + { + quick = 1000, + medium = 2000, + slow = 3000 + } + #endregion #region 全局变量 diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs index ba229b80..ba87e466 100644 --- a/v2rayN/v2rayN/Handler/ConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs @@ -40,6 +40,15 @@ namespace v2rayN.Handler ////默认监听端口 //config.pacPort = 8888; + + // 默认缓存七天 + config.CacheDays = 7; + + // 默认不开启统计 + config.enableStatistics = false; + + // 默认中等刷新率 + config.statisticsFreshRate = (int)Global.StatisticsFreshRate.medium; } //本地监听 diff --git a/v2rayN/v2rayN/Handler/StatisticsHandler.cs b/v2rayN/v2rayN/Handler/StatisticsHandler.cs new file mode 100644 index 00000000..2ab1d687 --- /dev/null +++ b/v2rayN/v2rayN/Handler/StatisticsHandler.cs @@ -0,0 +1,159 @@ +using System; +using System.Threading; +using System.IO; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Diagnostics; + +using v2rayN.Mode; + +namespace v2rayN.Handler +{ + class StatisticsHandler + { + private Config config_; + private const string cliName_ = "v2ctl.exe"; + private string args_ = ""; + + private Process connector_; + + private Thread workThread_; + + Action updateFunc_; + + private bool enabled_; + public bool Enable + { + get { return enabled_; } + set { enabled_ = value; } + } + + public bool UpdateUI; + + private StringBuilder outputBuilder_; + + public UInt64 TotalUp { get; private set; } + + public UInt64 TotalDown { get; private set; } + + public UInt64 Up { get; private set; } + + public UInt64 Down { get; private set; } + + public StatisticsHandler(Config config, Action update) + { + config_ = config; + enabled_ = config.enableStatistics; + UpdateUI = false; + updateFunc_ = update; + + outputBuilder_ = new StringBuilder(); + + var fullPath = Utils.GetPath(cliName_); + + if (!File.Exists(fullPath)) + { + connector_ = null; + return; + } + + // .\v2ctl.exe api --server="127.0.0.1:port" StatsService.QueryStats "reset:true" + args_ = string.Format("api --server=\"127.0.0.1:{0}\" StatsService.QueryStats \"reset:true\"", Global.InboundAPIPort); + + connector_ = new Process(); + connector_.StartInfo.FileName = fullPath; + connector_.StartInfo.Arguments = args_; + connector_.StartInfo.RedirectStandardOutput = true; + connector_.StartInfo.UseShellExecute = false; + connector_.StartInfo.CreateNoWindow = true; + + + workThread_ = new Thread(new ThreadStart(run)); + workThread_.Start(); + } + + public void run() + { + try + { + while (true) + { + if (enabled_) + { + connector_.Start(); + string output = connector_.StandardOutput.ReadToEnd(); + UInt64 up = 0; + UInt64 down = 0; + + //TODO: parse output + parseOutput(output, out up, out down); + + Up = up; + Down = down; + + TotalUp += up; + TotalDown += down; + + if (UpdateUI) + updateFunc_(TotalUp, TotalDown, Up, Down); + Thread.Sleep(config_.statisticsFreshRate); + } + } + } + catch (Exception e) + { } + } + + public void parseOutput(string source, out UInt64 up, out UInt64 down) + { + // (?<=name: ")(.*?)(?=")|(?<=value: )(.*?) + var datas = Regex.Matches(source, "(?<=name: \")(?.*?)(?=\").*?(?<=value: )(?.*?)(?=>)", RegexOptions.Singleline); + + up = 0; down = 0; + + foreach(Match match in datas) + { + var g = match.Groups; + var name = g["name"].Value; + var value = g["value"].Value; + var nStr = name.Split(">>>".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + var type = ""; + + name = name.Trim(); + value = value.Trim(); + + name = nStr[1]; + type = nStr[3]; + + try + { + if (name == Global.InboundProxyTagName) + { + if (type == "uplink") + { + up = UInt64.Parse(value); + } + else if (type == "downlink") + { + down = UInt64.Parse(value); + } + } + } + catch { } + } + } + + public void saveToFile() + { + + } + + public void loadFromFile() + { + + } + } +} diff --git a/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs b/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs index d9eb4267..bf417ab0 100644 --- a/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs @@ -4,6 +4,7 @@ using System.IO; using v2rayN.Mode; using System.Net; using System.Text; +using System.Linq; namespace v2rayN.Handler { @@ -78,6 +79,9 @@ namespace v2rayN.Handler //dns dns(config, ref v2rayConfig); + // TODO: 统计配置 + statistic(config, ref v2rayConfig); + Utils.ToJsonFile(v2rayConfig, fileName); msg = string.Format(UIRes.I18N("SuccessfulConfiguration"), config.getSummary()); @@ -613,6 +617,51 @@ namespace v2rayN.Handler return 0; } + public static int statistic(Config config, ref V2rayConfig v2rayConfig) + { + if (config.enableStatistics) + { + var tag = Global.InboundAPITagName; + var apiObj = new Mode.API(); + var policyObj = new Mode.Policy(); + var policySystemSetting = new Mode.SystemPolicy(); + + string[] services = { "StatsService" }; + + v2rayConfig.stats = new Stats(); + + apiObj.tag = tag; + apiObj.services = services.ToList(); + v2rayConfig.api = apiObj; + + policySystemSetting.statsInboundDownlink = true; + policySystemSetting.statsInboundUplink = true; + policyObj.system = policySystemSetting; + v2rayConfig.policy = policyObj; + if(!v2rayConfig.inbounds.Exists(item => { return item.tag == tag; })) + { + var apiInbound = new Mode.Inbounds(); + var apiInboundSettings = new Mode.Inboundsettings(); + apiInbound.tag = tag; + apiInbound.listen = Global.Loopback; + apiInbound.port = config.port(); + apiInbound.protocol = Global.InboundAPIProtocal; + apiInboundSettings.address = Global.Loopback; + apiInbound.settings = apiInboundSettings; + v2rayConfig.inbounds.Add(apiInbound); + } + if(!v2rayConfig.routing.rules.Exists(item => { return item.outboundTag == tag; })) + { + var apiRoutingRule = new Mode.RulesItem(); + apiRoutingRule.inboundTag = tag; + apiRoutingRule.outboundTag = tag; + apiRoutingRule.type = "field"; + v2rayConfig.routing.rules.Add(apiRoutingRule); + } + } + return 0; + } + /// /// 生成v2ray的客户端配置文件(自定义配置) /// diff --git a/v2rayN/v2rayN/Mode/Config.cs b/v2rayN/v2rayN/Mode/Config.cs index 929efece..47b21e78 100644 --- a/v2rayN/v2rayN/Mode/Config.cs +++ b/v2rayN/v2rayN/Mode/Config.cs @@ -91,6 +91,32 @@ namespace v2rayN.Mode /// public bool allowLANConn { get; set; } + /// + /// 启用实时网速和流量统计 + /// + public bool enableStatistics { get; set; } + + /// + /// 视图刷新率 + /// + public int statisticsFreshRate { get; set; } + + /// + /// 统计数据缓存天数 [0, 30] + /// * 0 关闭单独每天使用流量的缓存 + /// * 无论如何不会关闭总流量的缓存 + /// + private uint cacheDays; + public uint CacheDays { + get { return cacheDays; } + set + { + if (value < 0) cacheDays = 0; + else if (value > 30) cacheDays = 30; + else cacheDays = value; + } + } + /// /// 自定义远程DNS /// diff --git a/v2rayN/v2rayN/Mode/V2rayConfig.cs b/v2rayN/v2rayN/Mode/V2rayConfig.cs index b6502abb..d969b539 100644 --- a/v2rayN/v2rayN/Mode/V2rayConfig.cs +++ b/v2rayN/v2rayN/Mode/V2rayConfig.cs @@ -21,6 +21,43 @@ namespace v2rayN.Mode /// public List outbounds { get; set; } + /// 网速统计 + /// 使用v2ray api功能 + /// + /// routing->rules 需要加上这一条 + /// { + /// "inboundTag": [ + /// "api" + /// ], + /// "outboundTag": "api", + /// "type": "field" + /// } + + /// + /// 统计需要, 空对象 + /// + public Stats stats { get; set; } + + /// + /// 需要tag和services + /// "api": { + /// "tag": "api", + /// "services": [ + /// "StatsService" + /// ] + /// } + /// + public API api { get; set; } + + /// + /// policy 都设置为true; + /// "system": { + /// "statsInboundUplink": true, + /// "statsInboundDownlink": true + /// } + /// + public Policy policy; + /// /// DNS 配置 /// @@ -31,6 +68,25 @@ namespace v2rayN.Mode public Routing routing { get; set; } } + public class Stats { }; + + public class API + { + public string tag { get; set; } + public List services { get; set; } + } + + public class Policy + { + public SystemPolicy system; + } + + public class SystemPolicy + { + public bool statsInboundUplink; + public bool statsInboundDownlink; + } + public class Log { /// @@ -49,6 +105,7 @@ namespace v2rayN.Mode public class Inbounds { + public string tag { get; set; } /// /// /// @@ -92,6 +149,11 @@ namespace v2rayN.Mode /// public string ip { get; set; } + /// + /// api 使用 + /// + public string address { get; set; } + /// /// /// @@ -273,6 +335,8 @@ namespace v2rayN.Mode /// /// public string port { get; set; } + + public string inboundTag { get; set; } /// /// /// diff --git a/v2rayN/v2rayN/Properties/DataSources/v2rayN.Mode.Config.datasource b/v2rayN/v2rayN/Properties/DataSources/v2rayN.Mode.Config.datasource new file mode 100644 index 00000000..73249b2c --- /dev/null +++ b/v2rayN/v2rayN/Properties/DataSources/v2rayN.Mode.Config.datasource @@ -0,0 +1,10 @@ + + + + v2rayN.Mode.Config, v2rayN, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/v2rayN/v2rayN/Resx/ResUI.Designer.cs b/v2rayN/v2rayN/Resx/ResUI.Designer.cs index c580c02b..8b66bfc2 100644 --- a/v2rayN/v2rayN/Resx/ResUI.Designer.cs +++ b/v2rayN/v2rayN/Resx/ResUI.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// 此代码由工具生成。 -// 运行时版本:4.0.30319.42000 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -13,13 +13,13 @@ namespace v2rayN.Resx { /// - /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// A strongly-typed resource class, for looking up localized strings, etc. /// - // 此类是由 StronglyTypedResourceBuilder - // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 - // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen - // (以 /str 作为命令选项),或重新生成 VS 项目。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [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 { @@ -33,7 +33,7 @@ namespace v2rayN.Resx { } /// - /// 返回此类使用的缓存的 ResourceManager 实例。 + /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { @@ -47,8 +47,8 @@ namespace v2rayN.Resx { } /// - /// 使用此强类型资源类,为所有资源查找 - /// 重写当前线程的 CurrentUICulture 属性。 + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { @@ -61,7 +61,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Batch export subscription to clipboard successfully 的本地化字符串。 + /// Looks up a localized string similar to Batch export subscription to clipboard successfully. /// internal static string BatchExportSubscriptionSuccessfully { get { @@ -70,7 +70,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Batch export share URL to clipboard successfully 的本地化字符串。 + /// Looks up a localized string similar to Batch export share URL to clipboard successfully. /// internal static string BatchExportURLSuccessfully { get { @@ -79,7 +79,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Please check the server settings first 的本地化字符串。 + /// Looks up a localized string similar to Please check the server settings first. /// internal static string CheckServerSettings { get { @@ -88,7 +88,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 configuration format is incorrect 的本地化字符串。 + /// Looks up a localized string similar to configuration format is incorrect. /// internal static string ConfigurationFormatIncorrect { get { @@ -97,7 +97,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 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. 的本地化字符串。 + /// Looks up a localized string similar to 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.. /// internal static string CustomServerTips { get { @@ -106,7 +106,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Whether to download? {0} 的本地化字符串。 + /// Looks up a localized string similar to Whether to download? {0}. /// internal static string DownloadYesNo { get { @@ -115,7 +115,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Failed to convert configuration file 的本地化字符串。 + /// Looks up a localized string similar to Failed to convert configuration file. /// internal static string FailedConversionConfiguration { get { @@ -124,7 +124,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Failed to generate default configuration file 的本地化字符串。 + /// Looks up a localized string similar to Failed to generate default configuration file. /// internal static string FailedGenDefaultConfiguration { get { @@ -133,7 +133,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Failed to get the default configuration 的本地化字符串。 + /// Looks up a localized string similar to Failed to get the default configuration. /// internal static string FailedGetDefaultConfiguration { get { @@ -142,7 +142,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Failed to import custom configuration server 的本地化字符串。 + /// Looks up a localized string similar to Failed to import custom configuration server. /// internal static string FailedImportedCustomServer { get { @@ -151,7 +151,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Failed to read configuration file 的本地化字符串。 + /// Looks up a localized string similar to Failed to read configuration file. /// internal static string FailedReadConfiguration { get { @@ -160,7 +160,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Please fill in the correct format extra ID 的本地化字符串。 + /// Looks up a localized string similar to Please fill in the correct format extra ID. /// internal static string FillCorrectAlterId { get { @@ -169,7 +169,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Please fill in the correct format server port 的本地化字符串。 + /// Looks up a localized string similar to Please fill in the correct format server port. /// internal static string FillCorrectServerPort { get { @@ -178,7 +178,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Please fill in the KCP parameters correctly 的本地化字符串。 + /// Looks up a localized string similar to Please fill in the KCP parameters correctly. /// internal static string FillKcpParameters { get { @@ -187,7 +187,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Please fill in the local listening port 的本地化字符串。 + /// Looks up a localized string similar to Please fill in the local listening port. /// internal static string FillLocalListeningPort { get { @@ -196,7 +196,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Please fill in the password 的本地化字符串。 + /// Looks up a localized string similar to Please fill in the password. /// internal static string FillPassword { get { @@ -205,7 +205,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Please fill in the server address 的本地化字符串。 + /// Looks up a localized string similar to Please fill in the server address. /// internal static string FillServerAddress { get { @@ -214,7 +214,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Please fill in the user ID 的本地化字符串。 + /// Looks up a localized string similar to Please fill in the user ID. /// internal static string FillUUID { get { @@ -223,7 +223,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 is not the correct client configuration file, please check 的本地化字符串。 + /// Looks up a localized string similar to is not the correct client configuration file, please check. /// internal static string IncorrectClientConfiguration { get { @@ -232,7 +232,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 is not the correct configuration, please check 的本地化字符串。 + /// Looks up a localized string similar to is not the correct configuration, please check. /// internal static string Incorrectconfiguration { get { @@ -241,7 +241,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 is not the correct server configuration file, please check 的本地化字符串。 + /// Looks up a localized string similar to is not the correct server configuration file, please check. /// internal static string IncorrectServerConfiguration { get { @@ -250,7 +250,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Initial Configuration 的本地化字符串。 + /// Looks up a localized string similar to Initial Configuration. /// internal static string InitialConfiguration { get { @@ -259,7 +259,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Address 的本地化字符串。 + /// Looks up a localized string similar to Address. /// internal static string LvAddress { get { @@ -268,7 +268,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Alias 的本地化字符串。 + /// Looks up a localized string similar to Alias. /// internal static string LvAlias { get { @@ -277,7 +277,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Security 的本地化字符串。 + /// Looks up a localized string similar to Security. /// internal static string LvEncryptionMethod { get { @@ -286,7 +286,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Port 的本地化字符串。 + /// Looks up a localized string similar to Port. /// internal static string LvPort { get { @@ -295,7 +295,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Type 的本地化字符串。 + /// Looks up a localized string similar to Type. /// internal static string LvServiceType { get { @@ -304,7 +304,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Subs 的本地化字符串。 + /// Looks up a localized string similar to Subs. /// internal static string LvSubscription { get { @@ -313,7 +313,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Test Results 的本地化字符串。 + /// Looks up a localized string similar to Test Results. /// internal static string LvTestResults { get { @@ -322,7 +322,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Transport 的本地化字符串。 + /// Looks up a localized string similar to Transport. /// internal static string LvTransportProtocol { get { @@ -331,7 +331,16 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Clear original subscription content 的本地化字符串。 + /// Looks up a localized string similar to MediumFresh. + /// + internal static string MediumFresh { + get { + return ResourceManager.GetString("MediumFresh", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Clear original subscription content. /// internal static string MsgClearSubscription { get { @@ -340,7 +349,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Download V2rayCore successfully 的本地化字符串。 + /// Looks up a localized string similar to Download V2rayCore successfully. /// internal static string MsgDownloadV2rayCoreSuccessfully { get { @@ -349,7 +358,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Failed to import subscription content 的本地化字符串。 + /// Looks up a localized string similar to Failed to import subscription content. /// internal static string MsgFailedImportSubscription { get { @@ -358,7 +367,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Get the subscription content successfully 的本地化字符串。 + /// Looks up a localized string similar to Get the subscription content successfully. /// internal static string MsgGetSubscriptionSuccessfully { get { @@ -367,7 +376,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 No valid subscriptions set 的本地化字符串。 + /// Looks up a localized string similar to No valid subscriptions set. /// internal static string MsgNoValidSubscription { get { @@ -376,7 +385,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 PAC update failed 的本地化字符串。 + /// Looks up a localized string similar to PAC update failed. /// internal static string MsgPACUpdateFailed { get { @@ -385,7 +394,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 PAC update succeeded 的本地化字符串。 + /// Looks up a localized string similar to PAC update succeeded. /// internal static string MsgPACUpdateSuccessfully { get { @@ -394,7 +403,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Resolve V2rayCore successfully 的本地化字符串。 + /// Looks up a localized string similar to Resolve V2rayCore successfully. /// internal static string MsgParsingV2rayCoreSuccessfully { get { @@ -403,7 +412,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Simplify PAC Success 的本地化字符串。 + /// Looks up a localized string similar to Simplify PAC Success. /// internal static string MsgSimplifyPAC { get { @@ -412,7 +421,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Start getting subscriptions 的本地化字符串。 + /// Looks up a localized string similar to Start getting subscriptions. /// internal static string MsgStartGettingSubscriptions { get { @@ -421,7 +430,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Start updating PAC... 的本地化字符串。 + /// Looks up a localized string similar to Start updating PAC.... /// internal static string MsgStartUpdatingPAC { get { @@ -430,7 +439,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Start updating V2rayCore... 的本地化字符串。 + /// Looks up a localized string similar to Start updating V2rayCore.... /// internal static string MsgStartUpdatingV2rayCore { get { @@ -439,7 +448,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Subscription content decoding failed (non-BASE64 code) 的本地化字符串。 + /// Looks up a localized string similar to Subscription content decoding failed (non-BASE64 code). /// internal static string MsgSubscriptionDecodingFailed { get { @@ -448,7 +457,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 is unpacking... 的本地化字符串。 + /// Looks up a localized string similar to is unpacking.... /// internal static string MsgUnpacking { get { @@ -457,7 +466,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Update subscription end 的本地化字符串。 + /// Looks up a localized string similar to Update subscription end. /// internal static string MsgUpdateSubscriptionEnd { get { @@ -466,7 +475,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Update subscription starts 的本地化字符串。 + /// Looks up a localized string similar to Update subscription starts. /// internal static string MsgUpdateSubscriptionStart { get { @@ -475,7 +484,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Update V2rayCore successfully 的本地化字符串。 + /// Looks up a localized string similar to Update V2rayCore successfully. /// internal static string MsgUpdateV2rayCoreSuccessfully { get { @@ -484,7 +493,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Update V2rayCore successfully! Restarting service... 的本地化字符串。 + /// Looks up a localized string similar to Update V2rayCore successfully! Restarting service.... /// internal static string MsgUpdateV2rayCoreSuccessfullyMore { get { @@ -493,7 +502,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 This feature relies on the Http global proxy, please set it correctly first. 的本地化字符串。 + /// Looks up a localized string similar to This feature relies on the Http global proxy, please set it correctly first.. /// internal static string NeedHttpGlobalProxy { get { @@ -502,7 +511,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Non-vmess or ss protocol 的本地化字符串。 + /// Looks up a localized string similar to Non-vmess or ss protocol. /// internal static string NonvmessOrssProtocol { get { @@ -511,7 +520,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 non-Vmess service, this feature is invalid 的本地化字符串。 + /// Looks up a localized string similar to non-Vmess service, this feature is invalid. /// internal static string NonVmessService { get { @@ -520,7 +529,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 V2ray-core not found, download address: {0} 的本地化字符串。 + /// Looks up a localized string similar to V2ray-core not found, download address: {0}. /// internal static string NotFoundCore { get { @@ -529,7 +538,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Scan completed, no valid QR code found 的本地化字符串。 + /// Looks up a localized string similar to Scan completed, no valid QR code found. /// internal static string NoValidQRcodeFound { get { @@ -538,7 +547,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 operation failed, please check retry 的本地化字符串。 + /// Looks up a localized string similar to operation failed, please check retry. /// internal static string OperationFailed { get { @@ -547,7 +556,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Please Fill Remarks 的本地化字符串。 + /// Looks up a localized string similar to Please Fill Remarks. /// internal static string PleaseFillRemarks { get { @@ -556,7 +565,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Please select the encryption method 的本地化字符串。 + /// Looks up a localized string similar to Please select the encryption method. /// internal static string PleaseSelectEncryption { get { @@ -565,7 +574,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Please select an agreement 的本地化字符串。 + /// Looks up a localized string similar to Please select an agreement. /// internal static string PleaseSelectProtocol { get { @@ -574,7 +583,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Please select the server first 的本地化字符串。 + /// Looks up a localized string similar to Please select the server first. /// internal static string PleaseSelectServer { get { @@ -583,7 +592,16 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Are you sure to remove the server? 的本地化字符串。 + /// Looks up a localized string similar to QuickFresh. + /// + internal static string QuickFresh { + get { + return ResourceManager.GetString("QuickFresh", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Are you sure to remove the server?. /// internal static string RemoveServer { get { @@ -592,7 +610,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 The client configuration file is saved at: {0} 的本地化字符串。 + /// Looks up a localized string similar to The client configuration file is saved at: {0}. /// internal static string SaveClientConfigurationIn { get { @@ -601,7 +619,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 The server configuration file is saved at: {0} 的本地化字符串。 + /// Looks up a localized string similar to The server configuration file is saved at: {0}. /// internal static string SaveServerConfigurationIn { get { @@ -610,7 +628,16 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Note: After this function relies on the Http global proxy test, please manually adjust the Http global proxy and active node! 的本地化字符串。 + /// Looks up a localized string similar to SlowFresh. + /// + internal static string SlowFresh { + get { + return ResourceManager.GetString("SlowFresh", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Note: After this function relies on the Http global proxy test, please manually adjust the Http global proxy and active node!. /// internal static string SpeedServerTips { get { @@ -619,7 +646,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Start service ({0})...... 的本地化字符串。 + /// Looks up a localized string similar to Start service ({0})....... /// internal static string StartService { get { @@ -628,8 +655,8 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Successful configuration - ///{0} 的本地化字符串。 + /// Looks up a localized string similar to Successful configuration + ///{0}. /// internal static string SuccessfulConfiguration { get { @@ -638,7 +665,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Successfully imported custom configuration server 的本地化字符串。 + /// Looks up a localized string similar to Successfully imported custom configuration server. /// internal static string SuccessfullyImportedCustomServer { get { @@ -647,7 +674,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Imported bulk URL from clipboard successfully 的本地化字符串。 + /// Looks up a localized string similar to Imported bulk URL from clipboard successfully. /// internal static string SuccessfullyImportedServerViaClipboard { get { @@ -656,7 +683,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Scan import URL successfully 的本地化字符串。 + /// Looks up a localized string similar to Scan import URL successfully. /// internal static string SuccessfullyImportedServerViaScan { get { diff --git a/v2rayN/v2rayN/Resx/ResUI.resx b/v2rayN/v2rayN/Resx/ResUI.resx index b46bc376..c49770ca 100644 --- a/v2rayN/v2rayN/Resx/ResUI.resx +++ b/v2rayN/v2rayN/Resx/ResUI.resx @@ -319,4 +319,13 @@ Update V2rayCore successfully! Restarting service... + + MediumFresh + + + QuickFresh + + + SlowFresh + \ 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 147c247a..27a7cd9e 100644 --- a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx @@ -319,4 +319,13 @@ 更新V2rayCore成功!正在重启服务... + + 中等 + + + + + + + \ No newline at end of file diff --git a/v2rayN/v2rayN/Sample/SampleClientConfig.txt b/v2rayN/v2rayN/Sample/SampleClientConfig.txt index b134fb9d..e038f083 100644 --- a/v2rayN/v2rayN/Sample/SampleClientConfig.txt +++ b/v2rayN/v2rayN/Sample/SampleClientConfig.txt @@ -1,25 +1,55 @@ { + "stats": {}, + "api": { + "tag": "api", + "services": [ + "StatsService" + ] + }, + "policy": { + "system": { + "statsInboundUplink": true, + "statsInboundDownlink": true + } + }, + "log": { + "access": "", + "error": "", + "loglevel": "error" + }, "log": { "access": "Vaccess.log", "error": "Verror.log", "loglevel": "warning" }, - "inbounds": [{ - "port": 10808, - "protocol": "socks", - "listen": "127.0.0.1", - "settings": { - "auth": "noauth", - "udp": true + "inbounds": [ + { + "tag": "proxy", + "port": 10808, + "protocol": "socks", + "listen": "127.0.0.1", + "settings": { + "auth": "noauth", + "udp": true + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } }, - "sniffing": { - "enabled": true, - "destOverride": [ - "http", - "tls" - ] - } - }], + { + "listen": "127.0.0.1", + "port": 10085, + "protocol": "dokodemo-door", + "settings": { + "address": "127.0.0.1" + }, + "tag": "api" + } + ], "outbounds": [{ "tag": "proxy", "protocol": "vmess", @@ -66,6 +96,12 @@ ], "routing": { "domainStrategy": "IPIfNonMatch", - "rules": [] + "rules": [ + { + "inboundTag": "api", + "outboundTag": "api", + "type": "field" + } + ] } } \ No newline at end of file diff --git a/v2rayN/v2rayN/v2rayN.csproj b/v2rayN/v2rayN/v2rayN.csproj index a27c4be7..1af85bc3 100644 --- a/v2rayN/v2rayN/v2rayN.csproj +++ b/v2rayN/v2rayN/v2rayN.csproj @@ -142,6 +142,7 @@ SubSettingControl.cs + @@ -290,6 +291,7 @@ Designer + SettingsSingleFileGenerator Settings.Designer.cs From 56bb63a012ec7f7d46f3940b8fe4241eb8cda0ad Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Sun, 25 Aug 2019 09:33:38 +0800 Subject: [PATCH 4/8] add Statistics(netspeed, traffic data amount) --- v2rayN/v2rayN/Forms/MainForm.Designer.cs | 4 +- v2rayN/v2rayN/Forms/MainForm.cs | 151 +++++++++++- v2rayN/v2rayN/Forms/MainForm.resx | 28 +-- v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx | 3 + .../Forms/OptionSettingForm.Designer.cs | 26 +-- v2rayN/v2rayN/Forms/OptionSettingForm.cs | 21 +- v2rayN/v2rayN/Forms/OptionSettingForm.resx | 6 +- .../Forms/OptionSettingForm.zh-Hans.resx | 5 +- v2rayN/v2rayN/Global.cs | 8 +- v2rayN/v2rayN/Handler/StatisticsHandler.cs | 217 +++++++++++++++++- v2rayN/v2rayN/Mode/ServerStatistics.cs | 31 +++ v2rayN/v2rayN/Resx/ResUI.Designer.cs | 54 +++++ v2rayN/v2rayN/Resx/ResUI.resx | 18 ++ v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx | 18 ++ v2rayN/v2rayN/Tool/Utils.cs | 49 ++++ v2rayN/v2rayN/v2rayN.csproj | 1 + 16 files changed, 583 insertions(+), 57 deletions(-) create mode 100644 v2rayN/v2rayN/Mode/ServerStatistics.cs diff --git a/v2rayN/v2rayN/Forms/MainForm.Designer.cs b/v2rayN/v2rayN/Forms/MainForm.Designer.cs index a48ab929..4f4fe2e9 100644 --- a/v2rayN/v2rayN/Forms/MainForm.Designer.cs +++ b/v2rayN/v2rayN/Forms/MainForm.Designer.cs @@ -31,7 +31,7 @@ this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.lvServers = new System.Windows.Forms.ListView(); + this.lvServers = new v2rayN.Forms.MainForm.ListViewFlickerFree(); this.cmsLv = new System.Windows.Forms.ContextMenuStrip(this.components); this.menuAddVmessServer = new System.Windows.Forms.ToolStripMenuItem(); this.menuAddShadowsocksServer = new System.Windows.Forms.ToolStripMenuItem(); @@ -766,7 +766,7 @@ private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.TextBox txtMsgBox; - private System.Windows.Forms.ListView lvServers; + private v2rayN.Forms.MainForm.ListViewFlickerFree lvServers; private System.Windows.Forms.NotifyIcon notifyMain; private System.Windows.Forms.ContextMenuStrip cmsMain; private System.Windows.Forms.ToolStripMenuItem menuExit; diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index a4a7d2e5..356178e3 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -20,6 +20,17 @@ namespace v2rayN.Forms private StatisticsHandler statistics; + class ListViewFlickerFree: ListView + { + public ListViewFlickerFree() + { + SetStyle(ControlStyles.OptimizedDoubleBuffer + | ControlStyles.AllPaintingInWmPaint + , true); + UpdateStyles(); + } + } + #region Window 事件 public MainForm() @@ -42,15 +53,73 @@ namespace v2rayN.Forms v2rayHandler = new V2rayHandler(); v2rayHandler.ProcessEvent += v2rayHandler_ProcessEvent; statistics = new StatisticsHandler(config, - (ulong totalUp, ulong totalDown, ulong up, ulong down) => + (ulong totalUp, ulong totalDown, ulong up, ulong down, List statistics) => { - toolSslBlank4.Text = down.ToString(); + double up_amount = 0.0, down_amount; + string up_unit = "", down_unit; + Utils.ToHumanReadable(up, out up_amount, out up_unit); + Utils.ToHumanReadable(down, out down_amount, out down_unit); + up_unit += "/s"; + down_unit += "/s"; + + up_amount /= config.statisticsFreshRate / 1000f; + down_amount /= config.statisticsFreshRate / 1000f; + + toolSslBlank4.Text = string.Format( + "{4}: {0:f2} {1} | {5}: {2:f2} {3}", + up_amount, + up_unit, + down_amount, + down_unit, + UIRes.I18N("uploadSpeed"), + UIRes.I18N("downloadSpeed") + ); + + + List datas = new List(); + for (int i= 0; i < config.vmess.Count; i++) + { + string totalUp_ = string.Empty, + totalDown_ = string.Empty, + todayUp_ = string.Empty, + todayDown_ = string.Empty; + var index = statistics.FindIndex(item_ => (config.vmess[i].address == item_.address && config.vmess[i].port == item_.port)); + if (index != -1) + { + Func human_fy = (amount) => + { + double result; + string unit; + Utils.ToHumanReadable(amount, out result, out unit); + return $"{string.Format("{0:f2}", result)}{unit}"; + }; + totalUp_ = human_fy(statistics[index].totalUp); + totalDown_ = human_fy(statistics[index].totalDown); + todayUp_ = human_fy(statistics[index].todayUp); + todayDown_ = human_fy(statistics[index].todayDown); + } + + datas.Add(new string[] { totalUp_, totalDown_, todayUp_, todayDown_ }); + } + + lvServers.Invoke((MethodInvoker)delegate + { + lvServers.SuspendLayout(); + for (int i =0; i< datas.Count; i++) + { + lvServers.Items[i].SubItems[7].Text = datas[i][0]; + lvServers.Items[i].SubItems[8].Text = datas[i][1]; + lvServers.Items[i].SubItems[9].Text = datas[i][2]; + lvServers.Items[i].SubItems[10].Text = datas[i][3]; + } + lvServers.ResumeLayout(); + }); }); } private void MainForm_VisibleChanged(object sender, EventArgs e) { - if (statistics == null) return; + if (statistics == null || !statistics.Enable) return; if((sender as Form).Visible) { statistics.UpdateUI = true; @@ -78,9 +147,15 @@ namespace v2rayN.Forms { e.Cancel = true; + statistics.saveToFile(); + HideForm(); return; } + if(e.CloseReason == CloseReason.ApplicationExitCall) + { + statistics.saveToFile(); + } } private void MainForm_Resize(object sender, EventArgs e) @@ -109,7 +184,8 @@ namespace v2rayN.Forms Utils.SaveLog("Windows shutdown UnsetProxy"); //CloseV2ray(); ConfigHandler.ToJsonFile(config); - statistics.saveToFile(); + if(statistics!=null && statistics.Enable) + statistics.saveToFile(); ProxySetting.UnsetProxy(); m.Result = (IntPtr)1; break; @@ -152,6 +228,16 @@ namespace v2rayN.Forms lvServers.Columns.Add(UIRes.I18N("LvPort"), 50, HorizontalAlignment.Left); lvServers.Columns.Add(UIRes.I18N("LvEncryptionMethod"), 90, HorizontalAlignment.Left); lvServers.Columns.Add(UIRes.I18N("LvTransportProtocol"), 70, HorizontalAlignment.Left); + + 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); + this.Width = 1250; + } + lvServers.Columns.Add(UIRes.I18N("LvSubscription"), 50, HorizontalAlignment.Left); lvServers.Columns.Add(UIRes.I18N("LvTestResults"), 100, HorizontalAlignment.Left); @@ -167,14 +253,38 @@ namespace v2rayN.Forms for (int k = 0; k < config.vmess.Count; k++) { string def = string.Empty; + string totalUp = string.Empty, + totalDown = string.Empty, + todayUp = string.Empty, + todayDown = string.Empty; if (config.index.Equals(k)) { def = "√"; } VmessItem item = config.vmess[k]; - ListViewItem lvItem = new ListViewItem(new string[] + + ListViewItem lvItem = null; + if (statistics != null && statistics.Enable) { + var index = statistics.Statistic.FindIndex(item_ => item_.address == item.address); + if (index != -1) + { + Func human_fy = (amount) => + { + double result; + string unit; + Utils.ToHumanReadable(amount, out result, out unit); + return $"{string.Format("{0:f2}", result)}{unit}"; + }; + totalUp = human_fy(statistics.Statistic[index].totalUp); + totalDown = human_fy(statistics.Statistic[index].totalDown); + todayUp = human_fy(statistics.Statistic[index].todayUp); + todayDown = human_fy(statistics.Statistic[index].todayDown); + } + + lvItem = new ListViewItem(new string[] + { def, ((EConfigType)item.configType).ToString(), item.remarks, @@ -184,10 +294,37 @@ namespace v2rayN.Forms //item.alterId.ToString(), item.security, item.network, + totalUp, + totalDown, + todayUp, + todayDown, item.getSubRemarks(config), item.testResult - }); - lvServers.Items.Add(lvItem); + }); + } + else + { + lvItem = new ListViewItem(new string[] + { + def, + ((EConfigType)item.configType).ToString(), + item.remarks, + item.address, + item.port.ToString(), + //item.id, + //item.alterId.ToString(), + item.security, + item.network, + //totalUp, + //totalDown, + //todayUp, + //todayDown, + item.getSubRemarks(config), + item.testResult + }); + } + + if(lvItem!=null) lvServers.Items.Add(lvItem); } //if (lvServers.Items.Count > 0) diff --git a/v2rayN/v2rayN/Forms/MainForm.resx b/v2rayN/v2rayN/Forms/MainForm.resx index 1c8fbd92..89a06c02 100644 --- a/v2rayN/v2rayN/Forms/MainForm.resx +++ b/v2rayN/v2rayN/Forms/MainForm.resx @@ -305,7 +305,7 @@ 0, 0 - 726, 331 + 638, 331 @@ -315,7 +315,7 @@ lvServers - System.Windows.Forms.ListView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + v2rayN.Forms.MainForm+ListViewFlickerFree, v2rayN, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null splitContainer1.Panel1 @@ -375,10 +375,10 @@ 100 - 986, 331 + 898, 331 - 726 + 638 2 @@ -501,7 +501,7 @@ 0, 66 - 992, 351 + 904, 351 2 @@ -537,7 +537,7 @@ Vertical - 986, 134 + 898, 134 2 @@ -567,7 +567,7 @@ 0, 17 - 257, 17 + 227, 17 38, 17 @@ -579,7 +579,7 @@ 0, 17 - 257, 17 + 227, 17 31, 17 @@ -591,7 +591,7 @@ 0, 17 - 257, 17 + 227, 17 45, 17 @@ -609,7 +609,7 @@ 3, 151 - 986, 22 + 898, 22 7 @@ -636,7 +636,7 @@ 0, 417 - 992, 176 + 904, 176 4 @@ -663,7 +663,7 @@ 0, 56 - 992, 10 + 904, 10 5 @@ -867,7 +867,7 @@ 0, 0 - 992, 56 + 904, 56 6 @@ -894,7 +894,7 @@ 6, 12 - 992, 593 + 904, 593 4, 4, 4, 4 diff --git a/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx b/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx index e25e9c82..ea88b1d6 100644 --- a/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx +++ b/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx @@ -450,4 +450,7 @@ 关闭 + + 代理速度 + \ No newline at end of file diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs b/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs index f642333e..4caf3e40 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs @@ -83,7 +83,9 @@ this.txtKcpmtu = new System.Windows.Forms.TextBox(); this.label6 = new System.Windows.Forms.Label(); this.tabPage7 = new System.Windows.Forms.TabPage(); + this.cbFreshrate = new System.Windows.Forms.ComboBox(); this.tbCacheDays = new System.Windows.Forms.TextBox(); + this.lbFreshrate = new System.Windows.Forms.Label(); this.lbCacheDays = new System.Windows.Forms.Label(); this.chkEnableStatistics = new System.Windows.Forms.CheckBox(); this.chkAllowLANConn = new System.Windows.Forms.CheckBox(); @@ -93,8 +95,6 @@ this.panel2 = new System.Windows.Forms.Panel(); this.btnOK = new System.Windows.Forms.Button(); this.panel1 = new System.Windows.Forms.Panel(); - this.cbFreshrate = new System.Windows.Forms.ComboBox(); - this.lbFreshrate = new System.Windows.Forms.Label(); this.configBindingSource = new System.Windows.Forms.BindingSource(this.components); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); @@ -494,11 +494,22 @@ this.tabPage7.Name = "tabPage7"; this.tabPage7.UseVisualStyleBackColor = true; // + // cbFreshrate + // + this.cbFreshrate.FormattingEnabled = true; + resources.ApplyResources(this.cbFreshrate, "cbFreshrate"); + this.cbFreshrate.Name = "cbFreshrate"; + // // tbCacheDays // resources.ApplyResources(this.tbCacheDays, "tbCacheDays"); this.tbCacheDays.Name = "tbCacheDays"; // + // lbFreshrate + // + resources.ApplyResources(this.lbFreshrate, "lbFreshrate"); + this.lbFreshrate.Name = "lbFreshrate"; + // // lbCacheDays // resources.ApplyResources(this.lbCacheDays, "lbCacheDays"); @@ -551,17 +562,6 @@ resources.ApplyResources(this.panel1, "panel1"); this.panel1.Name = "panel1"; // - // cbFreshrate - // - this.cbFreshrate.FormattingEnabled = true; - resources.ApplyResources(this.cbFreshrate, "cbFreshrate"); - this.cbFreshrate.Name = "cbFreshrate"; - // - // lbFreshrate - // - resources.ApplyResources(this.lbFreshrate, "lbFreshrate"); - this.lbFreshrate.Name = "lbFreshrate"; - // // configBindingSource // this.configBindingSource.DataSource = typeof(v2rayN.Mode.Config); diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.cs b/v2rayN/v2rayN/Forms/OptionSettingForm.cs index f64f9271..b692f928 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.cs +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.cs @@ -114,16 +114,31 @@ namespace v2rayN.Forms tbCacheDays.Text = config.CacheDays.ToString(); - - cbFreshrate.DataSource = new ComboItem[] + var cbSource = new ComboItem[] { new ComboItem{ID = (int)Global.StatisticsFreshRate.quick, Text = UIRes.I18N("QuickFresh")}, new ComboItem{ID = (int)Global.StatisticsFreshRate.medium, Text = UIRes.I18N("MediumFresh")}, new ComboItem{ID = (int)Global.StatisticsFreshRate.slow, Text = UIRes.I18N("SlowFresh")}, }; + cbFreshrate.DataSource = cbSource; cbFreshrate.DisplayMember = "Text"; cbFreshrate.ValueMember = "ID"; + + switch(config.statisticsFreshRate) + { + case (int)Global.StatisticsFreshRate.quick: + cbFreshrate.SelectedItem = cbSource[0]; + break; + case (int)Global.StatisticsFreshRate.medium: + cbFreshrate.SelectedItem = cbSource[1]; + break; + case (int)Global.StatisticsFreshRate.slow: + cbFreshrate.SelectedItem = cbSource[2]; + break; + } + + cbFreshrate.Enabled = enableStatistics; } private void btnOK_Click(object sender, EventArgs e) @@ -319,6 +334,8 @@ namespace v2rayN.Forms days = 7; config.CacheDays = days; + config.statisticsFreshRate = (int)cbFreshrate.SelectedValue; + return 0; } diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.resx b/v2rayN/v2rayN/Forms/OptionSettingForm.resx index 16622a9b..7e395cbd 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.resx +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.resx @@ -1486,7 +1486,7 @@ 161, 82 - 121, 20 + 58, 20 32 @@ -1591,13 +1591,13 @@ 15, 60 - 390, 16 + 558, 16 29 - Enable Statistics(Realtime net speed and traffic data amount) + Enable Statistics(Realtime net speed and traffic data amount. Need restart v2rayN client) chkEnableStatistics diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx b/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx index 1f11bc0f..cef4cd5a 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx @@ -288,11 +288,8 @@ 参数设置 - - 启用快捷键(Ctrl+P ping 选中服务器/ Ctrl+T 测速选中服务器) - - 启用统计(实时网速显示和使用流量显示) + 启用统计(实时网速显示和使用流量显示,需要重启v2rayN客户端) 缓存天数(0-30, 0关闭缓存单独每天的数据使用情况) diff --git a/v2rayN/v2rayN/Global.cs b/v2rayN/v2rayN/Global.cs index b854be90..f3a77f79 100644 --- a/v2rayN/v2rayN/Global.cs +++ b/v2rayN/v2rayN/Global.cs @@ -149,10 +149,12 @@ namespace v2rayN public const uint InboundAPIPort = 10085; public enum StatisticsFreshRate { - quick = 1000, - medium = 2000, - slow = 3000 + quick = 500, + medium = 1000, + slow = 2000 } + public const string StatisticLogDirectory = "Statistics"; + public const string StatisticLogOverall = "overall.txt"; #endregion diff --git a/v2rayN/v2rayN/Handler/StatisticsHandler.cs b/v2rayN/v2rayN/Handler/StatisticsHandler.cs index 2ab1d687..9813c8ef 100644 --- a/v2rayN/v2rayN/Handler/StatisticsHandler.cs +++ b/v2rayN/v2rayN/Handler/StatisticsHandler.cs @@ -22,7 +22,7 @@ namespace v2rayN.Handler private Thread workThread_; - Action updateFunc_; + Action> updateFunc_; private bool enabled_; public bool Enable @@ -35,20 +35,35 @@ namespace v2rayN.Handler private StringBuilder outputBuilder_; - public UInt64 TotalUp { get; private set; } + public ulong TotalUp { get; private set; } - public UInt64 TotalDown { get; private set; } + public ulong TotalDown { get; private set; } - public UInt64 Up { get; private set; } + public List Statistic{ get; set; } - public UInt64 Down { get; private set; } + public ulong Up { get; private set; } - public StatisticsHandler(Config config, Action update) + public ulong Down { get; private set; } + + private string logPath_; + + public StatisticsHandler(Config config, Action> update) { config_ = config; enabled_ = config.enableStatistics; UpdateUI = false; updateFunc_ = update; + logPath_ = Utils.GetPath($"{Global.StatisticLogDirectory}\\"); + Statistic = new List(); + + DeleteExpiredLog(); + foreach (var server in config.vmess) + { + var statistic = new ServerStatistics(server.remarks, server.address, server.port, 0, 0, 0, 0); + Statistic.Add(statistic); + } + + loadFromFile(); outputBuilder_ = new StringBuilder(); @@ -83,6 +98,9 @@ namespace v2rayN.Handler { if (enabled_) { + var addr = config_.address(); + var port = config_.port(); + var cur = Statistic.FindIndex(item => item.address == addr && item.port == port); connector_.Start(); string output = connector_.StandardOutput.ReadToEnd(); UInt64 up = 0; @@ -97,14 +115,21 @@ namespace v2rayN.Handler TotalUp += up; TotalDown += down; + if(cur != -1) + { + Statistic[cur].todayUp += up; + Statistic[cur].todayDown += down; + Statistic[cur].totalUp += up; + Statistic[cur].totalDown += down; + } + if (UpdateUI) - updateFunc_(TotalUp, TotalDown, Up, Down); + updateFunc_(TotalUp, TotalDown, Up, Down, Statistic); Thread.Sleep(config_.statisticsFreshRate); } } } - catch (Exception e) - { } + catch { } } public void parseOutput(string source, out UInt64 up, out UInt64 down) @@ -148,12 +173,186 @@ namespace v2rayN.Handler public void saveToFile() { + if(!Directory.Exists(logPath_)) + { + Directory.CreateDirectory(logPath_); + } + // 总流量统计文件 + var overallPath = Path.Combine(logPath_, Global.StatisticLogOverall); + if (!File.Exists(overallPath)) + { + File.Create(overallPath); + } + try + { + using (var overallWriter = new StreamWriter(overallPath)) + { + double up_amount, down_amount; + string up_unit, down_unit; + + Utils.ToHumanReadable(TotalUp, out up_amount, out up_unit); + Utils.ToHumanReadable(TotalDown, out down_amount, out down_unit); + + overallWriter.WriteLine($"LastUpdate {DateTime.Now.ToLongDateString()} {DateTime.Now.ToLongTimeString()}"); + overallWriter.WriteLine($"UP {string.Format("{0:f2}", up_amount)}{up_unit} {TotalUp}"); + overallWriter.WriteLine($"DOWN {string.Format("{0:f2}", down_amount)}{down_unit} {TotalDown}"); + foreach(var s in Statistic) + { + overallWriter.WriteLine($"* {s.name} {s.address} {s.port} {s.totalUp} {s.totalDown}"); + } + } + } + catch { } + + // 当天流量记录文件 + var dailyPath = Path.Combine(logPath_, $"{DateTime.Now.ToLongDateString()}.txt"); + if (!File.Exists(dailyPath)) + { + File.Create(dailyPath); + } + try + { + using (var dailyWriter = new StreamWriter(dailyPath)) + { + dailyWriter.WriteLine($"LastUpdate {DateTime.Now.ToLongDateString()} {DateTime.Now.ToLongTimeString()}"); + foreach (var s in Statistic) + { + dailyWriter.WriteLine($"* {s.name} {s.address} {s.port} {s.todayUp} {s.todayDown}"); + } + } + } + catch { } } public void loadFromFile() { + if (!Directory.Exists(logPath_)) return; + // 总流量统计文件 + /// + /// 文件结构 + /// LastUpdate [date] [time] + /// UP [readable string] [amount] + /// DOWN [readable string] [amount] + /// 每行每个数据空格分隔 + /// + var overallPath = Path.Combine(logPath_, Global.StatisticLogOverall); + if (File.Exists(overallPath)) + { + try + { + using (var overallReader = new StreamReader(overallPath)) + { + while (!overallReader.EndOfStream) + { + var line = overallReader.ReadLine(); + if (line.StartsWith("LastUpdate")) + { + + } + else if (line.StartsWith("UP")) + { + var datas = line.Split(' '); + if (datas.Length < 3) return; + TotalUp = ulong.Parse(datas[2]); + } + else if (line.StartsWith("DOWN")) + { + var datas = line.Split(' '); + if (datas.Length < 3) return; + TotalDown = ulong.Parse(datas[2]); + } + else if (line.StartsWith("*")) + { + var datas = line.Split(' '); + if (datas.Length < 6) return; + var name = datas[1]; + var address = datas[2]; + var port = int.Parse(datas[3]); + var totalUp = ulong.Parse(datas[4]); + var totalDown = ulong.Parse(datas[5]); + + var index = Statistic.FindIndex(item => item.address == address && item.port == port); + if (index != -1) + { + Statistic[index].totalUp = totalUp; + Statistic[index].totalDown = totalDown; + } + else + { + var s = new Mode.ServerStatistics(name, address, port, totalUp, totalDown, 0, 0); + Statistic.Add(s); + } + } + } + } + } + catch { } + } + + // 当天流量记录文件 + var dailyPath = Path.Combine(logPath_, $"{DateTime.Now.ToLongDateString()}.txt"); + if (File.Exists(dailyPath)) + { + try + { + using (var dailyReader = new StreamReader(dailyPath)) + { + while (!dailyReader.EndOfStream) + { + var line = dailyReader.ReadLine(); + if (line.StartsWith("LastUpdate")) + { + + } + else if (line.StartsWith("*")) + { + var datas = line.Split(' '); + if (datas.Length < 6) return; + var name = datas[1]; + var address = datas[2]; + var port = int.Parse(datas[3]); + var todayUp = ulong.Parse(datas[4]); + var todayDown = ulong.Parse(datas[5]); + + var index = Statistic.FindIndex(item => item.address == address && item.port == port); + if (index != -1) + { + Statistic[index].todayUp = todayUp; + Statistic[index].todayDown = todayDown; + } + else + { + var s = new Mode.ServerStatistics(name, address, port, 0, 0, todayUp, todayDown); + Statistic.Add(s); + } + } + } + } + } + catch { } + } + } + + + private void DeleteExpiredLog() + { + if (!Directory.Exists(logPath_)) return; + var dirInfo = new DirectoryInfo(logPath_); + var files = dirInfo.GetFiles(); + foreach (var file in files) + { + if (file.Name == "overall.txt") continue; + var name = file.Name.Split('.')[0]; + var ft = DateTime.Parse(name); + var ct = DateTime.Now; + var dur = ct - ft; + if(dur.Days > config_.CacheDays) + { + file.Delete(); + } + } } } } diff --git a/v2rayN/v2rayN/Mode/ServerStatistics.cs b/v2rayN/v2rayN/Mode/ServerStatistics.cs new file mode 100644 index 00000000..ac8ee61b --- /dev/null +++ b/v2rayN/v2rayN/Mode/ServerStatistics.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace v2rayN.Mode +{ + class ServerStatistics + { + public string name; + public string address; + public int port; + public ulong totalUp; + public ulong totalDown; + public ulong todayUp; + public ulong todayDown; + + public ServerStatistics() { } + public ServerStatistics(string name, string addr, int port, ulong totalUp, ulong totalDown, ulong todayUp, ulong todayDown) + { + this.name = name; + this.address = addr; + this.port = port; + this.totalUp = totalUp; + this.totalDown = totalDown; + this.todayUp = todayUp; + this.todayDown = todayDown; + } + } +} diff --git a/v2rayN/v2rayN/Resx/ResUI.Designer.cs b/v2rayN/v2rayN/Resx/ResUI.Designer.cs index 8b66bfc2..66383ce9 100644 --- a/v2rayN/v2rayN/Resx/ResUI.Designer.cs +++ b/v2rayN/v2rayN/Resx/ResUI.Designer.cs @@ -105,6 +105,15 @@ namespace v2rayN.Resx { } } + /// + /// Looks up a localized string similar to DOWN. + /// + internal static string downloadSpeed { + get { + return ResourceManager.GetString("downloadSpeed", resourceCulture); + } + } + /// /// Looks up a localized string similar to Whether to download? {0}. /// @@ -321,6 +330,42 @@ namespace v2rayN.Resx { } } + /// + /// Looks up a localized string similar to Today download traffic. + /// + internal static string LvTodayDownloadDataAmount { + get { + return ResourceManager.GetString("LvTodayDownloadDataAmount", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Today upload traffic. + /// + internal static string LvTodayUploadDataAmount { + get { + return ResourceManager.GetString("LvTodayUploadDataAmount", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Total download traffic. + /// + internal static string LvTotalDownloadDataAmount { + get { + return ResourceManager.GetString("LvTotalDownloadDataAmount", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Total upload traffic. + /// + internal static string LvTotalUploadDataAmount { + get { + return ResourceManager.GetString("LvTotalUploadDataAmount", resourceCulture); + } + } + /// /// Looks up a localized string similar to Transport. /// @@ -690,5 +735,14 @@ namespace v2rayN.Resx { return ResourceManager.GetString("SuccessfullyImportedServerViaScan", resourceCulture); } } + + /// + /// Looks up a localized string similar to UP. + /// + internal static string uploadSpeed { + get { + return ResourceManager.GetString("uploadSpeed", resourceCulture); + } + } } } diff --git a/v2rayN/v2rayN/Resx/ResUI.resx b/v2rayN/v2rayN/Resx/ResUI.resx index c49770ca..7f18977b 100644 --- a/v2rayN/v2rayN/Resx/ResUI.resx +++ b/v2rayN/v2rayN/Resx/ResUI.resx @@ -328,4 +328,22 @@ SlowFresh + + DOWN + + + Today download traffic + + + Today upload traffic + + + Total download traffic + + + Total upload traffic + + + UP + \ 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 27a7cd9e..9119c5d5 100644 --- a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx @@ -328,4 +328,22 @@ + + 下载 + + + 今日下载 + + + 今日上传 + + + 总下载 + + + 总上传 + + + 上传 + \ No newline at end of file diff --git a/v2rayN/v2rayN/Tool/Utils.cs b/v2rayN/v2rayN/Tool/Utils.cs index fb8e7a20..01037932 100644 --- a/v2rayN/v2rayN/Tool/Utils.cs +++ b/v2rayN/v2rayN/Tool/Utils.cs @@ -262,6 +262,55 @@ namespace v2rayN } } + /// + /// byte 转成 有两位小数点的 方便阅读的数据 + /// 比如 2.50 MB + /// + /// bytes + /// 转换之后的数据 + /// 单位 + public static void ToHumanReadable(ulong amount, out double result, out string unit) + { + var factor = 1024u; + var KBs = amount / factor; + if(amount / factor > 0) + { + // multi KB + var MBs = KBs / factor; + if(MBs > 0) + { + // multi MB + var GBs = MBs / factor; + if(GBs > 0) + { + // multi GB + var TBs = GBs / factor; + if(TBs > 0) + { + // 你是魔鬼吗? 用这么多流量 + result = TBs + GBs % factor / (factor + 0.0); + unit = "TB"; + return; + } + result = GBs + MBs % factor / (factor + 0.0); + unit = "GB"; + return; + } + result = MBs + KBs % factor / (factor + 0.0); + unit = "MB"; + return; + } + result = KBs + amount % factor / (factor + 0.0); + unit = "KB"; + return; + } + else + { + result = amount; + unit = "Byte"; + } + } + #endregion diff --git a/v2rayN/v2rayN/v2rayN.csproj b/v2rayN/v2rayN/v2rayN.csproj index 1af85bc3..141ced38 100644 --- a/v2rayN/v2rayN/v2rayN.csproj +++ b/v2rayN/v2rayN/v2rayN.csproj @@ -157,6 +157,7 @@ Component + From f036f12925849c0c398f480ede6d8e0021307817 Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Sun, 25 Aug 2019 10:07:51 +0800 Subject: [PATCH 5/8] Update Utils.cs --- v2rayN/v2rayN/Tool/Utils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2rayN/v2rayN/Tool/Utils.cs b/v2rayN/v2rayN/Tool/Utils.cs index 01037932..b623a3e5 100644 --- a/v2rayN/v2rayN/Tool/Utils.cs +++ b/v2rayN/v2rayN/Tool/Utils.cs @@ -273,7 +273,7 @@ namespace v2rayN { var factor = 1024u; var KBs = amount / factor; - if(amount / factor > 0) + if(KBs > 0) { // multi KB var MBs = KBs / factor; From 2861bff5a004bcd5eaa535f807e8f88a0fd80a3f Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Sun, 25 Aug 2019 22:43:28 +0800 Subject: [PATCH 6/8] Add one click deduplicate feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加一键删除重复服务器功能 --- v2rayN/v2rayN/Forms/MainForm.Designer.cs | 9 +++++++++ v2rayN/v2rayN/Forms/MainForm.cs | 17 ++++++++++++++++- v2rayN/v2rayN/Forms/MainForm.resx | 14 +++++++++++++- v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx | 3 +++ v2rayN/v2rayN/Tool/Utils.cs | 14 ++++++++++++++ 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/v2rayN/v2rayN/Forms/MainForm.Designer.cs b/v2rayN/v2rayN/Forms/MainForm.Designer.cs index 4f4fe2e9..70a84327 100644 --- a/v2rayN/v2rayN/Forms/MainForm.Designer.cs +++ b/v2rayN/v2rayN/Forms/MainForm.Designer.cs @@ -115,6 +115,7 @@ this.tsbPromotion = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator(); this.tsbClose = new System.Windows.Forms.ToolStripButton(); + this.menuRemoveDuplicateServer = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -172,6 +173,7 @@ this.menuScanScreen, this.toolStripSeparator1, this.menuRemoveServer, + this.menuRemoveDuplicateServer, this.menuCopyServer, this.menuSetDefaultServer, this.toolStripSeparator3, @@ -727,6 +729,12 @@ this.tsbClose.Name = "tsbClose"; this.tsbClose.Click += new System.EventHandler(this.tsbClose_Click); // + // menuRemoveDuplicateServer + // + this.menuRemoveDuplicateServer.Name = "menuRemoveDuplicateServer"; + resources.ApplyResources(this.menuRemoveDuplicateServer, "menuRemoveDuplicateServer"); + this.menuRemoveDuplicateServer.Click += new System.EventHandler(this.menuRemoveDuplicateServer_Click); + // // MainForm // resources.ApplyResources(this, "$this"); @@ -848,6 +856,7 @@ private System.Windows.Forms.ToolStripStatusLabel toolSslPacPortLab; private System.Windows.Forms.ToolStripStatusLabel toolSslServerSpeed; private System.Windows.Forms.ToolStripStatusLabel toolSslBlank4; + private System.Windows.Forms.ToolStripMenuItem menuRemoveDuplicateServer; } } diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index 356178e3..63bc559a 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -580,6 +580,22 @@ namespace v2rayN.Forms } + private void menuRemoveDuplicateServer_Click(object sender, EventArgs e) + { + List servers = null; + Utils.DedupServerList(config.vmess, out servers); + if (servers != null) + { + config.vmess = servers; + } + //刷新 + RefreshServers(); + LoadV2ray(); + + // save to config file + ConfigHandler.ToJsonFile(config); + } + private void menuCopyServer_Click(object sender, EventArgs e) { int index = GetLvSelectedIndex(); @@ -1565,6 +1581,5 @@ namespace v2rayN.Forms #endregion - } } diff --git a/v2rayN/v2rayN/Forms/MainForm.resx b/v2rayN/v2rayN/Forms/MainForm.resx index 89a06c02..45d6947e 100644 --- a/v2rayN/v2rayN/Forms/MainForm.resx +++ b/v2rayN/v2rayN/Forms/MainForm.resx @@ -173,6 +173,12 @@ Remove selected server (multiple choice) (Delete) + + 447, 22 + + + Remove duplicate server + 447, 22 @@ -273,7 +279,7 @@ ImageAboveText - 448, 468 + 448, 512 cmsLv @@ -1346,6 +1352,12 @@ System.Windows.Forms.ToolStripButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + menuRemoveDuplicateServer + + + 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 ea88b1d6..6e2ce7b5 100644 --- a/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx +++ b/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx @@ -453,4 +453,7 @@ 代理速度 + + 移除重复的服务器 + \ No newline at end of file diff --git a/v2rayN/v2rayN/Tool/Utils.cs b/v2rayN/v2rayN/Tool/Utils.cs index b623a3e5..57725c24 100644 --- a/v2rayN/v2rayN/Tool/Utils.cs +++ b/v2rayN/v2rayN/Tool/Utils.cs @@ -311,6 +311,20 @@ namespace v2rayN } } + public static void DedupServerList(List source, out List result) + { + var list = new List(); + foreach (var item in source) + { + if(!list.Exists(i => item.address == i.address && item.port == i.port)) + { + list.Add(item); + } + } + + result = list; + } + #endregion From fe015b0227c6db7c2cdf3f6e83599a586a40c5ef Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Sun, 25 Aug 2019 23:30:00 +0800 Subject: [PATCH 7/8] fix number may exceed 1024 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复网速可能超过1024的问题,比如1500 Byte 应该是 1.x KB --- v2rayN/v2rayN/Forms/MainForm.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index 63bc559a..6d3b3cbe 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -57,14 +57,15 @@ namespace v2rayN.Forms { double up_amount = 0.0, down_amount; string up_unit = "", down_unit; + + up /= (ulong)(config.statisticsFreshRate / 1000f); + down /= (ulong)(config.statisticsFreshRate / 1000f); + Utils.ToHumanReadable(up, out up_amount, out up_unit); Utils.ToHumanReadable(down, out down_amount, out down_unit); up_unit += "/s"; down_unit += "/s"; - up_amount /= config.statisticsFreshRate / 1000f; - down_amount /= config.statisticsFreshRate / 1000f; - toolSslBlank4.Text = string.Format( "{4}: {0:f2} {1} | {5}: {2:f2} {3}", up_amount, From 83e7ad936061d5d49636f6abc925cafc9577fbfc Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Mon, 26 Aug 2019 09:32:45 +0800 Subject: [PATCH 8/8] fix infinite loop thread hang there causes v2rayN hang in the background MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复死循环线程导致v2rayN在用户点击退出仍挂在后台 --- v2rayN/v2rayN/Forms/MainForm.cs | 3 +++ v2rayN/v2rayN/Handler/StatisticsHandler.cs | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index 6d3b3cbe..2a7975e1 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -1020,6 +1020,9 @@ namespace v2rayN.Forms this.Visible = false; this.Close(); + + statistics.Close(); + //this.Dispose(); //System.Environment.Exit(System.Environment.ExitCode); Application.Exit(); diff --git a/v2rayN/v2rayN/Handler/StatisticsHandler.cs b/v2rayN/v2rayN/Handler/StatisticsHandler.cs index 9813c8ef..242b045e 100644 --- a/v2rayN/v2rayN/Handler/StatisticsHandler.cs +++ b/v2rayN/v2rayN/Handler/StatisticsHandler.cs @@ -47,6 +47,8 @@ namespace v2rayN.Handler private string logPath_; + private bool exitFlag_; // true to close workThread_ + public StatisticsHandler(Config config, Action> update) { config_ = config; @@ -55,6 +57,7 @@ namespace v2rayN.Handler updateFunc_ = update; logPath_ = Utils.GetPath($"{Global.StatisticLogDirectory}\\"); Statistic = new List(); + exitFlag_ = false; DeleteExpiredLog(); foreach (var server in config.vmess) @@ -90,11 +93,17 @@ namespace v2rayN.Handler workThread_.Start(); } + public void Close() + { + exitFlag_ = true; + connector_.Kill(); + } + public void run() { try { - while (true) + while (!exitFlag_) { if (enabled_) {