From 3f1688f8b7f59998d2312ba0b3c4f004720cf6b5 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Mon, 25 Nov 2019 13:22:35 +0800 Subject: [PATCH] up stat --- v2rayN/v2rayN/Forms/MainForm.cs | 55 +- .../Forms/OptionSettingForm.Designer.cs | 62 +- v2rayN/v2rayN/Forms/OptionSettingForm.cs | 9 - v2rayN/v2rayN/Forms/OptionSettingForm.resx | 3352 ++++++++--------- v2rayN/v2rayN/Global.cs | 5 +- v2rayN/v2rayN/Handler/ConfigHandler.cs | 9 +- v2rayN/v2rayN/Handler/DownloadHandle.cs | 72 +- v2rayN/v2rayN/Handler/SpeedtestHandler.cs | 2 +- v2rayN/v2rayN/Handler/StatisticsHandler.cs | 377 +- v2rayN/v2rayN/Mode/Config.cs | 39 +- v2rayN/v2rayN/Mode/ServerStatistics.cs | 58 +- v2rayN/v2rayN/Properties/AssemblyInfo.cs | 2 +- v2rayN/v2rayN/Tool/Utils.cs | 9 - 13 files changed, 1902 insertions(+), 2149 deletions(-) diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index 7a74cb15..07571e52 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -197,7 +197,7 @@ namespace v2rayN.Forms ListViewItem lvItem = null; if (statistics != null && statistics.Enable) { - var index = statistics.Statistic.FindIndex(item_ => item_.address == item.address); + var index = statistics.Statistic.FindIndex(item_ => item_.itemId == item.getItemId()); if (index != -1) { totalUp = Utils.HumanFy(statistics.Statistic[index].totalUp); @@ -350,7 +350,7 @@ namespace v2rayN.Forms Utils.SetClipboardData(e.ClickedItem.Text); } } - + #endregion #region v2ray 操作 @@ -367,6 +367,7 @@ namespace v2rayN.Forms v2rayHandler.LoadV2ray(config); Global.reloadV2ray = false; ConfigHandler.SaveConfig(ref config, false); + statistics?.SaveToFile(); ChangePACButtonStatus(config.listenerType); } @@ -377,6 +378,7 @@ namespace v2rayN.Forms private void CloseV2ray() { ConfigHandler.SaveConfig(ref config, false); + statistics?.SaveToFile(); ChangePACButtonStatus(0); @@ -958,51 +960,34 @@ namespace v2rayN.Forms }); } - private void UpdateStatisticsHandler(ulong totalUp, ulong totalDown, ulong up, ulong down, List statistics) + private void UpdateStatisticsHandler(ulong up, ulong down, List statistics) { try { up /= (ulong)(config.statisticsFreshRate / 1000f); down /= (ulong)(config.statisticsFreshRate / 1000f); - toolSslServerSpeed.Text = string.Format( - "{0}/s↑ | {1}/s↓", - Utils.HumanFy(up), - Utils.HumanFy(down) - ); + toolSslServerSpeed.Text = string.Format("{0}/s↑ | {1}/s↓", Utils.HumanFy(up), Utils.HumanFy(down)); 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_ => Utils.IsIdenticalServer(item_, new ServerStatistics(config.vmess[i].remarks, config.vmess[i].address, config.vmess[i].port, config.vmess[i].path, config.vmess[i].requestHost, 0, 0, 0, 0))); + var index = statistics.FindIndex(item_ => item_.itemId == config.vmess[i].getItemId()); if (index != -1) { - totalUp_ = Utils.HumanFy(statistics[index].totalUp); - totalDown_ = Utils.HumanFy(statistics[index].totalDown); - todayUp_ = Utils.HumanFy(statistics[index].todayUp); - todayDown_ = Utils.HumanFy(statistics[index].todayDown); - } + lvServers.Invoke((MethodInvoker)delegate + { + lvServers.SuspendLayout(); - datas.Add(new string[] { totalUp_, totalDown_, todayUp_, todayDown_ }); + var indexStart = 9; + lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].totalUp); + lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].totalDown); + lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].todayUp); + lvServers.Items[i].SubItems[indexStart++].Text = Utils.HumanFy(statistics[index].todayDown); + + lvServers.ResumeLayout(); + }); + } } - - lvServers.Invoke((MethodInvoker)delegate - { - lvServers.SuspendLayout(); - for (int i = 0; i < datas.Count; i++) - { - var indexStart = 9; - lvServers.Items[i].SubItems[indexStart++].Text = datas[i][0]; - lvServers.Items[i].SubItems[indexStart++].Text = datas[i][1]; - lvServers.Items[i].SubItems[indexStart++].Text = datas[i][2]; - lvServers.Items[i].SubItems[indexStart++].Text = datas[i][3]; - } - lvServers.ResumeLayout(); - }); - } catch (Exception ex) { @@ -1149,7 +1134,7 @@ namespace v2rayN.Forms } else { - downloadHandle.DownloadFileAsync(config, url, null); + downloadHandle.DownloadFileAsync(config, url, null, -1); } })); } diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs b/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs index 8a7a9d59..57488adc 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs @@ -85,9 +85,7 @@ 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(); this.txturlGFWList = new System.Windows.Forms.TextBox(); @@ -114,32 +112,31 @@ // // btnClose // - resources.ApplyResources(this.btnClose, "btnClose"); this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; + resources.ApplyResources(this.btnClose, "btnClose"); this.btnClose.Name = "btnClose"; this.btnClose.UseVisualStyleBackColor = true; this.btnClose.Click += new System.EventHandler(this.btnClose_Click); // // tabControl1 // - resources.ApplyResources(this.tabControl1, "tabControl1"); this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Controls.Add(this.tabPage2); this.tabControl1.Controls.Add(this.tabPage6); this.tabControl1.Controls.Add(this.tabPage7); + resources.ApplyResources(this.tabControl1, "tabControl1"); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; // // tabPage1 // - resources.ApplyResources(this.tabPage1, "tabPage1"); this.tabPage1.Controls.Add(this.groupBox1); + resources.ApplyResources(this.tabPage1, "tabPage1"); this.tabPage1.Name = "tabPage1"; this.tabPage1.UseVisualStyleBackColor = true; // // groupBox1 // - resources.ApplyResources(this.groupBox1, "groupBox1"); this.groupBox1.Controls.Add(this.label16); this.groupBox1.Controls.Add(this.cmblistenerType); this.groupBox1.Controls.Add(this.chksniffingEnabled2); @@ -160,6 +157,7 @@ this.groupBox1.Controls.Add(this.label5); this.groupBox1.Controls.Add(this.txtlocalPort); this.groupBox1.Controls.Add(this.label2); + resources.ApplyResources(this.groupBox1, "groupBox1"); this.groupBox1.Name = "groupBox1"; this.groupBox1.TabStop = false; // @@ -170,7 +168,6 @@ // // cmblistenerType // - resources.ApplyResources(this.cmblistenerType, "cmblistenerType"); this.cmblistenerType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmblistenerType.FormattingEnabled = true; this.cmblistenerType.Items.AddRange(new object[] { @@ -179,6 +176,7 @@ resources.GetString("cmblistenerType.Items2"), resources.GetString("cmblistenerType.Items3"), resources.GetString("cmblistenerType.Items4")}); + resources.ApplyResources(this.cmblistenerType, "cmblistenerType"); this.cmblistenerType.Name = "cmblistenerType"; // // chksniffingEnabled2 @@ -224,12 +222,12 @@ // // cmbprotocol2 // - resources.ApplyResources(this.cmbprotocol2, "cmbprotocol2"); this.cmbprotocol2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbprotocol2.FormattingEnabled = true; this.cmbprotocol2.Items.AddRange(new object[] { resources.GetString("cmbprotocol2.Items"), resources.GetString("cmbprotocol2.Items1")}); + resources.ApplyResources(this.cmbprotocol2, "cmbprotocol2"); this.cmbprotocol2.Name = "cmbprotocol2"; // // label3 @@ -244,8 +242,8 @@ // // cmbprotocol // - resources.ApplyResources(this.cmbprotocol, "cmbprotocol"); this.cmbprotocol.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + resources.ApplyResources(this.cmbprotocol, "cmbprotocol"); this.cmbprotocol.FormattingEnabled = true; this.cmbprotocol.Items.AddRange(new object[] { resources.GetString("cmbprotocol.Items"), @@ -271,7 +269,6 @@ // // cmbloglevel // - resources.ApplyResources(this.cmbloglevel, "cmbloglevel"); this.cmbloglevel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbloglevel.FormattingEnabled = true; this.cmbloglevel.Items.AddRange(new object[] { @@ -280,6 +277,7 @@ resources.GetString("cmbloglevel.Items2"), resources.GetString("cmbloglevel.Items3"), resources.GetString("cmbloglevel.Items4")}); + resources.ApplyResources(this.cmbloglevel, "cmbloglevel"); this.cmbloglevel.Name = "cmbloglevel"; // // label5 @@ -299,33 +297,33 @@ // // tabPage2 // - resources.ApplyResources(this.tabPage2, "tabPage2"); this.tabPage2.Controls.Add(this.groupBox2); + resources.ApplyResources(this.tabPage2, "tabPage2"); this.tabPage2.Name = "tabPage2"; this.tabPage2.UseVisualStyleBackColor = true; // // groupBox2 // - resources.ApplyResources(this.groupBox2, "groupBox2"); this.groupBox2.Controls.Add(this.tabControl2); this.groupBox2.Controls.Add(this.panel3); + resources.ApplyResources(this.groupBox2, "groupBox2"); this.groupBox2.Name = "groupBox2"; this.groupBox2.TabStop = false; // // tabControl2 // - resources.ApplyResources(this.tabControl2, "tabControl2"); this.tabControl2.Controls.Add(this.tabPage3); this.tabControl2.Controls.Add(this.tabPage4); this.tabControl2.Controls.Add(this.tabPage5); this.tabControl2.Controls.Add(this.tabPage8); + resources.ApplyResources(this.tabControl2, "tabControl2"); this.tabControl2.Name = "tabControl2"; this.tabControl2.SelectedIndex = 0; // // tabPage3 // - resources.ApplyResources(this.tabPage3, "tabPage3"); this.tabPage3.Controls.Add(this.txtUseragent); + resources.ApplyResources(this.tabPage3, "tabPage3"); this.tabPage3.Name = "tabPage3"; this.tabPage3.UseVisualStyleBackColor = true; // @@ -336,8 +334,8 @@ // // tabPage4 // - resources.ApplyResources(this.tabPage4, "tabPage4"); this.tabPage4.Controls.Add(this.txtUserdirect); + resources.ApplyResources(this.tabPage4, "tabPage4"); this.tabPage4.Name = "tabPage4"; this.tabPage4.UseVisualStyleBackColor = true; // @@ -348,8 +346,8 @@ // // tabPage5 // - resources.ApplyResources(this.tabPage5, "tabPage5"); this.tabPage5.Controls.Add(this.txtUserblock); + resources.ApplyResources(this.tabPage5, "tabPage5"); this.tabPage5.Name = "tabPage5"; this.tabPage5.UseVisualStyleBackColor = true; // @@ -360,14 +358,13 @@ // // tabPage8 // - resources.ApplyResources(this.tabPage8, "tabPage8"); this.tabPage8.Controls.Add(this.cmbroutingMode); + resources.ApplyResources(this.tabPage8, "tabPage8"); this.tabPage8.Name = "tabPage8"; this.tabPage8.UseVisualStyleBackColor = true; // // cmbroutingMode // - resources.ApplyResources(this.cmbroutingMode, "cmbroutingMode"); this.cmbroutingMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbroutingMode.FormattingEnabled = true; this.cmbroutingMode.Items.AddRange(new object[] { @@ -375,15 +372,16 @@ resources.GetString("cmbroutingMode.Items1"), resources.GetString("cmbroutingMode.Items2"), resources.GetString("cmbroutingMode.Items3")}); + resources.ApplyResources(this.cmbroutingMode, "cmbroutingMode"); this.cmbroutingMode.Name = "cmbroutingMode"; // // panel3 // - resources.ApplyResources(this.panel3, "panel3"); this.panel3.Controls.Add(this.btnSetDefRountingRule); this.panel3.Controls.Add(this.labRoutingTips); this.panel3.Controls.Add(this.cmbdomainStrategy); this.panel3.Controls.Add(this.label15); + resources.ApplyResources(this.panel3, "panel3"); this.panel3.Name = "panel3"; // // btnSetDefRountingRule @@ -395,19 +393,19 @@ // // labRoutingTips // - resources.ApplyResources(this.labRoutingTips, "labRoutingTips"); this.labRoutingTips.ForeColor = System.Drawing.Color.Brown; + resources.ApplyResources(this.labRoutingTips, "labRoutingTips"); this.labRoutingTips.Name = "labRoutingTips"; // // cmbdomainStrategy // - resources.ApplyResources(this.cmbdomainStrategy, "cmbdomainStrategy"); this.cmbdomainStrategy.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbdomainStrategy.FormattingEnabled = true; this.cmbdomainStrategy.Items.AddRange(new object[] { resources.GetString("cmbdomainStrategy.Items"), resources.GetString("cmbdomainStrategy.Items1"), resources.GetString("cmbdomainStrategy.Items2")}); + resources.ApplyResources(this.cmbdomainStrategy, "cmbdomainStrategy"); this.cmbdomainStrategy.Name = "cmbdomainStrategy"; // // label15 @@ -417,7 +415,6 @@ // // tabPage6 // - resources.ApplyResources(this.tabPage6, "tabPage6"); this.tabPage6.Controls.Add(this.chkKcpcongestion); this.tabPage6.Controls.Add(this.txtKcpwriteBufferSize); this.tabPage6.Controls.Add(this.label10); @@ -431,6 +428,7 @@ this.tabPage6.Controls.Add(this.label7); this.tabPage6.Controls.Add(this.txtKcpmtu); this.tabPage6.Controls.Add(this.label6); + resources.ApplyResources(this.tabPage6, "tabPage6"); this.tabPage6.Name = "tabPage6"; this.tabPage6.UseVisualStyleBackColor = true; // @@ -502,41 +500,29 @@ // // tabPage7 // - resources.ApplyResources(this.tabPage7, "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); this.tabPage7.Controls.Add(this.chkAutoRun); + resources.ApplyResources(this.tabPage7, "tabPage7"); this.tabPage7.Name = "tabPage7"; this.tabPage7.UseVisualStyleBackColor = true; // // cbFreshrate // - resources.ApplyResources(this.cbFreshrate, "cbFreshrate"); this.cbFreshrate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 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"); - this.lbCacheDays.Name = "lbCacheDays"; - // // chkEnableStatistics // resources.ApplyResources(this.chkEnableStatistics, "chkEnableStatistics"); @@ -567,9 +553,9 @@ // // panel2 // - resources.ApplyResources(this.panel2, "panel2"); this.panel2.Controls.Add(this.btnClose); this.panel2.Controls.Add(this.btnOK); + resources.ApplyResources(this.panel2, "panel2"); this.panel2.Name = "panel2"; // // btnOK @@ -682,8 +668,6 @@ 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.Label label16; diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.cs b/v2rayN/v2rayN/Forms/OptionSettingForm.cs index 6d877d06..cefc211a 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.cs +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.cs @@ -115,8 +115,6 @@ namespace v2rayN.Forms var enableStatistics = config.enableStatistics; chkEnableStatistics.Checked = enableStatistics; - tbCacheDays.Text = config.CacheDays.ToString(); - var cbSource = new ComboItem[] { @@ -332,13 +330,6 @@ namespace v2rayN.Forms var lastEnableStatistics = config.enableStatistics; config.enableStatistics = chkEnableStatistics.Checked; - - uint days = 0; - var valid = uint.TryParse(tbCacheDays.Text, out days); - if (!valid) - days = 7; - config.CacheDays = days; - config.statisticsFreshRate = (int)cbFreshrate.SelectedValue; //if(lastEnableStatistics != config.enableStatistics) diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.resx b/v2rayN/v2rayN/Forms/OptionSettingForm.resx index 89755a95..e2c26e28 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.resx +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.resx @@ -117,1816 +117,1768 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 355, 16 + + + 75, 23 + - + + 7 + + + &Cancel + + + btnClose + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel2 + + + 0 + + True - - 11 + + + NoControl + + + 42, 98 + + + 65, 12 + + + 34 + + + Http proxy + + + label16 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 0 + + + Not Enabled Http Proxy + + + Open Http proxy and automatically configure proxy server (global mode) + + + Open PAC and automatically configure PAC (PAC mode) + + + Only open Http proxy, do not automatically configure proxy server (direct mode) + + + Only open PAC, do not automatically configure PAC + + + 124, 94 + + + 464, 20 + + + 33 + + + cmblistenerType + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 1 + + + 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 + + + 2 + + + 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 + + + 3 + + + 33, 228 + + + 402, 21 + + + 30 + + + txtremoteDNS System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - groupBox2 + + groupBox1 - - 1 + + 4 - - - 30, 176 + + True + + + 33, 204 + + + 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 + + + 5 + + + True + + + 15, 129 + + + 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 + + + 6 + + + 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 + + + 7 + + + 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 + + + 8 + + + 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 + + + 9 + + + 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 + + + 10 + + + 124, 60 + + + 78, 21 + + + 14 + + + False + + + txtlocalPort2 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 11 + + + 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 + + + 12 + + + 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 + + + 13 + + + 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 + + + 14 + + + True + + + 15, 160 + + + 126, 16 + + + 9 Record local logs + + chklogEnabled + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 15 + + + debug + + + info + + + warning + + + error + + + none + + + 257, 158 + + + 97, 20 + + + 6 + + + cmbloglevel + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 16 + + + True + + + 193, 162 + + + 59, 12 + + + 8 + + + Log level + + + label5 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 17 + + + 124, 25 + + + 78, 21 + + + 3 + + + txtlocalPort + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 18 + + + 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 + + + 19 + + + Fill + + + 3, 3 + + + 648, 573 + + + 6 + + + groupBox1 + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage1 + + + 0 + + + 4, 22 + + + 3, 3, 3, 3 + + + 654, 579 + + + 0 + + + Core: basic settings + + + tabPage1 + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabControl1 + + + 0 + + + Fill + + + 3, 3 + + + 0 + + + True + + + Vertical + + + 628, 454 + + + 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 + + + 634, 460 + + + 0 + + + 1.Proxy 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 + + + 0 + + + True + + + Vertical + + + 628, 454 + + + 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 + 634, 460 + + 1 + + + 2.Direct 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 + + + 0 + + + True + + + Vertical + + + 628, 454 + + + 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 + + + 634, 460 + + + 2 + + + 3.Block Domain or IP + + + tabPage5 + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabControl2 + + + 2 + + + Global + + + Bypassing the LAN address + + + Bypass mainland address + + + Bypassing LAN and mainland address + + + 21, 17 + + + 255, 20 + + + 14 + + + cmbroutingMode + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage8 + + + 0 + + + 4, 22 + + + 3, 3, 3, 3 + + + 634, 460 + + + 3 + + + 4.Pre-defined rules + + + tabPage8 + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabControl2 + + + 3 + + + Fill + + + 3, 84 + + + 642, 486 + + + 12 + + + tabControl2 + + + System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 0 + + + 322, 10 + + + 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 + + + 5, 45 + + + 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 + + + 1 + + + AsIs + + + IPIfNonMatch + + + IPOnDemand + + + 115, 10 + + + 165, 20 + + + 16 + + + cmbdomainStrategy + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel3 + + + 2 + + + True + + + NoControl + + + 5, 14 + + + 95, 12 + + + 17 + + + Domain strategy + + + label15 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel3 + + + 3 + + + Top + + + 3, 17 + + + 642, 67 + + + 19 + + + panel3 + + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 1 + + + Fill + + + 3, 3 + + + 648, 573 + + + 12 + + + groupBox2 + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage2 + + + 0 + + + 4, 22 + + + 3, 3, 3, 3 + + + 654, 579 + + + 1 + + + Core: Routing settings + + + tabPage2 + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabControl1 + + + 1 + + + True + + + 20, 143 + + + 84, 16 + + + 20 + + + congestion + + + chkKcpcongestion + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage6 + + + 0 + + + 345, 100 + + + 94, 21 + + + 15 + + + txtKcpwriteBufferSize + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage6 + + + 1 + + + True + + + 236, 104 + + + 95, 12 + + + 14 + + + writeBufferSize + + + label10 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage6 + + + 2 + + + 111, 100 + + + 94, 21 + + + 13 + + + txtKcpreadBufferSize + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage6 + + + 3 + + + True + + + 18, 104 + + + 89, 12 + + + 12 + + + readBufferSize + + + label11 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage6 + + + 4 + + + 345, 62 + + + 94, 21 + + + 11 + + + txtKcpdownlinkCapacity + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage6 + + + 5 + + + True + + + 236, 66 + + + 101, 12 + + + 10 + + + downlinkCapacity + + + label8 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage6 + + + 6 + + + 111, 62 + + + 94, 21 + + + 9 + + + txtKcpuplinkCapacity + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage6 + + + 7 + + + True + + + 18, 66 + + + 89, 12 + + + 8 + + + uplinkCapacity + + + label9 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage6 + + + 8 + + + 345, 24 + + + 94, 21 + + + 7 + + + txtKcptti + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage6 + + + 9 + + + True + + + 236, 28 + + + 23, 12 + + + 6 + + + tti + + + label7 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage6 + + + 10 + + + 111, 24 + + + 94, 21 + + + 5 + + + txtKcpmtu + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage6 + + + 11 + + + True + + + 18, 28 + + + 23, 12 + + + 4 + + + mtu + + + label6 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPage6 + 12 4, 22 - - txtKcpwriteBufferSize - - - groupBox1 - - - 2 - - - False - - - 17 - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl1 - - - groupBox1 - - - True - - - 5 - - - 94, 21 - - - 9 - - - groupBox1 - - - label15 - - - 2 - - - 468, 60 - - - - Top - - - 6 - - - 464, 20 - - - 14 - - - tabPage3 - - - cmblistenerType - - - 0 - - - 634, 460 - - - 0 - - - 111, 100 - - - True - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 30 - - - 3, 3 - - - 598, 16 - - - True - - - 120, 16 - - - panel3 - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - True - - - tti - - - tabPage6 - - - tabPage6 - - - tabPage6 - - - Cache days(between 0 to 30, 0 disable cache indivitual days statistic data) - - - 84, 16 - - - 65, 12 - - - 628, 454 - - - tabPage7 - - - 12 - - - http - - - 7 - - - True - - - 648, 573 - - - 18 - - - True - - - 206, 64 - - - 95, 12 - - - tabPage6 - - - 0 - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 15, 63 - - - tabControl2 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 2 - - - Enable UDP - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Fill - - - &Cancel - - - label10 - - - 648, 573 - - - Vertical - - - 654, 579 - - - NoControl - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Settings - - - 31 - - - Bypassing the LAN address - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Bypassing LAN and mainland address - - - Bypass mainland address - - - Top - - - 126, 16 - - - 12 - - - txtKcpmtu - - - lbFreshrate - - - 1 - - - $this - - - label11 - - - 29 - - - 8 - - - NoControl - - - Only open Http proxy, do not automatically configure proxy server (direct mode) - - - 58, 20 - - - 3, 3 - - - tabPage6 - - - False - - - tabControl2 - - - 0 - - - $this - - - 6 - - - 662, 675 - - - none - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - NoControl - - - tabPage7 - - - 0 - - - tabPage6 - - - 3 - - - 558, 16 - - - 18 - - - True - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - congestion - - - panel3 - - - groupBox2 - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + 3, 3, 3, 3 - - 89, 12 - - - NoControl - - - txtUseragent - - - 0 - - - tabPage7 - - - v2rayN settings - - - 19 - - - 15 - - - Not Enabled Http Proxy - - - 13 - - - 32 - - - 628, 454 - - - 6, 12 - - - 16 - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 132, 16 - - - 516, 111 - - - Boot automatically - - - label14 - - - 3, 3, 3, 3 - - - 1 - - - 10 - - - txtKcptti - - - 2 - - - Turn on Sniffing - - - 281, 12 - - - 236, 66 - - - 355, 16 - - - 3, 3, 3, 3 - - - 3 - - - 662, 605 - - - 33, 29 - - - 124, 60 - - - 78, 21 - - - 5, 45 - - - Log level - - - tabControl1 - - - v2rayN.Forms.BaseForm, v2rayN, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - - warning - - - groupBox1 - - - 0 - - - Open PAC and automatically configure PAC (PAC mode) - - - tabPage7 - - - Statistics freshrate - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 120, 16 - - - 89, 12 - - - btnOK - - - 18, 66 - - - 20, 143 - - - 11 - - - True - - - 4, 4, 4, 4 - - - tabPage6 - - - btnClose - - - Turn on Sniffing - - - groupBox1 - - - 18, 28 - - - cmbdomainStrategy - - - 34 - - - 20 - - - 10 - - - 0 - - - 21, 17 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 1 - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 14 - - - 19 - - - True - - - chksniffingEnabled - - - 5 - - - 174, 16 - - - 30, 92 - - - groupBox1 - - - groupBox1 - - - groupBox1 - - - 18, 104 - - - tabPage2 - - - mtu - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - socks - - - tabPage5 - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 1 - - - 29 - - - tabPage6 - - - *Set the rules, separated by commas (,); support Domain (pure string / regular / subdomain) and IP - - - tabPage3 - - - 30 - - - 53, 12 - - - txtlocalPort2 - - - 16 - - - label8 - - - 468, 27 - - - label13 - - - chkAutoRun - - - 94, 21 - - - 3 - - - 14 - - - 1 - - - chkudpEnabled - - - True - - - 33, 204 - - - tabPage1 - - - 5 - - - tabPage6 - - - System.Windows.Forms.Label, 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 - - - 4 - - - btnSetDefRountingRule - - - True - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - label1 - - - 84, 16 - - - tabPage8 - - - True - - - label7 - - - txtlocalPort - - - txturlGFWList - - - 236, 28 - - - tabPage7 - - - 3, 17 - - - True - - - 4, 22 - - - labRoutingTips - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 3, 3, 3, 3 - - - 124, 25 - - - protocol - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl2 - - - tbCacheDays - - - 23, 12 - - - 402, 21 - - - socks - - - 0 - - - 3, 3 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - chkAllowLANConn - - - 84, 16 - - - tabControl1 - - - True - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 15, 38 - - - 2 - - - tabPage6 - - - 369, 62 - - - 12 - - - 1.Proxy Domain or IP - - - panel3 - - - 6 - - - tabControl1 - - - Fill - - - tabControl2 - - - 28 - - - 7 - - - 2.Direct Domain or IP - - - label6 - - - 53, 12 - - - 193, 162 - - - 369, 27 - - - 0 - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 0 - - - label2 - - - False - - - 3, 3 - - - 9 - - - groupBox1 - - - 4.Pre-defined rules - - - 101, 12 - - - 4 - - - 12 - - - 30, 120 - - - 20 - - - cmbprotocol - - - lbCacheDays - - - True - - - Enable Statistics(Realtime net speed and traffic data amount. Need restart v2rayN client) - - - 431, 12 - - - 1 - - - System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage6 - - - 4 - - - Listening port - - - cmbroutingMode - - - Fill - - - 1 - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Vertical - - - 60, 21 - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 257, 60 - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl1 - - - True - - - cmbprotocol2 - - - Open Http proxy and automatically configure proxy server (global mode) - - - 12 - - - 15, 129 - - - 16 - - - 5 - - - True - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - chkKcpcongestion - - - Core: basic settings - - - 0 - - - 257, 25 - - - 3, 84 - - - True - - - listening port 2 - - - 97, 20 - - - chkAllowIn2 - - - tabPage2 - - - True - - - False - - - 3 - - - tabPage4 - - - 4, 22 - - - 544, 21 - - - Core: KCP settings - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 29 - - - error - - - True - - - 59, 12 - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 634, 460 - - - downlinkCapacity - - - 120, 16 - - - 662, 10 - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - True - - - tabControl2 - - - True - - - Fill - - - 654, 579 - - - 7 - - - 27 - - - 10 - - - False - - - Vertical - - - 206, 29 - - - txtUserdirect - - - chkudpEnabled2 - - - 0 - - - info - - - 0 - - - 33 - - - Allow connections from the LAN - - - 161, 84 - - - panel3 - - - tabPage6 - - - groupBox1 - - - 3 - - - panel2 - - - 30 - - - 89, 12 - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - txtKcpreadBufferSize - - - True - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Fill - - - 6 - - - tabPage4 - - - OptionSettingForm - - - 2 - - - 95, 12 - - - AsIs - - - 15, 62 - - - 111, 62 - - - 8 - - - tabPage7 - - - 642, 486 - - - 4, 22 - - - 14 - - - True - - - 1 - - - 0 - - - 13 - - - 13 - - - 2 - - - chkEnableStatistics - - - 9 - - - 9 - - - 78, 21 - - - System.Windows.Forms.TextBox, 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 - - - True - - - 3 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 1 - - - 23, 12 - - - 11 - - - 8 - - - 3, 3, 3, 3 - - - 17 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 345, 100 - - - 94, 21 - - - readBufferSize - 654, 579 - - 10 - - - 204, 16 - - - 17 - - - 23 - - - 94, 21 - - - 9 - - - 7 - - - 0, 615 - - - txtUserblock - - - 229, 23 - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Bottom - - - 3 - - - 15 - - + 2 - - http + + Core: KCP settings - - 0 + + tabPage6 - - Custom GFWList address (please fill in the blank without customization) + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 97, 20 + + tabControl1 + + + 2 + + + 161, 84 + + + 58, 20 32 - - 255, 20 + + cbFreshrate - - tabPage6 + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 4, 22 - - - 7 - - - False - - - NoControl - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - &OK - - - 10 - - - 1 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - txtKcpuplinkCapacity - - - 115, 10 - - - groupBox1 - - - chklogEnabled - - - chksniffingEnabled2 - - + tabPage7 - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 642, 67 - - - groupBox2 - - - 4, 22 - - - $this - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabPage5 - - - 8 - - - Domain strategy - - - IPIfNonMatch - - - 4, 22 - - - groupBox1 - - + 0 - - 6 - - - protocol - - - tabPage7 - - - 15, 16 - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - True - - 0 + + NoControl - - 8 - - - txtremoteDNS - - - 3, 3 - - - 19 - - - True - - - 3 - - - writeBufferSize - - - 11 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 2 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 0 - - - 31 - - - 3, 3, 3, 3 - - - groupBox1 - - - groupBox1 - - - groupBox1 - - - groupBox1 - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Core: Routing settings - - - 345, 24 - - - tabPage1 - - - 124, 94 - - - 257, 158 - - - tabPage8 - - - 2 - - - 236, 104 - - - panel3 - - - 3.Block Domain or IP - - - 455, 12 + + 30, 92 125, 12 - - 165, 20 + + 30 - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Statistics freshrate - - 94, 21 + + lbFreshrate - - 75, 23 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + tabPage7 + + + 1 + + + True + + + NoControl + + + 15, 62 + + + 558, 16 + + + 29 + + + Enable Statistics(Realtime net speed and traffic data amount. Need restart v2rayN client) + + + chkEnableStatistics + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 33, 228 + + tabPage7 - - 345, 62 + + 2 - - uplinkCapacity + + True - - 42, 98 + + 15, 38 - - txtKcpdownlinkCapacity + + 204, 16 - - IPOnDemand + + 29 - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Allow connections from the LAN - - 5, 14 + + chkAllowLANConn - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 3, 3, 3, 3 + + tabPage7 + + + 3 32, 205 - - 634, 460 + + 544, 21 - - label5 + + 28 - - 1 + + txturlGFWList - - 628, 454 + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + tabPage7 - - label16 - - - tabPage6 - - - Set default custom routing rules - - - debug - - - Http proxy - - - chkmuxEnabled - - - label3 - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - False - - - 4, 22 - - - 8 - - - 0 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 0, 0 - - - Enable UDP - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 4 True - - groupBox1 + + 30, 176 - - 18 + + 431, 12 - - groupBox1 + + 27 - - 267, 16 + + Custom GFWList address (please fill in the blank without customization) - - Global + + label13 - - 75, 23 - - - tabPage7 - - - 15, 160 - - - Fill - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Fill - - + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 322, 10 + + tabPage7 - - groupBox1 + + 5 - - 0 - - - 94, 21 - - - 97, 20 - - - 3 - - - 3, 3, 3, 3 - - - Custom DNS (multiple, separated by commas (,)) - - - 654, 579 - - - 11 - - - 6 - - - groupBox1 - - - NoControl - - - panel2 - - + 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 - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + tabPage7 - - cbFreshrate + + 6 - - Turn on Mux Multiplexing + + 4, 22 - - cmbloglevel + + 3, 3, 3, 3 - - Only open PAC, do not automatically configure PAC + + 654, 579 - - 111, 24 + + 3 - - panel2 + + v2rayN settings - - 4 + + tabPage7 - - 1 + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - label9 + + tabControl1 + + + 3 + + + Fill 0, 10 - - panel1 + + 662, 605 + + + 10 + + + tabControl1 + + + System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + 267, 16 + + + 75, 23 + + + 8 + + + &OK + + + btnOK + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel2 + + + 1 + + + Bottom + + + 0, 615 662, 60 - - tabPage7 + + 11 + + + panel2 + + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + Top + + + 0, 0 + + + 662, 10 + + + 9 + + + panel1 + + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 True + + 6, 12 + + + 662, 675 + + + 4, 4, 4, 4 + + + Settings + + + OptionSettingForm + + + v2rayN.Forms.BaseForm, v2rayN, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/v2rayN/v2rayN/Global.cs b/v2rayN/v2rayN/Global.cs index 7dce5b75..929d7624 100644 --- a/v2rayN/v2rayN/Global.cs +++ b/v2rayN/v2rayN/Global.cs @@ -13,7 +13,7 @@ namespace v2rayN /// /// SpeedTestUrl /// - public const string SpeedTestUrl = @"http://speedtest-sfo2.digitalocean.com/10mb.test"; + public const string SpeedTestUrl = @"http://speedtest-sgp1.digitalocean.com/10mb.test"; public const string SpeedPingTestUrl = @"https://www.google.com/generate_204"; /// @@ -160,8 +160,7 @@ namespace v2rayN medium = 2000, slow = 3000 } - public const string StatisticLogDirectory = "Statistics"; - public const string StatisticLogOverall = "overall.txt"; + public const string StatisticLogOverall = "StatisticLogOverall.json"; #endregion diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs index cf816827..2399a666 100644 --- a/v2rayN/v2rayN/Handler/ConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs @@ -41,10 +41,7 @@ namespace v2rayN.Handler ////默认监听端口 //config.pacPort = 8888; - - // 默认缓存七天 - config.CacheDays = 7; - + // 默认不开启统计 config.enableStatistics = false; @@ -125,6 +122,10 @@ namespace v2rayN.Handler { config.urlGFWList = Global.GFWLIST_URL; } + if (Utils.IsNullOrEmpty(config.remoteDNS)) + { + config.remoteDNS = "1.1.1.1"; + } if (config.subItem == null) { diff --git a/v2rayN/v2rayN/Handler/DownloadHandle.cs b/v2rayN/v2rayN/Handler/DownloadHandle.cs index df26cc70..9ef170d2 100644 --- a/v2rayN/v2rayN/Handler/DownloadHandle.cs +++ b/v2rayN/v2rayN/Handler/DownloadHandle.cs @@ -40,15 +40,13 @@ namespace v2rayN.Handler private string latestUrl = "https://github.com/v2ray/v2ray-core/releases/latest"; private const string coreURL = "https://github.com/v2ray/v2ray-core/releases/download/{0}/v2ray-windows-{1}.zip"; private int progressPercentage = -1; - private bool blFirst = true; private long totalBytesToReceive = 0; private DateTime totalDatetime = new DateTime(); - + private int DownloadTimeout = -1; public void AbsoluteV2rayCore(Config config) { - ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; //TLS 1.2 - ServicePointManager.DefaultConnectionLimit = 256; + SetSecurityProtocol(); WebRequest request = WebRequest.Create(latestUrl); request.BeginGetResponse(new AsyncCallback(OnResponseV2rayCore), request); } @@ -87,12 +85,11 @@ namespace v2rayN.Handler } - public void DownloadFileAsync(Config config, string url, WebProxy webProxy) + public void DownloadFileAsync(Config config, string url, WebProxy webProxy, int downloadTimeout) { try { - ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; //TLS 1.2 - ServicePointManager.DefaultConnectionLimit = 256; + SetSecurityProtocol(); if (UpdateCompleted != null) { UpdateCompleted(this, new ResultEventArgs(false, "Downloading...")); @@ -101,6 +98,7 @@ namespace v2rayN.Handler progressPercentage = -1; WebClientEx ws = new WebClientEx(); + DownloadTimeout = downloadTimeout; if (webProxy != null) { ws.Proxy = webProxy;// new WebProxy(Global.Loopback, Global.httpPort); @@ -109,7 +107,7 @@ namespace v2rayN.Handler ws.DownloadFileCompleted += ws_DownloadFileCompleted; ws.DownloadProgressChanged += ws_DownloadProgressChanged; ws.DownloadFileAsync(new Uri(url), Utils.GetPath(DownloadFileName)); - blFirst = true; + totalBytesToReceive = 0; } catch (Exception ex) { @@ -122,14 +120,24 @@ namespace v2rayN.Handler void ws_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) { - if (blFirst) - { - totalBytesToReceive = e.TotalBytesToReceive - e.BytesReceived; - totalDatetime = DateTime.Now; - blFirst = false; - } if (UpdateCompleted != null) { + if (DownloadTimeout != -1) + { + if ((DateTime.Now - totalDatetime).TotalSeconds > DownloadTimeout) + { + ((WebClientEx)sender).CancelAsync(); + } + } + + if (totalBytesToReceive == 0) + { + totalDatetime = DateTime.Now; + totalBytesToReceive = e.BytesReceived; + return; + } + totalBytesToReceive = e.BytesReceived; + if (progressPercentage != e.ProgressPercentage && e.ProgressPercentage % 10 == 0) { progressPercentage = e.ProgressPercentage; @@ -143,19 +151,29 @@ namespace v2rayN.Handler { try { - if (e.Error == null - || Utils.IsNullOrEmpty(e.Error.ToString())) + if (UpdateCompleted != null) { - if (UpdateCompleted != null) + if (e.Cancelled) { + ((WebClientEx)sender).Dispose(); + TimeSpan ts = (DateTime.Now - totalDatetime); + string speed = string.Format("<{0} M/s", (totalBytesToReceive / ts.TotalMilliseconds / 1000).ToString("#0.##")); + UpdateCompleted(this, new ResultEventArgs(true, speed)); + return; + } + + if (e.Error == null + || Utils.IsNullOrEmpty(e.Error.ToString())) + { + TimeSpan ts = (DateTime.Now - totalDatetime); string speed = string.Format("{0} M/s", (totalBytesToReceive / ts.TotalMilliseconds / 1000).ToString("#0.##")); UpdateCompleted(this, new ResultEventArgs(true, speed)); } - } - else - { - throw e.Error; + else + { + throw e.Error; + } } } catch (Exception ex) @@ -176,8 +194,7 @@ namespace v2rayN.Handler string source = string.Empty; try { - ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; //TLS 1.2 - ServicePointManager.DefaultConnectionLimit = 256; + SetSecurityProtocol(); WebClientEx ws = new WebClientEx(); ws.DownloadStringCompleted += Ws_DownloadStringCompleted; @@ -216,6 +233,13 @@ namespace v2rayN.Handler } } - + private void SetSecurityProtocol() + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 + | SecurityProtocolType.Tls + | SecurityProtocolType.Tls11 + | SecurityProtocolType.Tls12; + ServicePointManager.DefaultConnectionLimit = 256; + } } } diff --git a/v2rayN/v2rayN/Handler/SpeedtestHandler.cs b/v2rayN/v2rayN/Handler/SpeedtestHandler.cs index 3c65a725..cc157e52 100644 --- a/v2rayN/v2rayN/Handler/SpeedtestHandler.cs +++ b/v2rayN/v2rayN/Handler/SpeedtestHandler.cs @@ -244,7 +244,7 @@ namespace v2rayN.Handler testCounter++; var webProxy = new WebProxy(Global.Loopback, httpPort + index); - downloadHandle2.DownloadFileAsync(_config, url, webProxy); + downloadHandle2.DownloadFileAsync(_config, url, webProxy, 30); return 0; } diff --git a/v2rayN/v2rayN/Handler/StatisticsHandler.cs b/v2rayN/v2rayN/Handler/StatisticsHandler.cs index a61f634a..1827685a 100644 --- a/v2rayN/v2rayN/Handler/StatisticsHandler.cs +++ b/v2rayN/v2rayN/Handler/StatisticsHandler.cs @@ -15,58 +15,33 @@ namespace v2rayN.Handler class StatisticsHandler { private Mode.Config config_; - + private ServerStatistics serverStatistics_; private Channel channel_; private StatsService.StatsServiceClient client_; private Thread workThread_; + private bool exitFlag_; - Action> updateFunc_; + Action> updateFunc_; - private bool enabled_; public bool Enable - { - get - { - return enabled_; - } - set - { - enabled_ = value; - } - } - - public bool UpdateUI; - - public ulong TotalUp - { - get; private set; - } - - public ulong TotalDown - { - get; private set; - } - - public List Statistic { get; set; } - public ulong Up + public bool UpdateUI { - get; private set; + get; set; } - public ulong Down + public List Statistic { - get; private set; + get + { + return serverStatistics_.server; + } } - private string logPath_; - - private bool exitFlag_; // true to close workThread_ - - public StatisticsHandler(Mode.Config config, Action> update) + public StatisticsHandler(Mode.Config config, Action> update) { try { @@ -86,20 +61,11 @@ namespace v2rayN.Handler } config_ = config; - enabled_ = config.enableStatistics; + Enable = config.enableStatistics; UpdateUI = false; updateFunc_ = update; - logPath_ = Utils.GetPath(Global.StatisticLogDirectory); - Statistic = new List(); exitFlag_ = false; - DeleteExpiredLog(); - foreach (var server in config.vmess) - { - var statistic = new ServerStatistics(server.remarks, server.address, server.port, server.path, server.requestHost, 0, 0, 0, 0); - Statistic.Add(statistic); - } - LoadFromFile(); GrpcInit(); @@ -125,7 +91,6 @@ namespace v2rayN.Handler { try { - exitFlag_ = true; channel_.ShutdownAsync(); } @@ -141,7 +106,7 @@ namespace v2rayN.Handler { try { - if (enabled_ && channel_.State == ChannelState.Ready) + if (Enable && channel_.State == ChannelState.Ready) { QueryStatsResponse res = null; try @@ -155,32 +120,23 @@ namespace v2rayN.Handler if (res != null) { - var addr = config_.address(); - var port = config_.port(); - var path = config_.path(); - var cur = Statistic.FindIndex(item => item.address == addr && item.port == port && item.path == path); + var itemId = config_.getItemId(); + var serverStatItem = GetServerStatItem(itemId); ulong up = 0, down = 0; //TODO: parse output ParseOutput(res.Stat, out up, out down); - Up = up; - Down = down; - - TotalUp += up; - TotalDown += down; - - if (cur != -1) - { - Statistic[cur].todayUp += up; - Statistic[cur].todayDown += down; - Statistic[cur].totalUp += up; - Statistic[cur].totalDown += down; - } + serverStatItem.todayUp += up; + serverStatItem.todayDown += down; + serverStatItem.totalUp += up; + serverStatItem.totalDown += down; if (UpdateUI) - updateFunc_(TotalUp, TotalDown, Up, Down, Statistic); + { + updateFunc_(up, down, new List { serverStatItem }); + } } } Thread.Sleep(config_.statisticsFreshRate); @@ -193,7 +149,82 @@ namespace v2rayN.Handler } } - public void ParseOutput(Google.Protobuf.Collections.RepeatedField source, out ulong up, out ulong down) + public void LoadFromFile() + { + try + { + string result = Utils.LoadResource(Utils.GetPath(Global.StatisticLogOverall)); + if (!Utils.IsNullOrEmpty(result)) + { + //转成Json + serverStatistics_ = Utils.FromJson(result); + } + + if (serverStatistics_ == null) + { + serverStatistics_ = new ServerStatistics(); + } + if (serverStatistics_.server == null) + { + serverStatistics_.server = new List(); + } + + var ticks = DateTime.Now.Date.Ticks; + foreach (var item in serverStatistics_.server) + { + if (item.dateNow != ticks) + { + item.todayUp = 0; + item.todayDown = 0; + item.dateNow = ticks; + } + } + } + catch (Exception ex) + { + Utils.SaveLog(ex.Message, ex); + } + } + + public void SaveToFile() + { + try + { + Utils.ToJsonFile(serverStatistics_, Utils.GetPath(Global.StatisticLogOverall)); + } + catch (Exception ex) + { + Utils.SaveLog(ex.Message, ex); + } + } + + private ServerStatItem GetServerStatItem(string itemId) + { + var ticks = DateTime.Now.Date.Ticks; + var cur = Statistic.FindIndex(item => item.itemId == itemId); + if (cur < 0) + { + Statistic.Add(new ServerStatItem + { + itemId = itemId, + totalUp = 0, + totalDown = 0, + todayUp = 0, + todayDown = 0, + dateNow = ticks + }); + cur = Statistic.Count - 1; + } + if (Statistic[cur].dateNow != ticks) + { + Statistic[cur].todayUp = 0; + Statistic[cur].todayDown = 0; + Statistic[cur].dateNow = ticks; + } + return Statistic[cur]; + } + + private void ParseOutput(Google.Protobuf.Collections.RepeatedField source, out ulong up, out ulong down) { up = 0; down = 0; @@ -231,218 +262,6 @@ 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.ToString("yyyy-MM-dd")} {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.path} {s.host} {s.totalUp} {s.totalDown}"); - } - } - } - catch (Exception ex) - { - Utils.SaveLog(ex.Message, ex); - } - - // 当天流量记录文件 - var dailyPath = Path.Combine(logPath_, $"{DateTime.Now.ToString("yyyy-MM-dd")}.txt"); - if (!File.Exists(dailyPath)) - { - File.Create(dailyPath); - } - try - { - using (var dailyWriter = new StreamWriter(dailyPath)) - { - dailyWriter.WriteLine($"LastUpdate {DateTime.Now.ToString("yyyy-MM-dd")} {DateTime.Now.ToLongTimeString()}"); - foreach (var s in Statistic) - { - dailyWriter.WriteLine($"* {s.name} {s.address} {s.port} {s.path} {s.host} {s.todayUp} {s.todayDown}"); - } - } - } - catch (Exception ex) - { - Utils.SaveLog(ex.Message, ex); - } - } - - public void LoadFromFile() - { - if (!Directory.Exists(logPath_)) return; - - // 总流量统计文件 - /// - /// 文件结构 - /// LastUpdate [date] [time] - /// UP [readable string] [amount] - /// DOWN [readable string] [amount] - /// 每行每个数据空格分隔 - - try - { - Utils.SaveLog(logPath_ + Global.StatisticLogOverall); - var overallPath = Path.Combine(logPath_, Global.StatisticLogOverall); - if (File.Exists(overallPath)) - { - 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 < 8) return; - var name = datas[1]; - var address = datas[2]; - var port = int.Parse(datas[3]); - var path = datas[4]; - var host = datas[5]; - var totalUp = ulong.Parse(datas[6]); - var totalDown = ulong.Parse(datas[7]); - - var temp = new ServerStatistics(name, address, port, path, host, 0, 0, 0, 0); - var index = Statistic.FindIndex(item => Utils.IsIdenticalServer(item, temp)); - if (index != -1) - { - Statistic[index].totalUp = totalUp; - Statistic[index].totalDown = totalDown; - } - else - { - var s = new Mode.ServerStatistics(name, address, port, path, host, totalUp, totalDown, 0, 0); - Statistic.Add(s); - } - } - } - - } - } - } - catch (Exception ex) - { - Utils.SaveLog(ex.Message, ex); - } - - try - { - Utils.SaveLog(logPath_ + $"{DateTime.Now.ToString("yyyy-MM-dd")}.txt"); - var dailyPath = Path.Combine(logPath_, $"{DateTime.Now.ToString("yyyy-MM-dd")}.txt"); - if (File.Exists(dailyPath)) - { - - 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 < 8) return; - var name = datas[1]; - var address = datas[2]; - var port = int.Parse(datas[3]); - var path = datas[4]; - var host = datas[5]; - var todayUp = ulong.Parse(datas[6]); - var todayDown = ulong.Parse(datas[7]); - - var temp = new ServerStatistics(name, address, port, path, host, 0, 0, 0, 0); - var index = Statistic.FindIndex(item => Utils.IsIdenticalServer(item, temp)); - if (index != -1) - { - Statistic[index].todayUp = todayUp; - Statistic[index].todayDown = todayDown; - } - else - { - var s = new Mode.ServerStatistics(name, address, port, path, host, 0, 0, todayUp, todayDown); - Statistic.Add(s); - } - } - } - } - } - } - catch (Exception ex) - { - Utils.SaveLog(ex.Message, ex); - } - } - - - private void DeleteExpiredLog() - { - try - { - 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(); - } - } - } - catch (Exception ex) - { - Utils.SaveLog(ex.Message, ex); - } - } - private int GetFreePort() { int defaultPort = 28123; diff --git a/v2rayN/v2rayN/Mode/Config.cs b/v2rayN/v2rayN/Mode/Config.cs index df188aa5..e83d1c2c 100644 --- a/v2rayN/v2rayN/Mode/Config.cs +++ b/v2rayN/v2rayN/Mode/Config.cs @@ -145,26 +145,7 @@ namespace v2rayN.Mode { 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 @@ -337,6 +318,16 @@ namespace v2rayN.Mode return vmess[index].getSummary(); } + public string getItemId() + { + if (index < 0) + { + return string.Empty; + } + + return vmess[index].getItemId(); + } + #endregion } @@ -420,6 +411,14 @@ namespace v2rayN.Mode } return subid.Substring(0, 4); } + + public string getItemId() + { + var itemId = $"{address}{port}{requestHost}{path}"; + itemId = Utils.Base64Encode(itemId); + return itemId; + } + /// /// 版本(现在=2) /// diff --git a/v2rayN/v2rayN/Mode/ServerStatistics.cs b/v2rayN/v2rayN/Mode/ServerStatistics.cs index 27d3673c..e4a42a5a 100644 --- a/v2rayN/v2rayN/Mode/ServerStatistics.cs +++ b/v2rayN/v2rayN/Mode/ServerStatistics.cs @@ -1,35 +1,43 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace v2rayN.Mode { - class ServerStatistics + [Serializable] + public class ServerStatistics { - public string name; - public string address; - public int port; - public string path; - public string host; - public ulong totalUp; - public ulong totalDown; - public ulong todayUp; - public ulong todayDown; - - public ServerStatistics() { } - public ServerStatistics(string name, string addr, int port, string path, string host, ulong totalUp, ulong totalDown, ulong todayUp, ulong todayDown) + public List server { - this.name = name; - this.address = addr; - this.port = port; - this.path = path; - this.host = host; - this.totalUp = totalUp; - this.totalDown = totalDown; - this.todayUp = todayUp; - this.todayDown = todayDown; + get; set; + } + } + + [Serializable] + public class ServerStatItem + { + public string itemId + { + get; set; + } + public ulong totalUp + { + get; set; + } + public ulong totalDown + { + get; set; + } + public ulong todayUp + { + get; set; + } + public ulong todayDown + { + get; set; + } + public long dateNow + { + get; set; } } } diff --git a/v2rayN/v2rayN/Properties/AssemblyInfo.cs b/v2rayN/v2rayN/Properties/AssemblyInfo.cs index f9c5bb20..498bb62d 100644 --- a/v2rayN/v2rayN/Properties/AssemblyInfo.cs +++ b/v2rayN/v2rayN/Properties/AssemblyInfo.cs @@ -33,4 +33,4 @@ using System.Runtime.InteropServices; // 方法是按如下所示使用“*”: //[assembly: AssemblyVersion("1.0.*")] //[assembly: AssemblyVersion("1.0.0")] -[assembly: AssemblyFileVersion("2.50")] +[assembly: AssemblyFileVersion("2.51")] diff --git a/v2rayN/v2rayN/Tool/Utils.cs b/v2rayN/v2rayN/Tool/Utils.cs index 2dd6acbf..46f1cec8 100644 --- a/v2rayN/v2rayN/Tool/Utils.cs +++ b/v2rayN/v2rayN/Tool/Utils.cs @@ -443,15 +443,6 @@ namespace v2rayN return Regex.IsMatch(input, pattern, RegexOptions.IgnoreCase); } - public static bool IsIdenticalServer(Mode.ServerStatistics a, Mode.ServerStatistics b) - { - return (a.address == b.address - && a.port == b.port - && a.path == b.path - && a.host == b.host - ); - } - #endregion #region 开机自动启动