Compare commits

...

24 Commits

Author SHA1 Message Date
Amazing_DM
40f74252a9 流量统计回归
🎨 新增了防止小白因为各种启动失败来找麻烦的提示框
⬆️ 更新v2ray core to v4.25.1
⬆️ 更新规则
2020-07-01 13:23:16 +08:00
AmazingDM
47044548b1 Update README.md 2020-06-30 17:01:03 +08:00
AmazingDM
2f74c36b26 Merge pull request #284 from zhibinr/patch-1
Update Quickstart.zh-CN.md
2020-06-29 23:32:18 +08:00
zhibinr
9665e6c788 Update Quickstart.zh-CN.md 2020-06-29 21:29:53 +08:00
AmazingDM
c2cf338931 Update UpdateChecker.cs 2020-06-23 14:15:31 +08:00
Amazing_DM
b41ab4d25e 🐛Update submodule
⬆️更新v2ray-core to  4.25.0
⬆️更新部分规则
2020-06-23 14:13:21 +08:00
AmazingDM
be0770d81b Update README.zh-CN.md 2020-06-12 17:00:29 +08:00
Amazing_DM
6106cb4878 Update submodule 2020-06-12 10:47:21 +08:00
AmazingDM
b1202b47eb Update README.md 2020-06-12 10:29:22 +08:00
Amazing_DM
da54abda3d Update README.md 2020-06-04 16:58:28 +08:00
Amazing_DM
d0f604eb42 Update README.md 2020-06-04 13:01:01 +08:00
Amazing_DM
957222cc7b Update README.md 2020-06-04 12:55:37 +08:00
Amazing_DM
6dd26574e0 Update README.md 2020-06-04 12:45:21 +08:00
Amazing_DM
9e8659a8ea 添加语言设置
🎨优化电源监听逻辑
2020-06-03 10:12:08 +08:00
Amazing_DM
e7daef1226 Update submodule 2020-06-01 11:33:14 +08:00
Amazing_DM
e77b551e68 Merge pull request #279 from xiejx5/patch-1
Fix the failure of visiting google.com in 0 mode
2020-06-01 11:27:51 +08:00
xiejx5
16d9cb77ce Fix the failure of visiting google.com in 0 mode 2020-06-01 01:51:57 +08:00
Amazing_DM
6b872701a4 Merge pull request #278 from NormanBB/master
修改文档细节
2020-05-31 13:00:36 +08:00
NormanBB
f1e39102f5 修改文档细节 2020-05-31 02:04:28 +00:00
Amazing_DM
bd6e8d4d76 Update submodule 2020-05-26 11:53:53 +08:00
Amazing_DM
e893b4e5d4 Merge pull request #276 from zhuzai123/master
Update TUNTAPController.cs
2020-05-26 11:53:20 +08:00
Amazing_DM
d67b219e4a Update Server.cs 2020-05-25 14:23:54 +08:00
Amazing_DM
166bf6a53e Update submodule 2020-05-25 12:00:53 +08:00
HHZ
c7d6dee6c3 Update TUNTAPController.cs 2020-05-18 23:45:19 +08:00
22 changed files with 668 additions and 146 deletions

View File

@@ -228,6 +228,9 @@ namespace Netch.Controllers
if (int.TryParse("32", out var prefix))
{
NativeMethods.CreateRoute("1.1.1.1", prefix, Global.Settings.TUNTAP.Gateway, Global.TUNTAP.Index);
NativeMethods.CreateRoute("8.8.8.8", prefix, Global.Settings.TUNTAP.Gateway, Global.TUNTAP.Index);
NativeMethods.CreateRoute("9.9.9.9", prefix, Global.Settings.TUNTAP.Gateway, Global.TUNTAP.Index);
NativeMethods.CreateRoute("185.222.222.222", prefix, Global.Settings.TUNTAP.Gateway, Global.TUNTAP.Index);
}
}
}

View File

@@ -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.8";
public const string Version = @"1.4.11";
public async void Check(bool notifyNoFound, bool isPreRelease)
{

View File

@@ -127,7 +127,7 @@ namespace Netch.Controllers
enabled = server.UseMux
}
},
(mode.Type==1||mode.Type==2) ? new Models.Information.VMess.Outbounds
(mode.Type==0||mode.Type==1||mode.Type==2) ? new Models.Information.VMess.Outbounds
{
tag = "TUNTAP",
protocol = "freedom"

View File

@@ -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;
}
}

View File

@@ -68,16 +68,21 @@ namespace Netch.Forms
/// <param name="e"></param>
void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
switch (e.Mode)
//不对Netch命令等待状态的电源事件做任何处理
if (!State.Equals(Models.State.Waiting))
{
case PowerModes.Suspend://操作系统即将挂起
Logging.Info("操作系统即将挂起,自动停止===>" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
ControlFun();
break;
case PowerModes.Resume://操作系统即将从挂起状态继续
Logging.Info("操作系统即将从挂起状态继续,自动重启===>" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
ControlFun();
break;
switch (e.Mode)
{
case PowerModes.Suspend://操作系统即将挂起
Logging.Info("操作系统即将挂起,自动停止===>" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
ControlFun();
break;
case PowerModes.Resume://操作系统即将从挂起状态继续
Logging.Info("操作系统即将从挂起状态继续,自动重启===>" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
ControlFun();
break;
}
}
}
private void CheckUpdate()
@@ -255,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)
@@ -336,9 +341,6 @@ namespace Netch.Forms
private void MainForm_Load(object sender, EventArgs e)
{
// 加载配置
Utils.Configuration.Load();
// 加载服务器
InitServer();
@@ -380,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();
@@ -747,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)
@@ -829,7 +832,7 @@ namespace Netch.Forms
}
public void ControlFun()
{
//聚焦到启动按钮,防止模式选择框变成蓝色:D
//聚焦到启动按钮,防止模式选择框变成蓝色:D,不过好像没啥用
ControlButton.Focus();
SaveConfigs();
if (State == Models.State.Waiting || State == Models.State.Stopped)
@@ -877,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)
@@ -1008,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;
@@ -1104,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)
@@ -1370,6 +1411,7 @@ namespace Netch.Forms
NatTypeStatusLabel.Visible = true;
if (!string.IsNullOrWhiteSpace(text))
{
text = text.Trim();
NatTypeStatusLabel.Text = "NAT" + Utils.i18N.Translate(": ") + text;
}
else
@@ -1521,5 +1563,10 @@ namespace Netch.Forms
}
});
}
private void RelyToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start($"https://mega.nz/file/9OQ1EazJ#0pjJ3xt57AVLr29vYEEv15GSACtXVQOGlEOPpi_2Ico");
}
}
}

View File

@@ -116,6 +116,11 @@ namespace Netch.Forms.Server
{
return;
}
if (AlterIDTextBox.Text == "")
{
MessageBox.Show(Utils.i18N.Translate("Please fill in alterID"), Utils.i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (Index == -1)
{
Global.Settings.Server.Add(new Models.Server

View File

@@ -52,6 +52,8 @@
this.ControlButton = new System.Windows.Forms.Button();
this.GlobalBypassIPsButton = new System.Windows.Forms.Button();
this.BehaviorGroupBox = new System.Windows.Forms.GroupBox();
this.LanguageLabel = new System.Windows.Forms.Label();
this.LanguageComboBox = new System.Windows.Forms.ComboBox();
this.BootShadowsocksFromDLLCheckBox = new System.Windows.Forms.CheckBox();
this.AclAddr = new System.Windows.Forms.TextBox();
this.AclLabel = new System.Windows.Forms.Label();
@@ -297,6 +299,8 @@
//
// BehaviorGroupBox
//
this.BehaviorGroupBox.Controls.Add(this.LanguageLabel);
this.BehaviorGroupBox.Controls.Add(this.LanguageComboBox);
this.BehaviorGroupBox.Controls.Add(this.BootShadowsocksFromDLLCheckBox);
this.BehaviorGroupBox.Controls.Add(this.AclAddr);
this.BehaviorGroupBox.Controls.Add(this.AclLabel);
@@ -323,6 +327,24 @@
this.BehaviorGroupBox.TabStop = false;
this.BehaviorGroupBox.Text = "Behavior";
//
// LanguageLabel
//
this.LanguageLabel.AutoSize = true;
this.LanguageLabel.Location = new System.Drawing.Point(12, 305);
this.LanguageLabel.Name = "LanguageLabel";
this.LanguageLabel.Size = new System.Drawing.Size(65, 17);
this.LanguageLabel.TabIndex = 23;
this.LanguageLabel.Text = "Language";
//
// LanguageComboBox
//
this.LanguageComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.LanguageComboBox.FormattingEnabled = true;
this.LanguageComboBox.Location = new System.Drawing.Point(120, 302);
this.LanguageComboBox.Name = "LanguageComboBox";
this.LanguageComboBox.Size = new System.Drawing.Size(121, 25);
this.LanguageComboBox.TabIndex = 22;
//
// BootShadowsocksFromDLLCheckBox
//
this.BootShadowsocksFromDLLCheckBox.AutoSize = true;
@@ -335,7 +357,7 @@
//
// AclAddr
//
this.AclAddr.Location = new System.Drawing.Point(120, 302);
this.AclAddr.Location = new System.Drawing.Point(120, 273);
this.AclAddr.Name = "AclAddr";
this.AclAddr.Size = new System.Drawing.Size(315, 23);
this.AclAddr.TabIndex = 19;
@@ -344,7 +366,7 @@
// AclLabel
//
this.AclLabel.AutoSize = true;
this.AclLabel.Location = new System.Drawing.Point(12, 305);
this.AclLabel.Location = new System.Drawing.Point(12, 276);
this.AclLabel.Name = "AclLabel";
this.AclLabel.Size = new System.Drawing.Size(78, 17);
this.AclLabel.TabIndex = 20;
@@ -353,7 +375,7 @@
// DetectionInterval_Label
//
this.DetectionInterval_Label.AutoSize = true;
this.DetectionInterval_Label.Location = new System.Drawing.Point(229, 221);
this.DetectionInterval_Label.Location = new System.Drawing.Point(229, 192);
this.DetectionInterval_Label.Name = "DetectionInterval_Label";
this.DetectionInterval_Label.Size = new System.Drawing.Size(136, 17);
this.DetectionInterval_Label.TabIndex = 18;
@@ -361,7 +383,7 @@
//
// DetectionInterval_TextBox
//
this.DetectionInterval_TextBox.Location = new System.Drawing.Point(367, 218);
this.DetectionInterval_TextBox.Location = new System.Drawing.Point(367, 189);
this.DetectionInterval_TextBox.Name = "DetectionInterval_TextBox";
this.DetectionInterval_TextBox.Size = new System.Drawing.Size(68, 23);
this.DetectionInterval_TextBox.TabIndex = 17;
@@ -370,7 +392,7 @@
// EnableStartedTcping_CheckBox
//
this.EnableStartedTcping_CheckBox.AutoSize = true;
this.EnableStartedTcping_CheckBox.Location = new System.Drawing.Point(144, 220);
this.EnableStartedTcping_CheckBox.Location = new System.Drawing.Point(144, 191);
this.EnableStartedTcping_CheckBox.Name = "EnableStartedTcping_CheckBox";
this.EnableStartedTcping_CheckBox.Size = new System.Drawing.Size(66, 21);
this.EnableStartedTcping_CheckBox.TabIndex = 15;
@@ -380,7 +402,7 @@
// DelayTestAfterStartup_Label
//
this.DelayTestAfterStartup_Label.AutoSize = true;
this.DelayTestAfterStartup_Label.Location = new System.Drawing.Point(12, 221);
this.DelayTestAfterStartup_Label.Location = new System.Drawing.Point(12, 192);
this.DelayTestAfterStartup_Label.Name = "DelayTestAfterStartup_Label";
this.DelayTestAfterStartup_Label.Size = new System.Drawing.Size(126, 17);
this.DelayTestAfterStartup_Label.TabIndex = 16;
@@ -388,7 +410,7 @@
//
// STUN_ServerPortTextBox
//
this.STUN_ServerPortTextBox.Location = new System.Drawing.Point(120, 273);
this.STUN_ServerPortTextBox.Location = new System.Drawing.Point(120, 244);
this.STUN_ServerPortTextBox.Name = "STUN_ServerPortTextBox";
this.STUN_ServerPortTextBox.Size = new System.Drawing.Size(315, 23);
this.STUN_ServerPortTextBox.TabIndex = 8;
@@ -397,7 +419,7 @@
// STUNServerPortLabel
//
this.STUNServerPortLabel.AutoSize = true;
this.STUNServerPortLabel.Location = new System.Drawing.Point(12, 276);
this.STUNServerPortLabel.Location = new System.Drawing.Point(12, 247);
this.STUNServerPortLabel.Name = "STUNServerPortLabel";
this.STUNServerPortLabel.Size = new System.Drawing.Size(110, 17);
this.STUNServerPortLabel.TabIndex = 12;
@@ -406,7 +428,7 @@
// STUNServerLabel
//
this.STUNServerLabel.AutoSize = true;
this.STUNServerLabel.Location = new System.Drawing.Point(12, 250);
this.STUNServerLabel.Location = new System.Drawing.Point(12, 221);
this.STUNServerLabel.Name = "STUNServerLabel";
this.STUNServerLabel.Size = new System.Drawing.Size(82, 17);
this.STUNServerLabel.TabIndex = 10;
@@ -424,7 +446,7 @@
//
// STUN_ServerTextBox
//
this.STUN_ServerTextBox.Location = new System.Drawing.Point(120, 244);
this.STUN_ServerTextBox.Location = new System.Drawing.Point(120, 215);
this.STUN_ServerTextBox.Name = "STUN_ServerTextBox";
this.STUN_ServerTextBox.Size = new System.Drawing.Size(315, 23);
this.STUN_ServerTextBox.TabIndex = 11;
@@ -443,7 +465,7 @@
// ProfileCount_Label
//
this.ProfileCount_Label.AutoSize = true;
this.ProfileCount_Label.Location = new System.Drawing.Point(12, 196);
this.ProfileCount_Label.Location = new System.Drawing.Point(12, 167);
this.ProfileCount_Label.Name = "ProfileCount_Label";
this.ProfileCount_Label.Size = new System.Drawing.Size(79, 17);
this.ProfileCount_Label.TabIndex = 8;
@@ -451,7 +473,7 @@
//
// ProfileCount_TextBox
//
this.ProfileCount_TextBox.Location = new System.Drawing.Point(209, 193);
this.ProfileCount_TextBox.Location = new System.Drawing.Point(209, 164);
this.ProfileCount_TextBox.Name = "ProfileCount_TextBox";
this.ProfileCount_TextBox.Size = new System.Drawing.Size(226, 23);
this.ProfileCount_TextBox.TabIndex = 9;
@@ -575,5 +597,7 @@
private System.Windows.Forms.Label AclLabel;
private System.Windows.Forms.CheckBox UseFakeDNSCheckBox;
private System.Windows.Forms.CheckBox BootShadowsocksFromDLLCheckBox;
private System.Windows.Forms.Label LanguageLabel;
private System.Windows.Forms.ComboBox LanguageComboBox;
}
}

View File

@@ -1,5 +1,9 @@
using System;
using Netch.Models.SSD;
using System;
using System.Globalization;
using System.IO;
using System.Net;
using System.Text;
using System.Windows.Forms;
using TaskScheduler;
@@ -101,6 +105,10 @@ namespace Netch.Forms
AclLabel.Text = Utils.i18N.Translate(AclLabel.Text);
AclAddr.Text = Global.Settings.ACL.ToString();
LanguageLabel.Text = Utils.i18N.Translate(LanguageLabel.Text);
LanguageComboBox.Items.AddRange(Utils.i18N.GetTranslateList().ToArray());
LanguageComboBox.SelectedItem = Global.Settings.Language;
if (Global.Settings.TUNTAP.DNS.Count > 0)
{
var dns = "";
@@ -160,7 +168,44 @@ namespace Netch.Forms
Global.Settings.MinimizeWhenStarted = MinimizeWhenStartedCheckBox.Checked;
Global.Settings.RunAtStartup = RunAtStartup.Checked;
Global.Settings.BootShadowsocksFromDLL = BootShadowsocksFromDLLCheckBox.Checked;
Global.Settings.Language = LanguageComboBox.SelectedItem.ToString();
// 加载系统语言
if (Global.Settings.Language.Equals("System"))
{
// 得到当前线程语言代码
var culture = CultureInfo.CurrentCulture.Name;
// 尝试加载内置中文语言
if (culture == "zh-CN")
{
// 加载语言
Utils.i18N.Load(Encoding.UTF8.GetString(Properties.Resources.zh_CN));
}
// 从外置文件中加载语言
if (File.Exists($"i18n\\{culture}"))
{
// 加载语言
Utils.i18N.Load(File.ReadAllText($"i18n\\{culture}"));
}
}
if (Global.Settings.Language.Equals("zh-CN"))
{
// 加载内置中文
Utils.i18N.Load(Encoding.UTF8.GetString(Properties.Resources.zh_CN));
}
else if (Global.Settings.Language.Equals("en-US"))
{
// 加载内置英文
Utils.i18N.Load(Global.Settings.Language);
}
else if (File.Exists($"i18n\\{Global.Settings.Language}"))
{
// 从外置文件中加载语言
Utils.i18N.Load(File.ReadAllText($"i18n\\{Global.Settings.Language}"));
}
// 开机自启判断
TaskSchedulerClass scheduler = new TaskSchedulerClass();
@@ -388,7 +433,7 @@ namespace Netch.Forms
Global.Settings.TUNTAP.UseFakeDNS = UseFakeDNSCheckBox.Checked;
Utils.Configuration.Save();
MessageBox.Show(Utils.i18N.Translate("Saved"), Utils.i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show(Utils.i18N.Translate("Saved. Modify some settings need to restart the software"), Utils.i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
Close();
}
}

View File

@@ -184,7 +184,7 @@ namespace Netch.Models
}
}
Group = Group.Equals("None") ? Group.ToUpper() : Group;
Group = Group.Equals("None") || Group.Equals("") ? "NONE" : Group;
switch (Type)
{

View File

@@ -178,5 +178,10 @@ namespace Netch.Models
/// 是否使用DLL启动Shadowsocks
/// </summary>
public bool BootShadowsocksFromDLL = false;
/// <summary>
/// 语言设置
/// </summary>
public string Language = "System";
}
}

View File

@@ -49,41 +49,48 @@ namespace Netch
}
}
// 得到当前线程语言代码
var culture = CultureInfo.CurrentCulture.Name;
// 加载配置
Utils.Configuration.Load();
// 如果命令行参数只有一个,且传入有效语言代码,那么覆盖掉已得到的语言代码
if (args.Length == 1)
// 加载系统语言
if (Global.Settings.Language.Equals("System"))
{
try
// 得到当前线程语言代码
var culture = CultureInfo.CurrentCulture.Name;
// 尝试加载内置中文语言
if (culture == "zh-CN")
{
culture = CultureInfo.GetCultureInfo(args[0]).Name;
// 加载语言
Utils.i18N.Load(Encoding.UTF8.GetString(Properties.Resources.zh_CN));
}
catch (CultureNotFoundException)
// 从外置文件中加载语言
if (File.Exists($"i18n\\{culture}"))
{
// 跳过
// 加载语言
Utils.i18N.Load(File.ReadAllText($"i18n\\{culture}"));
}
}
if (Global.Settings.Language.Equals("zh-CN"))
{
// 加载内置中文
Utils.i18N.Load(Encoding.UTF8.GetString(Properties.Resources.zh_CN));
}
else if (Global.Settings.Language.Equals("en-US"))
{
// 加载内置英文
Utils.i18N.Load(Global.Settings.Language);
}
else if (File.Exists($"i18n\\{Global.Settings.Language}"))
{
// 从外置文件中加载语言
Utils.i18N.Load(File.ReadAllText($"i18n\\{Global.Settings.Language}"));
}
// 记录当前系统语言
Utils.Logging.Info($"当前系统语言:{culture}");
// 尝试加载内置中文语言
if (culture == "zh-CN")
{
// 加载语言
Utils.i18N.Load(Encoding.UTF8.GetString(Properties.Resources.zh_CN));
}
// 记录当前程序语言
Utils.Logging.Info($"当前程序语言:{culture}");
// 从外置文件中加载语言
if (File.Exists($"i18n\\{culture}"))
{
// 加载语言
Utils.i18N.Load(File.ReadAllText($"i18n\\{culture}"));
}
Utils.Logging.Info($"当前语言:{Global.Settings.Language}");
// 检查是否已经运行
if (!mutex.WaitOne(0, false))

View File

@@ -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&#xD;&#xA;RD /S /Q $(TargetDir)bin &gt; NUL 2&gt;&amp;1&#xD;&#xA;RD /S /Q $(TargetDir)i18n &gt; NUL 2&gt;&amp;1&#xD;&#xA;RD /S /Q $(TargetDir)mode &gt; NUL 2&gt;&amp;1&#xD;&#xA;&#xD;&#xA;MKDIR $(TargetDir)bin &gt; NUL 2&gt;&amp;1&#xD;&#xA;MKDIR $(TargetDir)i18n &gt; NUL 2&gt;&amp;1&#xD;&#xA;MKDIR $(TargetDir)mode &gt; NUL 2&gt;&amp;1&#xD;&#xA;&#xD;&#xA;COPY /Y $(SolutionDir)binaries\* $(TargetDir)bin &gt; NUL 2&gt;&amp;1&#xD;&#xA;COPY /Y $(SolutionDir)translations\i18n\* $(TargetDir)i18n &gt; NUL 2&gt;&amp;1&#xD;&#xA;COPY /Y $(SolutionDir)modes\mode\* $(TargetDir)mode &gt; NUL 2&gt;&amp;1&#xD;&#xA;MKDIR $(TargetDir)bin\tap-driver &gt; NUL 2&gt;&amp;1&#xD;&#xA;COPY /Y $(SolutionDir)binaries\tap-driver\* $(TargetDir)bin\tap-driver &gt; NUL 2&gt;&amp;1&#xD;&#xA;&#xD;&#xA;DEL / f $(TargetDir)\*.config&#xD;&#xA;DEL / f $(TargetDir)\*.pdb" />
<Exec Command="@ECHO OFF&#xD;&#xA;RD /S /Q $(TargetDir)bin &gt; NUL 2&gt;&amp;1&#xD;&#xA;RD /S /Q $(TargetDir)i18n &gt; NUL 2&gt;&amp;1&#xD;&#xA;RD /S /Q $(TargetDir)mode &gt; NUL 2&gt;&amp;1&#xD;&#xA;&#xD;&#xA;MKDIR $(TargetDir)bin &gt; NUL 2&gt;&amp;1&#xD;&#xA;MKDIR $(TargetDir)i18n &gt; NUL 2&gt;&amp;1&#xD;&#xA;MKDIR $(TargetDir)mode &gt; NUL 2&gt;&amp;1&#xD;&#xA;&#xD;&#xA;COPY /Y $(SolutionDir)binaries\* $(TargetDir)bin &gt; NUL 2&gt;&amp;1&#xD;&#xA;COPY /Y $(SolutionDir)translations\i18n\* $(TargetDir)i18n &gt; NUL 2&gt;&amp;1&#xD;&#xA;COPY /Y $(SolutionDir)modes\mode\* $(TargetDir)mode &gt; NUL 2&gt;&amp;1&#xD;&#xA;MKDIR $(TargetDir)bin\tap-driver &gt; NUL 2&gt;&amp;1&#xD;&#xA;COPY /Y $(SolutionDir)binaries\tap-driver\* $(TargetDir)bin\tap-driver &gt; NUL 2&gt;&amp;1&#xD;&#xA;&#xD;&#xA;DEL / f $(TargetDir)\*.config&#xD;&#xA;DEL / f $(TargetDir)\*.pdb&#xD;&#xA;RD /s /Q $(TargetDir)\x86" />
</Target>
</Project>

View File

@@ -145,6 +145,7 @@
"Link can not be empty": "链接不可为空",
"Link must start with http:// or https://": "链接必须以 http:// 或 https:// 开头",
"Successfully saved": "保存成功",
"Please fill in alterID": "请填写额外ID",
"Settings": "设置",
"Start when opened": "打开软件时启动加速",
@@ -177,6 +178,8 @@
"STUN Server": "STUN 服务器",
"STUN Server Port": "STUN 服务器端口",
"Custom ACL": "自定义 ACL 规则",
"Language": "语言",
"Saved. Modify some settings need to restart the software": "保存成功,修改部分设置需重启软件",
"Profile": "配置名",
"Profiles": "配置",
@@ -184,6 +187,7 @@
"Show": "显示",
"Exit": "退出",
"Unable to start? Click me to download": "无法启动?点我下载依赖",
"Bypass LAN": "[网页代理] 绕过局域网",
"Bypass LAN (Non System Proxy)": "[网页代理] 绕过局域网(不设置系统代理)",

View File

@@ -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));
}
}
}
}
}

View File

@@ -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();
}

View File

@@ -1,5 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
namespace Netch.Utils
{
@@ -16,6 +18,11 @@ namespace Netch.Utils
/// <param name="text">语言文件</param>
public static void Load(string text)
{
if (text.Equals("en-US"))
{
Data.Clear();
return;
}
var data = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(text);
if (data != null)
@@ -42,5 +49,26 @@ namespace Netch.Utils
return text;
}
/// <summary>
/// 获取可使用的语言
/// </summary>
/// <returns></returns>
public static List<string> GetTranslateList()
{
List<string> TranslateFile = new List<string>();
TranslateFile.Add("System");
TranslateFile.Add("zh-CN");
TranslateFile.Add("en-US");
if (Directory.Exists("i18n"))
{
foreach (var fileName in Directory.GetFiles("i18n", "*"))
{
TranslateFile.Add(fileName.Substring(5));
}
}
return TranslateFile;
}
}
}

View File

@@ -1,12 +1,18 @@
# Netch
[![](https://img.shields.io/badge/Telegram-Channel-blue)](https://t.me/Netch) [![](https://img.shields.io/badge/Telegram-Group-green)](https://t.me/Netch_Discuss_Group) ![Netch CI](https://github.com/NetchX/Netch/workflows/Netch%20CI/badge.svg)
[![Platform](https://img.shields.io/badge/platform-windows-orange.svg)](https://github.com/NetchX/Netch)
[![Version](https://img.shields.io/github/v/release/NetchX/Netch)](https://github.com/NetchX/Netch/releases)
[![Downloads](https://img.shields.io/github/downloads/NetchX/Netch/total.svg)](https://github.com/NetchX/Netch/releases)
[![Netch CI](https://github.com/NetchX/Netch/workflows/Netch%20CI/badge.svg)](https://github.com/NetchX/Netch/actions)
[![License](https://img.shields.io/badge/license-MIT-yellow.svg)](LICENSE)
[![](https://img.shields.io/badge/Telegram-Channel-blue)](https://t.me/Netch) [![](https://img.shields.io/badge/Telegram-Group-green)](https://t.me/Netch_Discuss_Group)
[![Website](https://img.shields.io/website?url=https%3A%2F%2Fnetch.org)](https://netch.org/)
[中文说明](/docs/README.zh-CN.md)
[FAQ/常见问题](https://netch.org/#/docs/zh-CN/faq)
Game accelerator
[简体中文](docs/README.zh-CN.md) (此版本内容更丰富)
[Website](https://netch.org/)
## TOC
- [Netch](#netch)
- [TOC](#toc)

View File

@@ -0,0 +1,221 @@
# Netch 模式
用于存储 Netch 模式文件的仓库
## 目录
1. [模式介绍](#模式介绍)
- 1.1 [模式 1 进程代理模式](#模式-1-进程代理模式)
- 1.2 [模式 2需要自己新建模式文件 TUN/TAP IP 黑名单代理模式](#模式-2需要自己新建模式文件-tuntap-ip-黑名单代理模式)
- 1.3 [模式 3 TUN/TAP IP 白名单)全局代理模式](#模式-3-tuntap-ip-白名单全局代理模式)
- 1.4 [模式 4 HTTP 系统代理](#模式-4-http-系统代理)
- 1.5 [模式 5 本地 Socks5 代理](#模式-5-本地-socks5-代理)
- 1.6 [模式 6 本地 Socks5 和 HTTP 代理](#模式-6-本地-socks5-和-http-代理)
2. [Socks 5 代理中转](#socks-5-代理中转)
3. [新建进程代理模式](#新建进程代理模式)
- 3.1 [模式](#模式)
- 3.2 [扫描](#扫描)
- 3.3 [启动](#启动)
## 模式介绍
目前 Netch 所有模式文件都在 `mode` 文件夹下。模式号即模式菜单中最左边中括号内数字
内置的模式中,如果模式名中有 Bypass China 的部分,即该模式会绕过中国 IP 段
模式 1 和模式 2 里面除了第一行格式不同,其他内容和 [SSTap-Rule](https://github.com/FQrabbit/SSTap-Rule) 相同。是否绕过中国的功能依赖于 [CNIP 文件](https://github.com/NetchX/Netch/blob/master/Netch/Resources/CNIP)
模式 3 到模式 5 的是否绕过中国的功能依赖于 [acl 文件](https://github.com/NetchX/Netch/blob/master/binaries/default.acl)
第一行格式均为如下样式,不同模式之间第一行的具体区别可以参照后面的内容
```Python
# 备注, 类型(是主项目 USAGE.zh-CN.md 里提到的模式类型的值减一), 是否绕过中国1 为是, 0 为否)
```
### 模式 1 进程代理模式
- 根据进程名进行代理
- 底层依赖于 [NetFilter SDK](https://netfiltersdk.com) 和 Redirector.exe未开源
- 对于第一次使用 Netch 的用户而言,不需要做多余的事情
- 若 [NetFilter SDK](https://netfiltersdk.com) 的驱动不存在,会自动安装
- 自动安装驱动时不会判断旧驱动是否需要更新
- 对于老用户而言,版本更新日志里如果提到要更新驱动,或者你发现无法使用本模式时,可以通过运行 `DriverUpdater.exe` 的方式强制覆盖旧驱动
- 相关代码 [NFController.cs](..\Netch\Controllers\NFController.cs)
范例文件
在这个模式里,第一行只有备注是有用的
```
# 备注
进程名 1会被代理
进程名 2
...
```
### 模式 2需要自己新建模式文件 TUN/TAP IP 黑名单代理模式
- 黑名单代理指的是,除了名单内的 IP 走代理,其他连接都不走代理
- 需要自己新建模式文件,第一行写法同模式 3只是需要把 2 改成 1
- 后续内容的格式同 [SSTap-rules](https://github.com/FQrabbit/SSTap-Rule),任何规则问题建议到那边去提
- 可以通过左下角的`设置`来配置 IP 地址子网掩码网关DNS
- 该模式下直连 IP 段无效,暂时没有代码实现
- 底层依赖于 [Tap-Windows](https://github.com/OpenVPN/tap-windows) 适配器等
- 如果 Netch 提示没有该适配器,可以直接安装 [Tap-Windows](https://build.openvpn.net/downloads/releases/latest/tap-windows-latest-stable.exe) 或者通过安装 [OpenVPN](https://openvpn.net/community-downloads/)[SSTap](https://github.com/mayunbaba2/SSTap-beta-setup) 的方式获得该适配器
范例文件
在这个模式里,是否绕过中国的值是无效的
```
# 备注, 1
无类别域间路由写法 1目的 IP 在这个子网内的网络请求都会被代理)
无类别域间路由写法 2
...
```
### 模式 3 TUN/TAP IP 白名单)全局代理模式
- 白名单代理指的是,除了名单内的 IP 不走代理,其他连接都走代理
- 可以通过左下角的`设置`来配置 IP 地址子网掩码网关DNS直连 IP 段
- 底层依赖于 [Tap-Windows](https://github.com/OpenVPN/tap-windows) 适配器tun2socks 等
- 如果 Netch 提示没有该适配器,可以直接安装 [Tap-Windows](https://build.openvpn.net/downloads/releases/latest/tap-windows-latest-stable.exe) 或者通过安装 [OpenVPN](https://openvpn.net/community-downloads/)[SSTap](https://github.com/mayunbaba2/SSTap-beta-setup) 的方式获得该适配器
范例文件
```
# 备注, 2, 是否绕过中国1 为是, 0 为否)
无类别域间路由写法 1目的 IP 只有在这个子网内的网络请求不会被代理,其他的都会被代理)
无类别域间路由写法 2
...
```
### 模式 4 HTTP 系统代理
- 默认地址和端口为 127.0.0.1:2802
- 端口可以在左下角设置里面更改
- 会被设置为系统代理
范例文件
```
# 备注, 3, 是否绕过中国1 为是, 0 为否)
(目前只有第一行是有效的)
```
### 模式 5 本地 Socks5 代理
- 默认地址和端口为 127.0.0.1:2801
- 端口可以在左下角设置里面更改
- 不会被设置为系统代理,对于 Chrome 之类使用系统代理的浏览器需要设置使用插件 SwitchyOmega 之后才能被正常代理
- 注意如果是使用 Firefox 的网络设置,请仅设置 Socks5 代理,清除其他代理配置,并取消勾选`为所有协议使用相同的代理服务器`
- 其他模式均含 Socks5 代理,本模式可以理解为仅 Socks5 代理\
范例文件
```
# 备注, 4, 是否绕过中国1 为是, 0 为否)
(目前只有第一行是有效的)
```
### 模式 6 本地 Socks5 和 HTTP 代理
- Socks5 代理的默认地址和端口为 127.0.0.1:2801
- HTTP 代理的默认地址和端口为 127.0.0.1:2802
- 端口可以在左下角设置里面更改
- 不会被设置为系统代理
范例文件
```
# 备注, 5, 是否绕过中国1 为是, 0 为否)
(目前只有第一行是有效的)
```
## Socks 5 代理中转
说明一下Netch 并非是以网页代理为目的开发的程序,如果需要网络代理为目的的程序,需要 PAC规则分流订阅管理等功能的请参考使用以下软件而非 Netch均为 Windows 平台)
ShadowsocksR
- [HMBSbige/ShadowsocksR-Windows](https://github.com/HMBSbige/ShadowsocksR-Windows/releases)
Shadowsocks
- [Clash for Windows](https://github.com/Fndroid/clash_for_windows_pkg/releases)
V2Ray
- [V2RayN](https://github.com/2dust/v2rayN/releases)
如果你想使用的代理工具目前 Netch 还不支持,或者需要一些 Netch 目前没有的功能,如 V2Ray 自定义配置Socks5 本地代理规则分流的,可以在 Netch 里添加对应工具的本地 Socks5 代理端口后使用,注意如果你用的是模式 3 TUN/TAP IP 白名单)全局代理模式,记得在`设置 - 全局直连 IP`中添加你的服务器 IP 地址,否则会产生代理回环
## 新建进程代理模式
- 现在软件还处在早期开发阶段,可能后续版本会发生很大变化,操作仅供参考
当前版本已添加配置编辑功能,根据自己的情况,使用订阅或者别的方法添加代理配置,我这里使用的是剪贴板导入
![剪贴板导入](https://raw.githubusercontent.com/BingLingGroup/BingLingGroup.github.io/img/Netch_guide/2019-06-24_210438.png)
如果你发现你的程序没我截图的看起来清晰,可以右键 `Netch.exe - 属性 - 兼容性 - 更改高 DPI 设置 - 替代高 DPI 缩放执行 - 系统(增强)`
### 模式
如果你的游戏的模式已经被收录,也可以考虑在模式菜单中,选择使用已收录的模式。所有模式的文件,都在 `./mode/` 文件夹下,如果你需要多个模式的合并文件,可以使用记事本将其打开,将多个文件合并
ping 的值未必准确,因为这只是你本地到代理服务器而非游戏服务器的延迟
如果你的游戏的模式没被收录,可以看接下来的扫描步骤来手动创建模式
接着点击菜单栏上的`模式 - 创建进程模式`
![模式 - 创建进程模式](https://raw.githubusercontent.com/BingLingGroup/BingLingGroup.github.io/img/Netch_guide/2019-06-24%20211537.png)
### 扫描
在弹出的窗口中点击`扫描`
![扫描](https://raw.githubusercontent.com/BingLingGroup/BingLingGroup.github.io/img/Netch_guide/2019-06-24%20211842.png)
选择你要加速的游戏的安装路径,根据游戏不同,可能需要选择多个不同的目录进行扫描,参见[萌鹰的 Netch 教程](https://www.eaglemoe.com/archives/142)(包括 GTAOL 和 R6S 的配置方法)
>4. 选定 GTA5 游戏目录,点击确定,软件会自动扫描目录下的 exe 程式并填写进去
>5. 再次点击扫描,选择 SocialClub 的安装地址(一般为 C:\Program Files\Rockstar Games\Social Club点击确定点击保存
>
>注意:加入游戏时请不要忘记加入社交组件,比如说 GTA 不要忘记 SocialClub ,彩虹六号不要忘记 Uplay
这里以战争雷霆为例,只需添加战争雷霆游戏根目录即可
![选择路径](https://raw.githubusercontent.com/NetchX/Netch/master/docs/screenshots/Browse_For_Folder.png)
扫描时可能需要稍等片刻,扫描后记得填写备注
如果需要添加单个程序,也可以在添加按钮左侧的编辑栏中手动输入并添加
之后点保存进行`保存`
![保存](https://raw.githubusercontent.com/BingLingGroup/BingLingGroup.github.io/img/Netch_guide/2019-06-24%20212837.png)
### 启动
最后确认服务器一栏和模式一栏均为之前自己添加并需要使用的,没问题后点击`启动`即可
![启动](https://raw.githubusercontent.com/BingLingGroup/BingLingGroup.github.io/img/Netch_guide/2019-06-24%20213121.png)
启动后,你再去游戏根目录或者别的启动器如 SteamUplay 启动游戏即可。此时游戏就已经被代理了
如果在 Netch 启动前就启动了游戏,建议重启游戏
如果需要 SteamUplay 等启动器也被代理,参照前面的方式对 SteamUplay 根目录也进行扫描即可
如果出现了启动失败,或者无法代理成功的情况,请先尝试`选项 - 重启服务``选项 - 卸载服务`,或者在退出 Netch 以后,点击运行在 Netch 根目录下的 `DriverUpdater.exe` 程序进行驱动更新
## 语言支持
Netch 支持多种语言,在启动时会根据系统语言选择自身语言。如果需要手动切换语言,可以在启动时加入命令行参数,命令行参数为目前支持的语言代码,可以去 [NetchTranslation/i18n](https://github.com/NetchX/NetchTranslation/tree/master/i18n) 文件夹下查看外部支持的语言代码文件。Netch 目前内置 en-USzh-CN外置 zh-TW。欢迎大家为 [NetchTranslation](https://github.com/NetchX/NetchTranslation) 提供其他语言的翻译

View File

@@ -1,5 +1,5 @@
# 新手入门
**Version : 1.3.7**
**Version : 1.4.10**
[下载地址](https://github.com/NetchX/Netch/releases)
@@ -9,7 +9,7 @@
## 添加服务器
> Netch 目前仅支持以下代理协议ShadowsocksVMessSocks5ShadowsockR。
> Netch 目前仅支持以下代理协议ShadowsocksVMessSocks5ShadowsockRTrojan
首先,点击`服务器`增加所需服务器

View File

@@ -11,7 +11,7 @@
- [简介](#简介)
- [捐赠](#捐赠)
- [新手入门](Quickstart.zh-CN.md)
- [进阶用法](https://github.com/NormanBB/NetchMode/blob/master/docs/README.zh-CN.md)
- [进阶用法](Advanced_Usage.zh-CN.md)
- [依赖](#依赖)
- [语言支持](#语言支持)
@@ -20,6 +20,9 @@ Netch 是一款 Windows 平台的开源游戏加速工具Netch 可以实现
与此同时 Netch 避免了 SSTap 的 NAT 问题 ,检查 NAT 类型即可知道是否有 NAT 问题。使用 SSTap 加速部分 P2P 联机,对 NAT 类型有要求的游戏时,可能会因为 NAT 类型严格遇到无法加入联机,或者其他影响游戏体验的情况
需要更多特性请移步魔改仓库 [Netch-ForOwnUse](https://github.com/AmazingDM/Netch-ForOwnUse)
## 捐赠
- XMR *48ju3ELNZEa6wwPBMexCJ9G218BGY2XwhH6B6bmkFuJ3QgM4hPw2Pra35jPtuBZSc7SLNWeBpiWJZWjQeMAiLnTx2tH2Efx*
@@ -27,7 +30,7 @@ Netch 是一款 Windows 平台的开源游戏加速工具Netch 可以实现
[新手入门教程](Quickstart.zh-CN.md)
## 进阶用法
[进阶教程](https://github.com/NormanBB/NetchMode/blob/master/docs/README.zh-CN.md)
[进阶教程](Advanced_Usage.zh-CN.md)
## 依赖
- [Visual C++ 运行库合集](https://www.google.com/search?q=Visual+C%2B%2B+%E8%BF%90%E8%A1%8C%E5%BA%93%E5%90%88%E9%9B%86)
- [.NET Framework 4.8](https://dotnet.microsoft.com/download/dotnet-framework/thank-you/net48-offline-installer)

2
modes

Submodule modes updated: 20884a02f7...f0327e9399