mirror of
https://github.com/netchx/netch.git
synced 2026-03-18 18:13:21 +08:00
✨ 流量统计回归
🎨 新增了防止小白因为各种启动失败来找麻烦的提示框 ⬆️ 更新v2ray core to v4.25.1 ⬆️ 更新规则
This commit is contained in:
@@ -14,8 +14,8 @@ namespace Netch.Controllers
|
||||
|
||||
private const int DefaultGetTimeout = 30000;
|
||||
|
||||
private const string Owner = @"NetchX";
|
||||
private const string Repo = @"Netch";
|
||||
public const string Owner = @"NetchX";
|
||||
public const string Repo = @"Netch";
|
||||
|
||||
public string LatestVersionNumber;
|
||||
public string LatestVersionUrl;
|
||||
@@ -26,7 +26,7 @@ namespace Netch.Controllers
|
||||
|
||||
public const string Name = @"Netch";
|
||||
public const string Copyright = @"Copyright © 2019 - 2020";
|
||||
public const string Version = @"1.4.10";
|
||||
public const string Version = @"1.4.11";
|
||||
|
||||
public async void Check(bool notifyNoFound, bool isPreRelease)
|
||||
{
|
||||
|
||||
74
Netch/Forms/MainForm.Designer.cs
generated
74
Netch/Forms/MainForm.Designer.cs
generated
@@ -39,6 +39,7 @@ namespace Netch.Forms
|
||||
this.AddShadowsocksServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.AddShadowsocksRServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.AddVMessServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.AddTrojanServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ModeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.CreateProcessModeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ManageProcessModeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -56,6 +57,7 @@ namespace Netch.Forms
|
||||
this.AboutToolStripButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.VersionLabel = new System.Windows.Forms.ToolStripLabel();
|
||||
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.RelyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ConfigurationGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.configLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.ProfileLabel = new System.Windows.Forms.Label();
|
||||
@@ -86,7 +88,6 @@ namespace Netch.Forms
|
||||
this.SettingsButton = new System.Windows.Forms.Button();
|
||||
this.ProfileGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.ProfileTable = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.AddTrojanServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.MenuStrip.SuspendLayout();
|
||||
this.ConfigurationGroupBox.SuspendLayout();
|
||||
this.configLayoutPanel.SuspendLayout();
|
||||
@@ -114,11 +115,12 @@ namespace Netch.Forms
|
||||
this.OptionsToolStripMenuItem,
|
||||
this.AboutToolStripButton,
|
||||
this.VersionLabel,
|
||||
this.exitToolStripMenuItem});
|
||||
this.exitToolStripMenuItem,
|
||||
this.RelyToolStripMenuItem});
|
||||
this.MenuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.MenuStrip.Name = "MenuStrip";
|
||||
this.MenuStrip.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
|
||||
this.MenuStrip.Size = new System.Drawing.Size(629, 26);
|
||||
this.MenuStrip.Size = new System.Drawing.Size(733, 26);
|
||||
this.MenuStrip.TabIndex = 0;
|
||||
//
|
||||
// ServerToolStripMenuItem
|
||||
@@ -170,6 +172,13 @@ namespace Netch.Forms
|
||||
this.AddVMessServerToolStripMenuItem.Text = "Add [VMess] Server";
|
||||
this.AddVMessServerToolStripMenuItem.Click += new System.EventHandler(this.AddVMessServerToolStripMenuItem_Click);
|
||||
//
|
||||
// AddTrojanServerToolStripMenuItem
|
||||
//
|
||||
this.AddTrojanServerToolStripMenuItem.Name = "AddTrojanServerToolStripMenuItem";
|
||||
this.AddTrojanServerToolStripMenuItem.Size = new System.Drawing.Size(259, 22);
|
||||
this.AddTrojanServerToolStripMenuItem.Text = "Add [Trojan] Server";
|
||||
this.AddTrojanServerToolStripMenuItem.Click += new System.EventHandler(this.AddTrojanServerToolStripMenuItem_Click);
|
||||
//
|
||||
// ModeToolStripMenuItem
|
||||
//
|
||||
this.ModeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
@@ -236,49 +245,49 @@ namespace Netch.Forms
|
||||
// ReloadModesToolStripMenuItem
|
||||
//
|
||||
this.ReloadModesToolStripMenuItem.Name = "ReloadModesToolStripMenuItem";
|
||||
this.ReloadModesToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
|
||||
this.ReloadModesToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
|
||||
this.ReloadModesToolStripMenuItem.Text = "Reload Modes";
|
||||
this.ReloadModesToolStripMenuItem.Click += new System.EventHandler(this.ReloadModesToolStripMenuItem_Click);
|
||||
//
|
||||
// RestartServiceToolStripMenuItem
|
||||
//
|
||||
this.RestartServiceToolStripMenuItem.Name = "RestartServiceToolStripMenuItem";
|
||||
this.RestartServiceToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
|
||||
this.RestartServiceToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
|
||||
this.RestartServiceToolStripMenuItem.Text = "Restart Service";
|
||||
this.RestartServiceToolStripMenuItem.Click += new System.EventHandler(this.RestartServiceToolStripMenuItem_Click);
|
||||
//
|
||||
// UninstallServiceToolStripMenuItem
|
||||
//
|
||||
this.UninstallServiceToolStripMenuItem.Name = "UninstallServiceToolStripMenuItem";
|
||||
this.UninstallServiceToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
|
||||
this.UninstallServiceToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
|
||||
this.UninstallServiceToolStripMenuItem.Text = "Uninstall Service";
|
||||
this.UninstallServiceToolStripMenuItem.Click += new System.EventHandler(this.UninstallServiceToolStripMenuItem_Click);
|
||||
//
|
||||
// CleanDNSCacheToolStripMenuItem
|
||||
//
|
||||
this.CleanDNSCacheToolStripMenuItem.Name = "CleanDNSCacheToolStripMenuItem";
|
||||
this.CleanDNSCacheToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
|
||||
this.CleanDNSCacheToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
|
||||
this.CleanDNSCacheToolStripMenuItem.Text = "Clean DNS Cache";
|
||||
this.CleanDNSCacheToolStripMenuItem.Click += new System.EventHandler(this.CleanDNSCacheToolStripMenuItem_Click);
|
||||
//
|
||||
// UpdateACLToolStripMenuItem
|
||||
//
|
||||
this.UpdateACLToolStripMenuItem.Name = "UpdateACLToolStripMenuItem";
|
||||
this.UpdateACLToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
|
||||
this.UpdateACLToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
|
||||
this.UpdateACLToolStripMenuItem.Text = "Update ACL";
|
||||
this.UpdateACLToolStripMenuItem.Click += new System.EventHandler(this.updateACLToolStripMenuItem_Click);
|
||||
//
|
||||
// updateACLWithProxyToolStripMenuItem
|
||||
//
|
||||
this.updateACLWithProxyToolStripMenuItem.Name = "updateACLWithProxyToolStripMenuItem";
|
||||
this.updateACLWithProxyToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
|
||||
this.updateACLWithProxyToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
|
||||
this.updateACLWithProxyToolStripMenuItem.Text = "Update ACL with proxy";
|
||||
this.updateACLWithProxyToolStripMenuItem.Click += new System.EventHandler(this.updateACLWithProxyToolStripMenuItem_Click);
|
||||
//
|
||||
// reinstallTapDriverToolStripMenuItem
|
||||
//
|
||||
this.reinstallTapDriverToolStripMenuItem.Name = "reinstallTapDriverToolStripMenuItem";
|
||||
this.reinstallTapDriverToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
|
||||
this.reinstallTapDriverToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
|
||||
this.reinstallTapDriverToolStripMenuItem.Text = "Reinstall TUN/TAP driver";
|
||||
this.reinstallTapDriverToolStripMenuItem.Click += new System.EventHandler(this.reinstallTapDriverToolStripMenuItem_Click);
|
||||
//
|
||||
@@ -300,8 +309,8 @@ namespace Netch.Forms
|
||||
this.VersionLabel.IsLink = true;
|
||||
this.VersionLabel.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline;
|
||||
this.VersionLabel.Name = "VersionLabel";
|
||||
this.VersionLabel.Size = new System.Drawing.Size(32, 19);
|
||||
this.VersionLabel.Text = "x.x.x";
|
||||
this.VersionLabel.Size = new System.Drawing.Size(26, 19);
|
||||
this.VersionLabel.Text = "xxx";
|
||||
this.VersionLabel.Click += new System.EventHandler(this.VersionLabel_Click);
|
||||
//
|
||||
// exitToolStripMenuItem
|
||||
@@ -311,12 +320,21 @@ namespace Netch.Forms
|
||||
this.exitToolStripMenuItem.Text = "Exit";
|
||||
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
||||
//
|
||||
// RelyToolStripMenuItem
|
||||
//
|
||||
this.RelyToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.RelyToolStripMenuItem.ForeColor = System.Drawing.Color.Red;
|
||||
this.RelyToolStripMenuItem.Name = "RelyToolStripMenuItem";
|
||||
this.RelyToolStripMenuItem.Size = new System.Drawing.Size(244, 22);
|
||||
this.RelyToolStripMenuItem.Text = "Unable to start? Click me to download";
|
||||
this.RelyToolStripMenuItem.Click += new System.EventHandler(this.RelyToolStripMenuItem_Click);
|
||||
//
|
||||
// ConfigurationGroupBox
|
||||
//
|
||||
this.ConfigurationGroupBox.Controls.Add(this.configLayoutPanel);
|
||||
this.ConfigurationGroupBox.Location = new System.Drawing.Point(12, 28);
|
||||
this.ConfigurationGroupBox.Name = "ConfigurationGroupBox";
|
||||
this.ConfigurationGroupBox.Size = new System.Drawing.Size(605, 115);
|
||||
this.ConfigurationGroupBox.Size = new System.Drawing.Size(709, 115);
|
||||
this.ConfigurationGroupBox.TabIndex = 1;
|
||||
this.ConfigurationGroupBox.TabStop = false;
|
||||
this.ConfigurationGroupBox.Text = "Configuration";
|
||||
@@ -342,7 +360,7 @@ namespace Netch.Forms
|
||||
this.configLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
|
||||
this.configLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
|
||||
this.configLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
|
||||
this.configLayoutPanel.Size = new System.Drawing.Size(599, 93);
|
||||
this.configLayoutPanel.Size = new System.Drawing.Size(703, 93);
|
||||
this.configLayoutPanel.TabIndex = 15;
|
||||
//
|
||||
// ProfileLabel
|
||||
@@ -380,7 +398,7 @@ namespace Netch.Forms
|
||||
this.ProfileNameText.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.ProfileNameText.Location = new System.Drawing.Point(54, 65);
|
||||
this.ProfileNameText.Name = "ProfileNameText";
|
||||
this.ProfileNameText.Size = new System.Drawing.Size(442, 23);
|
||||
this.ProfileNameText.Size = new System.Drawing.Size(546, 23);
|
||||
this.ProfileNameText.TabIndex = 11;
|
||||
//
|
||||
// ModeComboBox
|
||||
@@ -392,7 +410,7 @@ namespace Netch.Forms
|
||||
this.ModeComboBox.IntegralHeight = false;
|
||||
this.ModeComboBox.Location = new System.Drawing.Point(54, 34);
|
||||
this.ModeComboBox.Name = "ModeComboBox";
|
||||
this.ModeComboBox.Size = new System.Drawing.Size(442, 24);
|
||||
this.ModeComboBox.Size = new System.Drawing.Size(546, 24);
|
||||
this.ModeComboBox.TabIndex = 2;
|
||||
this.ModeComboBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.ComboBox_DrawItem);
|
||||
//
|
||||
@@ -406,7 +424,7 @@ namespace Netch.Forms
|
||||
this.ServerComboBox.Location = new System.Drawing.Point(54, 3);
|
||||
this.ServerComboBox.MaxDropDownItems = 16;
|
||||
this.ServerComboBox.Name = "ServerComboBox";
|
||||
this.ServerComboBox.Size = new System.Drawing.Size(442, 24);
|
||||
this.ServerComboBox.Size = new System.Drawing.Size(546, 24);
|
||||
this.ServerComboBox.TabIndex = 1;
|
||||
this.ServerComboBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.ComboBox_DrawItem);
|
||||
//
|
||||
@@ -421,7 +439,7 @@ namespace Netch.Forms
|
||||
this.tableLayoutPanel2.Controls.Add(this.CopyLinkPictureBox, 3, 0);
|
||||
this.tableLayoutPanel2.Controls.Add(this.DeletePictureBox, 1, 0);
|
||||
this.tableLayoutPanel2.Controls.Add(this.SpeedPictureBox, 2, 0);
|
||||
this.tableLayoutPanel2.Location = new System.Drawing.Point(502, 3);
|
||||
this.tableLayoutPanel2.Location = new System.Drawing.Point(606, 3);
|
||||
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
|
||||
this.tableLayoutPanel2.RowCount = 1;
|
||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
@@ -481,7 +499,7 @@ namespace Netch.Forms
|
||||
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
|
||||
this.tableLayoutPanel3.Controls.Add(this.EditModePictureBox, 0, 0);
|
||||
this.tableLayoutPanel3.Controls.Add(this.DeleteModePictureBox, 1, 0);
|
||||
this.tableLayoutPanel3.Location = new System.Drawing.Point(502, 34);
|
||||
this.tableLayoutPanel3.Location = new System.Drawing.Point(606, 34);
|
||||
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
|
||||
this.tableLayoutPanel3.RowCount = 1;
|
||||
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
@@ -523,7 +541,7 @@ namespace Netch.Forms
|
||||
this.NatTypeStatusLabel});
|
||||
this.StatusStrip.Location = new System.Drawing.Point(0, 250);
|
||||
this.StatusStrip.Name = "StatusStrip";
|
||||
this.StatusStrip.Size = new System.Drawing.Size(629, 22);
|
||||
this.StatusStrip.Size = new System.Drawing.Size(733, 22);
|
||||
this.StatusStrip.SizingGrip = false;
|
||||
this.StatusStrip.TabIndex = 2;
|
||||
//
|
||||
@@ -563,7 +581,7 @@ namespace Netch.Forms
|
||||
// ControlButton
|
||||
//
|
||||
this.ControlButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.ControlButton.Location = new System.Drawing.Point(542, 215);
|
||||
this.ControlButton.Location = new System.Drawing.Point(646, 214);
|
||||
this.ControlButton.Name = "ControlButton";
|
||||
this.ControlButton.Size = new System.Drawing.Size(75, 27);
|
||||
this.ControlButton.TabIndex = 3;
|
||||
@@ -619,7 +637,7 @@ namespace Netch.Forms
|
||||
this.ProfileGroupBox.Controls.Add(this.ProfileTable);
|
||||
this.ProfileGroupBox.Location = new System.Drawing.Point(12, 146);
|
||||
this.ProfileGroupBox.Name = "ProfileGroupBox";
|
||||
this.ProfileGroupBox.Size = new System.Drawing.Size(605, 65);
|
||||
this.ProfileGroupBox.Size = new System.Drawing.Size(709, 65);
|
||||
this.ProfileGroupBox.TabIndex = 13;
|
||||
this.ProfileGroupBox.TabStop = false;
|
||||
this.ProfileGroupBox.Text = "Profiles";
|
||||
@@ -637,21 +655,14 @@ namespace Netch.Forms
|
||||
this.ProfileTable.RowCount = 1;
|
||||
this.ProfileTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.ProfileTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.ProfileTable.Size = new System.Drawing.Size(599, 43);
|
||||
this.ProfileTable.Size = new System.Drawing.Size(703, 43);
|
||||
this.ProfileTable.TabIndex = 0;
|
||||
//
|
||||
// AddTrojanServerToolStripMenuItem
|
||||
//
|
||||
this.AddTrojanServerToolStripMenuItem.Name = "AddTrojanServerToolStripMenuItem";
|
||||
this.AddTrojanServerToolStripMenuItem.Size = new System.Drawing.Size(259, 22);
|
||||
this.AddTrojanServerToolStripMenuItem.Text = "Add [Trojan] Server";
|
||||
this.AddTrojanServerToolStripMenuItem.Click += new System.EventHandler(this.AddTrojanServerToolStripMenuItem_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.ClientSize = new System.Drawing.Size(629, 272);
|
||||
this.ClientSize = new System.Drawing.Size(733, 272);
|
||||
this.Controls.Add(this.ProfileGroupBox);
|
||||
this.Controls.Add(this.SettingsButton);
|
||||
this.Controls.Add(this.ControlButton);
|
||||
@@ -748,5 +759,6 @@ namespace Netch.Forms
|
||||
private System.Windows.Forms.ToolStripMenuItem updateACLWithProxyToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem reinstallTapDriverToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem AddTrojanServerToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem RelyToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
@@ -260,7 +260,7 @@ namespace Netch.Forms
|
||||
private void SaveConfigs()
|
||||
{
|
||||
Global.Settings.ServerComboBoxSelectedIndex = ServerComboBox.SelectedIndex;
|
||||
if (ModeComboBox.Items.Count!=0 && ModeComboBox.SelectedItem != null)
|
||||
if (ModeComboBox.Items.Count != 0 && ModeComboBox.SelectedItem != null)
|
||||
{
|
||||
|
||||
if (ModeComboBox.Tag is object[] list)
|
||||
@@ -382,6 +382,7 @@ namespace Netch.Forms
|
||||
StatusLabel.Text = $@"{Utils.i18N.Translate("Status")}{Utils.i18N.Translate(": ")}{Utils.i18N.Translate("Waiting for command")}";
|
||||
ShowMainFormToolStripButton.Text = Utils.i18N.Translate(ShowMainFormToolStripButton.Text);
|
||||
ExitToolStripButton.Text = Utils.i18N.Translate(ExitToolStripButton.Text);
|
||||
RelyToolStripMenuItem.Text = Utils.i18N.Translate(RelyToolStripMenuItem.Text);
|
||||
|
||||
InitProfile();
|
||||
|
||||
@@ -749,7 +750,7 @@ namespace Netch.Forms
|
||||
|
||||
private void VersionLabel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Process.Start("https://github.com/NetchX/Netch/releases");
|
||||
Process.Start($"https://github.com/{UpdateChecker.Owner}/{UpdateChecker.Repo}/releases");
|
||||
}
|
||||
|
||||
private void EditPictureBox_Click(object sender, EventArgs e)
|
||||
@@ -879,8 +880,20 @@ namespace Netch.Forms
|
||||
|
||||
if (startResult)
|
||||
{
|
||||
// UsedBandwidthLabel.Visible = UploadSpeedLabel.Visible = DownloadSpeedLabel.Visible = true;
|
||||
// MainController.pNFController.OnBandwidthUpdated += OnBandwidthUpdated;
|
||||
Task.Run(() =>
|
||||
{
|
||||
LastUploadBandwidth = 0;
|
||||
//LastDownloadBandwidth = 0;
|
||||
//UploadSpeedLabel.Text = "↑: 0 KB/s";
|
||||
DownloadSpeedLabel.Text = "↑↓: 0 KB/s";
|
||||
UsedBandwidthLabel.Text = $"{Utils.i18N.Translate("Used")}{Utils.i18N.Translate(": ")}0 KB";
|
||||
UsedBandwidthLabel.Visible = UploadSpeedLabel.Visible = DownloadSpeedLabel.Visible = true;
|
||||
|
||||
|
||||
UploadSpeedLabel.Visible = false;
|
||||
Bandwidth.NetTraffic(server, mode, MainController);
|
||||
});
|
||||
//MainController.pNFController.OnBandwidthUpdated += OnBandwidthUpdated;
|
||||
|
||||
// 如果勾选启动后最小化
|
||||
if (Global.Settings.MinimizeWhenStarted)
|
||||
@@ -1010,12 +1023,12 @@ namespace Netch.Forms
|
||||
MainController.Stop();
|
||||
NatTypeStatusLabel.Text = "";
|
||||
|
||||
// LastUploadBandwidth = 0;
|
||||
// LastDownloadBandwidth = 0;
|
||||
// UploadSpeedLabel.Text = "↑: 0 KB/s";
|
||||
// DownloadSpeedLabel.Text = "↓: 0 KB/s";
|
||||
// UsedBandwidthLabel.Text = $"{Utils.i18N.Translate("Used")}{Utils.i18N.Translate(": ")}0 KB";
|
||||
// UsedBandwidthLabel.Visible = UploadSpeedLabel.Visible = DownloadSpeedLabel.Visible = false;
|
||||
LastUploadBandwidth = 0;
|
||||
LastDownloadBandwidth = 0;
|
||||
UploadSpeedLabel.Text = "↑: 0 KB/s";
|
||||
DownloadSpeedLabel.Text = "↓: 0 KB/s";
|
||||
UsedBandwidthLabel.Text = $"{Utils.i18N.Translate("Used")}{Utils.i18N.Translate(": ")}0 KB";
|
||||
UsedBandwidthLabel.Visible = UploadSpeedLabel.Visible = DownloadSpeedLabel.Visible = false;
|
||||
|
||||
ControlButton.Enabled = true;
|
||||
ProfileGroupBox.Enabled = true;
|
||||
@@ -1106,16 +1119,42 @@ namespace Netch.Forms
|
||||
new AboutForm().Show();
|
||||
Hide();
|
||||
}
|
||||
public void OnBandwidthUpdated(long download)
|
||||
{
|
||||
try
|
||||
{
|
||||
UsedBandwidthLabel.Text = $"{Utils.i18N.Translate("Used")}{Utils.i18N.Translate(": ")}{Utils.Bandwidth.Compute(download)}";
|
||||
//UploadSpeedLabel.Text = $"↑: {Utils.Bandwidth.Compute(upload - LastUploadBandwidth)}/s";
|
||||
DownloadSpeedLabel.Text = $"↑↓: {Utils.Bandwidth.Compute(download - LastDownloadBandwidth)}/s";
|
||||
|
||||
//LastUploadBandwidth = upload;
|
||||
LastDownloadBandwidth = download;
|
||||
Refresh();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void OnBandwidthUpdated(long upload, long download)
|
||||
{
|
||||
UsedBandwidthLabel.Text = $"{Utils.i18N.Translate("Used")}{Utils.i18N.Translate(": ")}{Utils.Bandwidth.Compute(upload + download)}";
|
||||
UploadSpeedLabel.Text = $"↑: {Utils.Bandwidth.Compute(upload - LastUploadBandwidth)}/s";
|
||||
DownloadSpeedLabel.Text = $"↓: {Utils.Bandwidth.Compute(download - LastDownloadBandwidth)}/s";
|
||||
try
|
||||
{
|
||||
if (upload < 1 || download < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
UsedBandwidthLabel.Text = $"{Utils.i18N.Translate("Used")}{Utils.i18N.Translate(": ")}{Utils.Bandwidth.Compute(upload + download)}";
|
||||
UploadSpeedLabel.Text = $"↑: {Utils.Bandwidth.Compute(upload - LastUploadBandwidth)}/s";
|
||||
DownloadSpeedLabel.Text = $"↓: {Utils.Bandwidth.Compute(download - LastDownloadBandwidth)}/s";
|
||||
|
||||
LastUploadBandwidth = upload;
|
||||
LastDownloadBandwidth = download;
|
||||
Refresh();
|
||||
LastUploadBandwidth = upload;
|
||||
LastDownloadBandwidth = download;
|
||||
Refresh();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void ProfileButton_Click(object sender, EventArgs e)
|
||||
@@ -1372,6 +1411,7 @@ namespace Netch.Forms
|
||||
NatTypeStatusLabel.Visible = true;
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
text = text.Trim();
|
||||
NatTypeStatusLabel.Text = "NAT" + Utils.i18N.Translate(": ") + text;
|
||||
}
|
||||
else
|
||||
@@ -1523,5 +1563,10 @@ namespace Netch.Forms
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void RelyToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Process.Start($"https://mega.nz/file/9OQ1EazJ#0pjJ3xt57AVLr29vYEEv15GSACtXVQOGlEOPpi_2Ico");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ini-parser" Version="2.5.2" />
|
||||
<PackageReference Include="MaxMind.GeoIP2" Version="3.2.0" />
|
||||
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.56" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="System.Buffers" Version="4.5.1" />
|
||||
<PackageReference Include="WindowsAPICodePack-Shell" Version="1.1.1" />
|
||||
@@ -97,6 +98,6 @@
|
||||
</ItemGroup>
|
||||
<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="@ECHO OFF
RD /S /Q $(TargetDir)bin > NUL 2>&1
RD /S /Q $(TargetDir)i18n > NUL 2>&1
RD /S /Q $(TargetDir)mode > NUL 2>&1

MKDIR $(TargetDir)bin > NUL 2>&1
MKDIR $(TargetDir)i18n > NUL 2>&1
MKDIR $(TargetDir)mode > NUL 2>&1

COPY /Y $(SolutionDir)binaries\* $(TargetDir)bin > NUL 2>&1
COPY /Y $(SolutionDir)translations\i18n\* $(TargetDir)i18n > NUL 2>&1
COPY /Y $(SolutionDir)modes\mode\* $(TargetDir)mode > NUL 2>&1
MKDIR $(TargetDir)bin\tap-driver > NUL 2>&1
COPY /Y $(SolutionDir)binaries\tap-driver\* $(TargetDir)bin\tap-driver > NUL 2>&1

DEL / f $(TargetDir)\*.config
DEL / f $(TargetDir)\*.pdb" />
|
||||
<Exec Command="@ECHO OFF
RD /S /Q $(TargetDir)bin > NUL 2>&1
RD /S /Q $(TargetDir)i18n > NUL 2>&1
RD /S /Q $(TargetDir)mode > NUL 2>&1

MKDIR $(TargetDir)bin > NUL 2>&1
MKDIR $(TargetDir)i18n > NUL 2>&1
MKDIR $(TargetDir)mode > NUL 2>&1

COPY /Y $(SolutionDir)binaries\* $(TargetDir)bin > NUL 2>&1
COPY /Y $(SolutionDir)translations\i18n\* $(TargetDir)i18n > NUL 2>&1
COPY /Y $(SolutionDir)modes\mode\* $(TargetDir)mode > NUL 2>&1
MKDIR $(TargetDir)bin\tap-driver > NUL 2>&1
COPY /Y $(SolutionDir)binaries\tap-driver\* $(TargetDir)bin\tap-driver > NUL 2>&1

DEL / f $(TargetDir)\*.config
DEL / f $(TargetDir)\*.pdb
RD /s /Q $(TargetDir)\x86" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
@@ -187,6 +187,7 @@
|
||||
|
||||
"Show": "显示",
|
||||
"Exit": "退出",
|
||||
"Unable to start? Click me to download": "无法启动?点我下载依赖",
|
||||
|
||||
"Bypass LAN": "[网页代理] 绕过局域网",
|
||||
"Bypass LAN (Non System Proxy)": "[网页代理] 绕过局域网(不设置系统代理)",
|
||||
|
||||
@@ -1,7 +1,20 @@
|
||||
namespace Netch.Utils
|
||||
using Microsoft.Diagnostics.Tracing.Parsers;
|
||||
using Microsoft.Diagnostics.Tracing.Session;
|
||||
using Netch.Controllers;
|
||||
using Netch.Forms;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Netch.Utils
|
||||
{
|
||||
public static class Bandwidth
|
||||
{
|
||||
public static int received = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 计算流量
|
||||
/// </summary>
|
||||
@@ -18,7 +31,105 @@
|
||||
i++;
|
||||
} while ((result /= 1024) > 1024);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return string.Format("{0} {1}", System.Math.Round(result, 2), units[i]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据程序名统计流量
|
||||
/// </summary>
|
||||
/// <param name="ProcessName"></param>
|
||||
public static void NetTraffic(Models.Server server, Models.Mode mode, MainController mainController)
|
||||
{
|
||||
var counterLock = new object();
|
||||
//int sent = 0;
|
||||
|
||||
//var processList = Process.GetProcessesByName(ProcessName).Select(p => p.Id).ToHashSet();
|
||||
List<int> processList = new List<int>();
|
||||
|
||||
if (server.Type.Equals("Socks5") && mainController.pHTTPController != null)
|
||||
{
|
||||
processList.Add(mainController.pHTTPController.pPrivoxyController.Instance.Id);
|
||||
}
|
||||
else if (server.Type.Equals("SS") && Global.Settings.BootShadowsocksFromDLL)
|
||||
{
|
||||
processList.Add(Process.GetCurrentProcess().Id);
|
||||
}
|
||||
else if (server.Type.Equals("SS") && mainController.pSSController != null)
|
||||
{
|
||||
processList.Add(mainController.pSSController.Instance.Id);
|
||||
}
|
||||
else if (server.Type.Equals("SSR") && mainController.pSSRController != null)
|
||||
{
|
||||
processList.Add(mainController.pSSRController.Instance.Id);
|
||||
}
|
||||
else if (server.Type.Equals("VMess") && mainController.pVMessController != null)
|
||||
{
|
||||
processList.Add(mainController.pVMessController.Instance.Id);
|
||||
}
|
||||
else if (server.Type.Equals("TR") && mainController.pTrojanController != null)
|
||||
{
|
||||
processList.Add(mainController.pTrojanController.Instance.Id);
|
||||
}
|
||||
else if (mainController.pTUNTAPController != null)
|
||||
{
|
||||
processList.Add(mainController.pTUNTAPController.Instance.Id);
|
||||
}
|
||||
else if (mainController.pNFController != null)
|
||||
{
|
||||
processList.Add(mainController.pNFController.Instance.Id);
|
||||
}
|
||||
Logging.Info("启动流量统计 PID:" + string.Join(",", processList.ToArray()));
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
using (var session = new TraceEventSession("KernelAndClrEventsSession"))
|
||||
{
|
||||
session.EnableKernelProvider(KernelTraceEventParser.Keywords.NetworkTCPIP);
|
||||
|
||||
//这玩意儿上传和下载得到的data是一样的:)
|
||||
//所以暂时没办法区分上传下载流量
|
||||
session.Source.Kernel.TcpIpRecv += data =>
|
||||
{
|
||||
if (processList.Contains(data.ProcessID))
|
||||
{
|
||||
lock (counterLock)
|
||||
received += data.size;
|
||||
//Logging.Info($"TcpIpRecv: {Compute(data.size)}");
|
||||
}
|
||||
};
|
||||
session.Source.Kernel.UdpIpRecv += data =>
|
||||
{
|
||||
if (processList.Contains(data.ProcessID))
|
||||
{
|
||||
lock (counterLock)
|
||||
received += data.size;
|
||||
//Logging.Info($"UdpIpRecv: {Compute(data.size)}");
|
||||
}
|
||||
};
|
||||
|
||||
session.Source.Process();
|
||||
}
|
||||
});
|
||||
|
||||
if ((Convert.ToInt32(MainForm.Instance.LastDownloadBandwidth) - Convert.ToInt32(received)) == 0)
|
||||
{
|
||||
MainForm.Instance.OnBandwidthUpdated(0);
|
||||
received = 0;
|
||||
}
|
||||
while (MainForm.Instance.State != Models.State.Stopped)
|
||||
{
|
||||
Task.Delay(1000).Wait();
|
||||
lock (counterLock)
|
||||
{
|
||||
MainForm.Instance.OnBandwidthUpdated(Convert.ToInt64(received));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,49 +26,49 @@ namespace Netch.Utils
|
||||
/// </summary>
|
||||
public static void Load()
|
||||
{
|
||||
if (Directory.Exists(DATA_DIR))
|
||||
if (Directory.Exists(DATA_DIR) && File.Exists(SETTINGS_JSON))
|
||||
{
|
||||
if (File.Exists(SETTINGS_JSON))
|
||||
try
|
||||
{
|
||||
try
|
||||
Global.Settings = Newtonsoft.Json.JsonConvert.DeserializeObject<Models.Setting>(File.ReadAllText(SETTINGS_JSON));
|
||||
if (Global.Settings.Server != null && Global.Settings.Server.Count > 0)
|
||||
{
|
||||
Global.Settings = Newtonsoft.Json.JsonConvert.DeserializeObject<Models.Setting>(File.ReadAllText(SETTINGS_JSON));
|
||||
if (Global.Settings.Server != null && Global.Settings.Server.Count > 0)
|
||||
// 如果是旧版 Server 类,使用旧版 Server 类进行读取
|
||||
if (Global.Settings.Server[0].Hostname == null)
|
||||
{
|
||||
// 如果是旧版 Server 类,使用旧版 Server 类进行读取
|
||||
if (Global.Settings.Server[0].Hostname == null)
|
||||
var LegacySettingConfig = Newtonsoft.Json.JsonConvert.DeserializeObject<Models.LegacySetting>(File.ReadAllText(SETTINGS_JSON));
|
||||
for (var i = 0; i < LegacySettingConfig.Server.Count; i++)
|
||||
{
|
||||
var LegacySettingConfig = Newtonsoft.Json.JsonConvert.DeserializeObject<Models.LegacySetting>(File.ReadAllText(SETTINGS_JSON));
|
||||
for (var i = 0; i < LegacySettingConfig.Server.Count; i++)
|
||||
Global.Settings.Server[i].Hostname = LegacySettingConfig.Server[i].Address;
|
||||
if (Global.Settings.Server[i].Type == "Shadowsocks")
|
||||
{
|
||||
Global.Settings.Server[i].Hostname = LegacySettingConfig.Server[i].Address;
|
||||
if (Global.Settings.Server[i].Type == "Shadowsocks")
|
||||
{
|
||||
Global.Settings.Server[i].Type = "SS";
|
||||
Global.Settings.Server[i].Plugin = LegacySettingConfig.Server[i].OBFS;
|
||||
Global.Settings.Server[i].PluginOption = LegacySettingConfig.Server[i].OBFSParam;
|
||||
}
|
||||
else if (Global.Settings.Server[i].Type == "ShadowsocksR")
|
||||
{
|
||||
Global.Settings.Server[i].Type = "SSR";
|
||||
}
|
||||
else if (Global.Settings.Server[i].Type == "VMess")
|
||||
{
|
||||
Global.Settings.Server[i].QUICSecure = LegacySettingConfig.Server[i].QUICSecurity;
|
||||
}
|
||||
Global.Settings.Server[i].Type = "SS";
|
||||
Global.Settings.Server[i].Plugin = LegacySettingConfig.Server[i].OBFS;
|
||||
Global.Settings.Server[i].PluginOption = LegacySettingConfig.Server[i].OBFSParam;
|
||||
}
|
||||
else if (Global.Settings.Server[i].Type == "ShadowsocksR")
|
||||
{
|
||||
Global.Settings.Server[i].Type = "SSR";
|
||||
}
|
||||
else if (Global.Settings.Server[i].Type == "VMess")
|
||||
{
|
||||
Global.Settings.Server[i].QUICSecure = LegacySettingConfig.Server[i].QUICSecurity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (Newtonsoft.Json.JsonException)
|
||||
{
|
||||
catch (Newtonsoft.Json.JsonException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 弹出提示
|
||||
MessageBox.Show("如果你是第一次使用本软件\n请务必前往http://netch.org 安装程序所需依赖,\n否则程序将无法正常运行!", i18N.Translate("注意!"), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
// 创建 data 文件夹并保存默认设置
|
||||
Save();
|
||||
}
|
||||
|
||||
2
binaries
2
binaries
Submodule binaries updated: 385188a7b6...f93cebfb75
2
modes
2
modes
Submodule modes updated: 5ed034a88b...f0327e9399
Reference in New Issue
Block a user