diff --git a/Netch/Controllers/Mode/NFController.cs b/Netch/Controllers/Mode/NFController.cs
index dc903746..7d4bcfd9 100644
--- a/Netch/Controllers/Mode/NFController.cs
+++ b/Netch/Controllers/Mode/NFController.cs
@@ -3,6 +3,7 @@ using System.Diagnostics;
using System.IO;
using System.ServiceProcess;
using System.Threading;
+using System.Threading.Tasks;
using Netch.Models;
using Netch.Utils;
using nfapinet;
@@ -105,11 +106,13 @@ namespace Netch.Controllers
if (State == State.Started)
{
-
- //备份并替换系统DNS
- _sysDns = DNS.getSystemDns();
- string[] dns = {"1.1.1.1", "8.8.8.8"};
- DNS.SetDNS(dns);
+ if (Global.Settings.ModifySystemDNS)
+ {
+ //备份并替换系统DNS
+ _sysDns = DNS.getSystemDns();
+ string[] dns = {"1.1.1.1", "8.8.8.8"};
+ DNS.SetDNS(dns);
+ }
return true;
}
@@ -171,7 +174,7 @@ namespace Netch.Controllers
/// 是否成功卸载
public static bool UninstallDriver()
{
- Global.MainForm.StatusText("Uninstall netfilter2");
+ Global.MainForm.StatusText(i18N.Translate("Uninstalling NF Service"));
Logging.Info("卸载NF驱动");
try
{
@@ -266,9 +269,13 @@ namespace Netch.Controllers
public override void Stop()
{
+ Task.Run(() =>
+ {
+ if (Global.Settings.ModifySystemDNS)
+ //恢复系统DNS
+ DNS.SetDNS(_sysDns);
+ });
StopInstance();
- //恢复系统DNS
- DNS.SetDNS(_sysDns);
}
///
diff --git a/Netch/Forms/MainForm.Designer.cs b/Netch/Forms/MainForm.Designer.cs
index 48bafdeb..94cdbb1e 100644
--- a/Netch/Forms/MainForm.Designer.cs
+++ b/Netch/Forms/MainForm.Designer.cs
@@ -274,7 +274,7 @@ namespace Netch.Forms
//
this.UninstallServiceToolStripMenuItem.Name = "UninstallServiceToolStripMenuItem";
this.UninstallServiceToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
- this.UninstallServiceToolStripMenuItem.Text = "Uninstall Service";
+ this.UninstallServiceToolStripMenuItem.Text = "Uninstall NF Service";
this.UninstallServiceToolStripMenuItem.Click += new System.EventHandler(this.UninstallServiceToolStripMenuItem_Click);
//
// reinstallTapDriverToolStripMenuItem
diff --git a/Netch/Forms/MainForm.MenuStrip.cs b/Netch/Forms/MainForm.MenuStrip.cs
index 82c4a5c4..f7a11e02 100644
--- a/Netch/Forms/MainForm.MenuStrip.cs
+++ b/Netch/Forms/MainForm.MenuStrip.cs
@@ -233,7 +233,7 @@ namespace Netch.Forms
private void UninstallServiceToolStripMenuItem_Click(object sender, EventArgs e)
{
Enabled = false;
- StatusText(i18N.Translate("Uninstalling Service"));
+ StatusText(i18N.Translate("Uninstalling NF Service"));
Task.Run(() =>
{
@@ -241,7 +241,7 @@ namespace Netch.Forms
{
if (NFController.UninstallDriver())
{
- MessageBoxX.Show(i18N.Translate("Service has been uninstalled"), owner: this);
+ StatusText(i18N.Translate("Service has been uninstalled"));
}
}
catch (Exception e)
@@ -250,8 +250,6 @@ namespace Netch.Forms
Console.WriteLine(e);
throw;
}
-
- StatusText(i18N.Translate(StateExtension.GetStatusString(State.Waiting)));
Enabled = true;
});
}
diff --git a/Netch/Forms/MainForm.cs b/Netch/Forms/MainForm.cs
index 9cf2d084..4c68a868 100644
--- a/Netch/Forms/MainForm.cs
+++ b/Netch/Forms/MainForm.cs
@@ -186,7 +186,7 @@ namespace Netch.Forms
UpdateServersFromSubscribeLinksToolStripMenuItem.Text = i18N.Translate("Update Servers From Subscribe Links");
OptionsToolStripMenuItem.Text = i18N.Translate("Options");
ReloadModesToolStripMenuItem.Text = i18N.Translate("Reload Modes");
- UninstallServiceToolStripMenuItem.Text = i18N.Translate("Uninstall Service");
+ UninstallServiceToolStripMenuItem.Text = i18N.Translate("Uninstall NF Service");
CleanDNSCacheToolStripMenuItem.Text = i18N.Translate("Clean DNS Cache");
UpdateACLToolStripMenuItem.Text = i18N.Translate("Update ACL");
updateACLWithProxyToolStripMenuItem.Text = i18N.Translate("Update ACL with proxy");
diff --git a/Netch/Forms/SettingForm.Designer.cs b/Netch/Forms/SettingForm.Designer.cs
index 5cdba74b..aea38724 100644
--- a/Netch/Forms/SettingForm.Designer.cs
+++ b/Netch/Forms/SettingForm.Designer.cs
@@ -55,24 +55,24 @@
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.AclAddrTextBox = new System.Windows.Forms.TextBox();
this.AclLabel = new System.Windows.Forms.Label();
- this.DetectionInterval_Label = new System.Windows.Forms.Label();
- this.DetectionInterval_TextBox = new System.Windows.Forms.TextBox();
- this.EnableStartedTcping_CheckBox = new System.Windows.Forms.CheckBox();
- this.DelayTestAfterStartup_Label = new System.Windows.Forms.Label();
+ this.DetectionIntervalLabel = new System.Windows.Forms.Label();
+ this.DetectionIntervalTextBox = new System.Windows.Forms.TextBox();
+ this.TcpingAtStartedCheckBox = new System.Windows.Forms.CheckBox();
this.STUN_ServerPortTextBox = new System.Windows.Forms.TextBox();
- this.STUNServerPortLabel = new System.Windows.Forms.Label();
+ this.StunTextBoxSplitLabel = new System.Windows.Forms.Label();
this.STUNServerLabel = new System.Windows.Forms.Label();
- this.RunAtStartup = new System.Windows.Forms.CheckBox();
+ this.RunAtStartupCheckBox = new System.Windows.Forms.CheckBox();
this.STUN_ServerTextBox = new System.Windows.Forms.TextBox();
this.MinimizeWhenStartedCheckBox = new System.Windows.Forms.CheckBox();
- this.ProfileCount_Label = new System.Windows.Forms.Label();
- this.ProfileCount_TextBox = new System.Windows.Forms.TextBox();
+ this.ProfileCountLabel = new System.Windows.Forms.Label();
+ this.ProfileCountTextBox = new System.Windows.Forms.TextBox();
this.CheckUpdateWhenOpenedCheckBox = new System.Windows.Forms.CheckBox();
this.StartWhenOpenedCheckBox = new System.Windows.Forms.CheckBox();
this.StopWhenExitedCheckBox = new System.Windows.Forms.CheckBox();
this.ExitWhenClosedCheckBox = new System.Windows.Forms.CheckBox();
+ this.ModifySystemDNSCheckBox = new System.Windows.Forms.CheckBox();
this.PortGroupBox.SuspendLayout();
this.TUNTAPGroupBox.SuspendLayout();
this.BehaviorGroupBox.SuspendLayout();
@@ -301,21 +301,21 @@
//
this.BehaviorGroupBox.Controls.Add(this.LanguageLabel);
this.BehaviorGroupBox.Controls.Add(this.LanguageComboBox);
+ this.BehaviorGroupBox.Controls.Add(this.ModifySystemDNSCheckBox);
this.BehaviorGroupBox.Controls.Add(this.BootShadowsocksFromDLLCheckBox);
- this.BehaviorGroupBox.Controls.Add(this.AclAddr);
+ this.BehaviorGroupBox.Controls.Add(this.AclAddrTextBox);
this.BehaviorGroupBox.Controls.Add(this.AclLabel);
- this.BehaviorGroupBox.Controls.Add(this.DetectionInterval_Label);
- this.BehaviorGroupBox.Controls.Add(this.DetectionInterval_TextBox);
- this.BehaviorGroupBox.Controls.Add(this.EnableStartedTcping_CheckBox);
- this.BehaviorGroupBox.Controls.Add(this.DelayTestAfterStartup_Label);
+ this.BehaviorGroupBox.Controls.Add(this.DetectionIntervalLabel);
+ this.BehaviorGroupBox.Controls.Add(this.DetectionIntervalTextBox);
+ this.BehaviorGroupBox.Controls.Add(this.TcpingAtStartedCheckBox);
this.BehaviorGroupBox.Controls.Add(this.STUN_ServerPortTextBox);
- this.BehaviorGroupBox.Controls.Add(this.STUNServerPortLabel);
+ this.BehaviorGroupBox.Controls.Add(this.StunTextBoxSplitLabel);
this.BehaviorGroupBox.Controls.Add(this.STUNServerLabel);
- this.BehaviorGroupBox.Controls.Add(this.RunAtStartup);
+ this.BehaviorGroupBox.Controls.Add(this.RunAtStartupCheckBox);
this.BehaviorGroupBox.Controls.Add(this.STUN_ServerTextBox);
this.BehaviorGroupBox.Controls.Add(this.MinimizeWhenStartedCheckBox);
- this.BehaviorGroupBox.Controls.Add(this.ProfileCount_Label);
- this.BehaviorGroupBox.Controls.Add(this.ProfileCount_TextBox);
+ this.BehaviorGroupBox.Controls.Add(this.ProfileCountLabel);
+ this.BehaviorGroupBox.Controls.Add(this.ProfileCountTextBox);
this.BehaviorGroupBox.Controls.Add(this.CheckUpdateWhenOpenedCheckBox);
this.BehaviorGroupBox.Controls.Add(this.StartWhenOpenedCheckBox);
this.BehaviorGroupBox.Controls.Add(this.StopWhenExitedCheckBox);
@@ -357,11 +357,11 @@
//
// AclAddr
//
- 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;
- this.AclAddr.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+ this.AclAddrTextBox.Location = new System.Drawing.Point(120, 273);
+ this.AclAddrTextBox.Name = "AclAddrTextBox";
+ this.AclAddrTextBox.Size = new System.Drawing.Size(315, 23);
+ this.AclAddrTextBox.TabIndex = 19;
+ this.AclAddrTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// AclLabel
//
@@ -374,61 +374,53 @@
//
// DetectionInterval_Label
//
- this.DetectionInterval_Label.AutoSize = true;
- 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;
- this.DetectionInterval_Label.Text = "Detection interval(sec)";
+ this.DetectionIntervalLabel.AutoSize = true;
+ this.DetectionIntervalLabel.Location = new System.Drawing.Point(228, 215);
+ this.DetectionIntervalLabel.Name = "DetectionIntervalLabel";
+ this.DetectionIntervalLabel.Size = new System.Drawing.Size(136, 17);
+ this.DetectionIntervalLabel.TabIndex = 18;
+ this.DetectionIntervalLabel.Text = "Detection interval(sec)";
//
// DetectionInterval_TextBox
//
- 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;
- this.DetectionInterval_TextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+ this.DetectionIntervalTextBox.Location = new System.Drawing.Point(366, 212);
+ this.DetectionIntervalTextBox.Name = "DetectionIntervalTextBox";
+ this.DetectionIntervalTextBox.Size = new System.Drawing.Size(68, 23);
+ this.DetectionIntervalTextBox.TabIndex = 17;
+ this.DetectionIntervalTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// EnableStartedTcping_CheckBox
//
- this.EnableStartedTcping_CheckBox.AutoSize = true;
- 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;
- this.EnableStartedTcping_CheckBox.Text = "Enable";
- this.EnableStartedTcping_CheckBox.UseVisualStyleBackColor = true;
- //
- // DelayTestAfterStartup_Label
- //
- this.DelayTestAfterStartup_Label.AutoSize = true;
- 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;
- this.DelayTestAfterStartup_Label.Text = "Delay test after start";
+ this.TcpingAtStartedCheckBox.AutoSize = true;
+ this.TcpingAtStartedCheckBox.Location = new System.Drawing.Point(15, 214);
+ this.TcpingAtStartedCheckBox.Name = "TcpingAtStartedCheckBox";
+ this.TcpingAtStartedCheckBox.Size = new System.Drawing.Size(145, 21);
+ this.TcpingAtStartedCheckBox.TabIndex = 15;
+ this.TcpingAtStartedCheckBox.TabStop = false;
+ this.TcpingAtStartedCheckBox.Text = "Delay test after start";
+ this.TcpingAtStartedCheckBox.UseVisualStyleBackColor = true;
//
// STUN_ServerPortTextBox
//
- this.STUN_ServerPortTextBox.Location = new System.Drawing.Point(120, 244);
+ this.STUN_ServerPortTextBox.Location = new System.Drawing.Point(366, 241);
this.STUN_ServerPortTextBox.Name = "STUN_ServerPortTextBox";
- this.STUN_ServerPortTextBox.Size = new System.Drawing.Size(315, 23);
+ this.STUN_ServerPortTextBox.Size = new System.Drawing.Size(68, 23);
this.STUN_ServerPortTextBox.TabIndex = 8;
this.STUN_ServerPortTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
- // STUNServerPortLabel
+ // StunTextBoxSplitLabel
//
- this.STUNServerPortLabel.AutoSize = true;
- 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;
- this.STUNServerPortLabel.Text = "STUN Server Port";
+ this.StunTextBoxSplitLabel.AutoSize = true;
+ this.StunTextBoxSplitLabel.Location = new System.Drawing.Point(353, 244);
+ this.StunTextBoxSplitLabel.Name = "StunTextBoxSplitLabel";
+ this.StunTextBoxSplitLabel.Size = new System.Drawing.Size(11, 17);
+ this.StunTextBoxSplitLabel.TabIndex = 12;
+ this.StunTextBoxSplitLabel.Text = ":";
//
// STUNServerLabel
//
this.STUNServerLabel.AutoSize = true;
- this.STUNServerLabel.Location = new System.Drawing.Point(12, 221);
+ this.STUNServerLabel.Location = new System.Drawing.Point(12, 244);
this.STUNServerLabel.Name = "STUNServerLabel";
this.STUNServerLabel.Size = new System.Drawing.Size(82, 17);
this.STUNServerLabel.TabIndex = 10;
@@ -436,19 +428,19 @@
//
// RunAtStartup
//
- this.RunAtStartup.AutoSize = true;
- this.RunAtStartup.Location = new System.Drawing.Point(12, 75);
- this.RunAtStartup.Name = "RunAtStartup";
- this.RunAtStartup.Size = new System.Drawing.Size(109, 21);
- this.RunAtStartup.TabIndex = 11;
- this.RunAtStartup.Text = "Run at startup";
- this.RunAtStartup.UseVisualStyleBackColor = true;
+ this.RunAtStartupCheckBox.AutoSize = true;
+ this.RunAtStartupCheckBox.Location = new System.Drawing.Point(12, 75);
+ this.RunAtStartupCheckBox.Name = "RunAtStartupCheckBox";
+ this.RunAtStartupCheckBox.Size = new System.Drawing.Size(109, 21);
+ this.RunAtStartupCheckBox.TabIndex = 11;
+ this.RunAtStartupCheckBox.Text = "Run at startup";
+ this.RunAtStartupCheckBox.UseVisualStyleBackColor = true;
//
// STUN_ServerTextBox
//
- this.STUN_ServerTextBox.Location = new System.Drawing.Point(120, 215);
+ this.STUN_ServerTextBox.Location = new System.Drawing.Point(120, 241);
this.STUN_ServerTextBox.Name = "STUN_ServerTextBox";
- this.STUN_ServerTextBox.Size = new System.Drawing.Size(315, 23);
+ this.STUN_ServerTextBox.Size = new System.Drawing.Size(233, 23);
this.STUN_ServerTextBox.TabIndex = 11;
this.STUN_ServerTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
@@ -464,20 +456,20 @@
//
// ProfileCount_Label
//
- this.ProfileCount_Label.AutoSize = true;
- 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;
- this.ProfileCount_Label.Text = "ProfileCount";
+ this.ProfileCountLabel.AutoSize = true;
+ this.ProfileCountLabel.Location = new System.Drawing.Point(12, 188);
+ this.ProfileCountLabel.Name = "ProfileCountLabel";
+ this.ProfileCountLabel.Size = new System.Drawing.Size(79, 17);
+ this.ProfileCountLabel.TabIndex = 8;
+ this.ProfileCountLabel.Text = "ProfileCount";
//
// ProfileCount_TextBox
//
- this.ProfileCount_TextBox.Location = new System.Drawing.Point(120, 164);
- this.ProfileCount_TextBox.Name = "ProfileCount_TextBox";
- this.ProfileCount_TextBox.Size = new System.Drawing.Size(90, 23);
- this.ProfileCount_TextBox.TabIndex = 9;
- this.ProfileCount_TextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+ this.ProfileCountTextBox.Location = new System.Drawing.Point(120, 185);
+ this.ProfileCountTextBox.Name = "ProfileCountTextBox";
+ this.ProfileCountTextBox.Size = new System.Drawing.Size(90, 23);
+ this.ProfileCountTextBox.TabIndex = 9;
+ this.ProfileCountTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// CheckUpdateWhenOpenedCheckBox
//
@@ -523,6 +515,16 @@
this.ExitWhenClosedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.ExitWhenClosedCheckBox.UseVisualStyleBackColor = true;
//
+ // ModifySystemDNSCheckBox
+ //
+ this.ModifySystemDNSCheckBox.AutoSize = true;
+ this.ModifySystemDNSCheckBox.Location = new System.Drawing.Point(12, 129);
+ this.ModifySystemDNSCheckBox.Name = "ModifySystemDNSCheckBox";
+ this.ModifySystemDNSCheckBox.Size = new System.Drawing.Size(143, 21);
+ this.ModifySystemDNSCheckBox.TabIndex = 21;
+ this.ModifySystemDNSCheckBox.Text = "Modify System DNS";
+ this.ModifySystemDNSCheckBox.UseVisualStyleBackColor = true;
+ //
// SettingForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
@@ -578,26 +580,26 @@
private System.Windows.Forms.CheckBox StopWhenExitedCheckBox;
private System.Windows.Forms.CheckBox StartWhenOpenedCheckBox;
private System.Windows.Forms.CheckBox CheckUpdateWhenOpenedCheckBox;
- private System.Windows.Forms.Label ProfileCount_Label;
- private System.Windows.Forms.TextBox ProfileCount_TextBox;
+ private System.Windows.Forms.Label ProfileCountLabel;
+ private System.Windows.Forms.TextBox ProfileCountTextBox;
private System.Windows.Forms.CheckBox MinimizeWhenStartedCheckBox;
- private System.Windows.Forms.CheckBox RunAtStartup;
- private System.Windows.Forms.Label STUNServerPortLabel;
+ private System.Windows.Forms.CheckBox RunAtStartupCheckBox;
+ private System.Windows.Forms.Label StunTextBoxSplitLabel;
private System.Windows.Forms.Label STUNServerLabel;
private System.Windows.Forms.TextBox STUN_ServerTextBox;
private System.Windows.Forms.TextBox STUN_ServerPortTextBox;
private System.Windows.Forms.CheckBox ProxyDNSCheckBox;
- private System.Windows.Forms.TextBox DetectionInterval_TextBox;
- private System.Windows.Forms.CheckBox EnableStartedTcping_CheckBox;
- private System.Windows.Forms.Label DelayTestAfterStartup_Label;
- private System.Windows.Forms.Label DetectionInterval_Label;
+ private System.Windows.Forms.TextBox DetectionIntervalTextBox;
+ private System.Windows.Forms.CheckBox TcpingAtStartedCheckBox;
+ private System.Windows.Forms.Label DetectionIntervalLabel;
private System.Windows.Forms.Label RedirectorLabel;
private System.Windows.Forms.TextBox RedirectorTextBox;
- private System.Windows.Forms.TextBox AclAddr;
+ private System.Windows.Forms.TextBox AclAddrTextBox;
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;
+ private System.Windows.Forms.CheckBox ModifySystemDNSCheckBox;
}
}
\ No newline at end of file
diff --git a/Netch/Forms/SettingForm.cs b/Netch/Forms/SettingForm.cs
index 6a147f73..1525e7ae 100644
--- a/Netch/Forms/SettingForm.cs
+++ b/Netch/Forms/SettingForm.cs
@@ -46,74 +46,33 @@ namespace Netch.Forms
}
}
- private void InitText()
+ private void InitValue()
{
- Text = i18N.Translate(Text);
- PortGroupBox.Text = i18N.Translate(PortGroupBox.Text);
- AllowDevicesCheckBox.Text = i18N.Translate(AllowDevicesCheckBox.Text);
- TUNTAPAddressLabel.Text = i18N.Translate(TUNTAPAddressLabel.Text);
- TUNTAPNetmaskLabel.Text = i18N.Translate(TUNTAPNetmaskLabel.Text);
- TUNTAPGatewayLabel.Text = i18N.Translate(TUNTAPGatewayLabel.Text);
- UseCustomDNSCheckBox.Text = i18N.Translate(UseCustomDNSCheckBox.Text);
- ProxyDNSCheckBox.Text = i18N.Translate(ProxyDNSCheckBox.Text);
- UseFakeDNSCheckBox.Text = i18N.Translate(UseFakeDNSCheckBox.Text);
- GlobalBypassIPsButton.Text = i18N.Translate(GlobalBypassIPsButton.Text);
- ControlButton.Text = i18N.Translate(ControlButton.Text);
- BootShadowsocksFromDLLCheckBox.Text = i18N.Translate(BootShadowsocksFromDLLCheckBox.Text);
-
- ExitWhenClosedCheckBox.Checked = Global.Settings.ExitWhenClosed;
- StopWhenExitedCheckBox.Checked = Global.Settings.StopWhenExited;
- StartWhenOpenedCheckBox.Checked = Global.Settings.StartWhenOpened;
- CheckUpdateWhenOpenedCheckBox.Checked = Global.Settings.CheckUpdateWhenOpened;
- MinimizeWhenStartedCheckBox.Checked = Global.Settings.MinimizeWhenStarted;
- RunAtStartup.Checked = Global.Settings.RunAtStartup;
- EnableStartedTcping_CheckBox.Checked = Global.Settings.StartedTcping;
- DetectionInterval_TextBox.Text = Global.Settings.StartedTcping_Interval.ToString();
- BootShadowsocksFromDLLCheckBox.Checked = Global.Settings.BootShadowsocksFromDLL;
-
+ // Local Port
Socks5PortTextBox.Text = Global.Settings.Socks5LocalPort.ToString();
HTTPPortTextBox.Text = Global.Settings.HTTPLocalPort.ToString();
RedirectorTextBox.Text = Global.Settings.RedirectorTCPPort.ToString();
+ switch (Global.Settings.LocalAddress)
+ {
+ case "127.0.0.1":
+ AllowDevicesCheckBox.Checked = false;
+ break;
+ case "0.0.0.0":
+ AllowDevicesCheckBox.Checked = true;
+ break;
+ default:
+ Global.Settings.LocalAddress = "127.0.0.1";
+ AllowDevicesCheckBox.Checked = false;
+ break;
+ }
+ // TUN/TAP
TUNTAPAddressTextBox.Text = Global.Settings.TUNTAP.Address;
TUNTAPNetmaskTextBox.Text = Global.Settings.TUNTAP.Netmask;
TUNTAPGatewayTextBox.Text = Global.Settings.TUNTAP.Gateway;
-
UseCustomDNSCheckBox.Checked = Global.Settings.TUNTAP.UseCustomDNS;
ProxyDNSCheckBox.Checked = Global.Settings.TUNTAP.ProxyDNS;
UseFakeDNSCheckBox.Checked = Global.Settings.TUNTAP.UseFakeDNS;
-
- BehaviorGroupBox.Text = i18N.Translate(BehaviorGroupBox.Text);
- ExitWhenClosedCheckBox.Text = i18N.Translate(ExitWhenClosedCheckBox.Text);
- StopWhenExitedCheckBox.Text = i18N.Translate(StopWhenExitedCheckBox.Text);
- StartWhenOpenedCheckBox.Text = i18N.Translate(StartWhenOpenedCheckBox.Text);
- MinimizeWhenStartedCheckBox.Text = i18N.Translate(MinimizeWhenStartedCheckBox.Text);
- RunAtStartup.Text = i18N.Translate(RunAtStartup.Text);
- CheckUpdateWhenOpenedCheckBox.Text = i18N.Translate(CheckUpdateWhenOpenedCheckBox.Text);
- ProfileCount_Label.Text = i18N.Translate(ProfileCount_Label.Text);
- DelayTestAfterStartup_Label.Text = i18N.Translate(DelayTestAfterStartup_Label.Text);
- EnableStartedTcping_CheckBox.Text = i18N.Translate(EnableStartedTcping_CheckBox.Text);
- DetectionInterval_Label.Text = i18N.Translate(DetectionInterval_Label.Text);
- DelayTestAfterStartup_Label.Text = i18N.Translate(DelayTestAfterStartup_Label.Text);
- STUNServerLabel.Text = i18N.Translate(STUNServerLabel.Text);
- STUNServerPortLabel.Text = i18N.Translate(STUNServerPortLabel.Text);
-
- ProfileCount_TextBox.Text = Global.Settings.ProfileCount.ToString();
- STUN_ServerTextBox.Text = Global.Settings.STUN_Server;
- STUN_ServerPortTextBox.Text = Global.Settings.STUN_Server_Port.ToString();
-
- AclLabel.Text = i18N.Translate(AclLabel.Text);
- AclAddr.Text = Global.Settings.ACL;
-
- LanguageLabel.Text = i18N.Translate(LanguageLabel.Text);
- LanguageComboBox.Items.AddRange(i18N.GetTranslateList().ToArray());
- LanguageComboBox.SelectedItem = Global.Settings.Language;
- }
-
- private void SettingForm_Load(object sender, EventArgs e)
- {
- InitText();
-
if (Global.Settings.TUNTAP.DNS.Count > 0)
{
var dns = "";
@@ -126,9 +85,9 @@ namespace Netch.Forms
dns = dns.Trim();
TUNTAPDNSTextBox.Text = dns.Substring(0, dns.Length - 1);
}
- // 如果 DNS 为空,设置为默认 DNS 1.1.1.1
else
{
+ // 如果 DNS 为空,设置为默认 DNS 1.1.1.1
Global.Settings.TUNTAP.DNS.Add("1.1.1.1");
TUNTAPDNSTextBox.Text = "1.1.1.1";
}
@@ -138,20 +97,63 @@ namespace Netch.Forms
TUNTAPDNSTextBox.Enabled = false;
}
- // 设置本地代理是否允许其他设备连接
- if (Global.Settings.LocalAddress == "127.0.0.1")
- {
- AllowDevicesCheckBox.Checked = false;
- }
- else if (Global.Settings.LocalAddress == "0.0.0.0")
- {
- AllowDevicesCheckBox.Checked = true;
- }
- else
- {
- Global.Settings.LocalAddress = "127.0.0.1";
- AllowDevicesCheckBox.Checked = false;
- }
+ // Behavior
+ ExitWhenClosedCheckBox.Checked = Global.Settings.ExitWhenClosed;
+ StopWhenExitedCheckBox.Checked = Global.Settings.StopWhenExited;
+ StartWhenOpenedCheckBox.Checked = Global.Settings.StartWhenOpened;
+ MinimizeWhenStartedCheckBox.Checked = Global.Settings.MinimizeWhenStarted;
+ RunAtStartupCheckBox.Checked = Global.Settings.RunAtStartup;
+ CheckUpdateWhenOpenedCheckBox.Checked = Global.Settings.CheckUpdateWhenOpened;
+ BootShadowsocksFromDLLCheckBox.Checked = Global.Settings.BootShadowsocksFromDLL;
+ ModifySystemDNSCheckBox.Checked = Global.Settings.ModifySystemDNS;
+
+ ProfileCountTextBox.Text = Global.Settings.ProfileCount.ToString();
+ TcpingAtStartedCheckBox.Checked = Global.Settings.StartedTcping;
+ DetectionIntervalTextBox.Text = Global.Settings.StartedTcping_Interval.ToString();
+ STUN_ServerTextBox.Text = Global.Settings.STUN_Server;
+ STUN_ServerPortTextBox.Text = Global.Settings.STUN_Server_Port.ToString();
+ AclAddrTextBox.Text = Global.Settings.ACL;
+ LanguageComboBox.Items.AddRange(i18N.GetTranslateList().ToArray());
+ LanguageComboBox.SelectedItem = Global.Settings.Language;
+ }
+
+ private void InitText()
+ {
+ Text = i18N.Translate(Text);
+
+ PortGroupBox.Text = i18N.Translate(PortGroupBox.Text);
+ AllowDevicesCheckBox.Text = i18N.Translate(AllowDevicesCheckBox.Text);
+ TUNTAPAddressLabel.Text = i18N.Translate(TUNTAPAddressLabel.Text);
+ TUNTAPNetmaskLabel.Text = i18N.Translate(TUNTAPNetmaskLabel.Text);
+ TUNTAPGatewayLabel.Text = i18N.Translate(TUNTAPGatewayLabel.Text);
+ UseCustomDNSCheckBox.Text = i18N.Translate(UseCustomDNSCheckBox.Text);
+ ProxyDNSCheckBox.Text = i18N.Translate(ProxyDNSCheckBox.Text);
+ UseFakeDNSCheckBox.Text = i18N.Translate(UseFakeDNSCheckBox.Text);
+ GlobalBypassIPsButton.Text = i18N.Translate(GlobalBypassIPsButton.Text);
+ ControlButton.Text = i18N.Translate(ControlButton.Text);
+ BootShadowsocksFromDLLCheckBox.Text = i18N.Translate(BootShadowsocksFromDLLCheckBox.Text);
+ ModifySystemDNSCheckBox.Text = i18N.Translate(ModifySystemDNSCheckBox.Text);
+ BehaviorGroupBox.Text = i18N.Translate(BehaviorGroupBox.Text);
+ ExitWhenClosedCheckBox.Text = i18N.Translate(ExitWhenClosedCheckBox.Text);
+ StopWhenExitedCheckBox.Text = i18N.Translate(StopWhenExitedCheckBox.Text);
+ StartWhenOpenedCheckBox.Text = i18N.Translate(StartWhenOpenedCheckBox.Text);
+ MinimizeWhenStartedCheckBox.Text = i18N.Translate(MinimizeWhenStartedCheckBox.Text);
+ RunAtStartupCheckBox.Text = i18N.Translate(RunAtStartupCheckBox.Text);
+ CheckUpdateWhenOpenedCheckBox.Text = i18N.Translate(CheckUpdateWhenOpenedCheckBox.Text);
+ ProfileCountLabel.Text = i18N.Translate(ProfileCountLabel.Text);
+ TcpingAtStartedCheckBox.Text = i18N.Translate(TcpingAtStartedCheckBox.Text);
+ DetectionIntervalLabel.Text = i18N.Translate(DetectionIntervalLabel.Text);
+ STUNServerLabel.Text = i18N.Translate(STUNServerLabel.Text);
+ StunTextBoxSplitLabel.Text = i18N.Translate(StunTextBoxSplitLabel.Text);
+ AclLabel.Text = i18N.Translate(AclLabel.Text);
+ LanguageLabel.Text = i18N.Translate(LanguageLabel.Text);
+ }
+
+ private void SettingForm_Load(object sender, EventArgs e)
+ {
+ InitText();
+
+ InitValue();
}
private void SettingForm_FormClosing(object sender, FormClosingEventArgs e)
@@ -172,7 +174,7 @@ namespace Netch.Forms
Global.Settings.StartWhenOpened = StartWhenOpenedCheckBox.Checked;
Global.Settings.CheckUpdateWhenOpened = CheckUpdateWhenOpenedCheckBox.Checked;
Global.Settings.MinimizeWhenStarted = MinimizeWhenStartedCheckBox.Checked;
- Global.Settings.RunAtStartup = RunAtStartup.Checked;
+ Global.Settings.RunAtStartup = RunAtStartupCheckBox.Checked;
Global.Settings.BootShadowsocksFromDLL = BootShadowsocksFromDLLCheckBox.Checked;
Global.Settings.Language = LanguageComboBox.SelectedItem.ToString();
@@ -191,7 +193,7 @@ namespace Netch.Forms
// ignored
}
- if (RunAtStartup.Checked)
+ if (RunAtStartupCheckBox.Checked)
{
if (taskIsExists)
folder.DeleteTask("Netch Startup", 0);
@@ -264,7 +266,7 @@ namespace Netch.Forms
try
{
- var ProfileCount = int.Parse(ProfileCount_TextBox.Text);
+ var ProfileCount = int.Parse(ProfileCountTextBox.Text);
if (ProfileCount > -1)
{
@@ -277,7 +279,7 @@ namespace Netch.Forms
}
catch (FormatException)
{
- ProfileCount_TextBox.Text = Global.Settings.ProfileCount.ToString();
+ ProfileCountTextBox.Text = Global.Settings.ProfileCount.ToString();
MessageBoxX.Show(i18N.Translate("ProfileCount value illegal. Try again."));
return;
@@ -301,7 +303,7 @@ namespace Netch.Forms
}
catch (FormatException)
{
- ProfileCount_TextBox.Text = Global.Settings.ProfileCount.ToString();
+ ProfileCountTextBox.Text = Global.Settings.ProfileCount.ToString();
MessageBoxX.Show(i18N.Translate("STUN_ServerPort value illegal. Try again."));
return;
@@ -309,9 +311,9 @@ namespace Netch.Forms
try
{
- Global.Settings.StartedTcping = EnableStartedTcping_CheckBox.Checked;
+ Global.Settings.StartedTcping = TcpingAtStartedCheckBox.Checked;
- var DetectionInterval = int.Parse(DetectionInterval_TextBox.Text);
+ var DetectionInterval = int.Parse(DetectionIntervalTextBox.Text);
if (DetectionInterval > 0)
{
@@ -324,13 +326,13 @@ namespace Netch.Forms
}
catch (FormatException)
{
- ProfileCount_TextBox.Text = Global.Settings.ProfileCount.ToString();
+ ProfileCountTextBox.Text = Global.Settings.ProfileCount.ToString();
MessageBoxX.Show(i18N.Translate("Detection interval value illegal. Try again."));
return;
}
- Global.Settings.ACL = AclAddr.Text;
+ Global.Settings.ACL = AclAddrTextBox.Text;
Global.Settings.TUNTAP.Address = TUNTAPAddressTextBox.Text;
Global.Settings.TUNTAP.Netmask = TUNTAPNetmaskTextBox.Text;
@@ -346,6 +348,8 @@ namespace Netch.Forms
Global.Settings.TUNTAP.ProxyDNS = ProxyDNSCheckBox.Checked;
Global.Settings.TUNTAP.UseFakeDNS = UseFakeDNSCheckBox.Checked;
+ Global.Settings.ModifySystemDNS = ModifySystemDNSCheckBox.Checked;
+
Configuration.Save();
MessageBoxX.Show(i18N.Translate("Saved"));
Close();
diff --git a/Netch/Models/Setting.cs b/Netch/Models/Setting.cs
index 10806750..167d4863 100644
--- a/Netch/Models/Setting.cs
+++ b/Netch/Models/Setting.cs
@@ -88,6 +88,11 @@ namespace Netch.Models
///
public bool CheckUpdateWhenOpened = true;
+ ///
+ /// 修改系统 DNS
+ ///
+ public bool ModifySystemDNS = false;
+
///
/// 使用何种模式文件名
/// 0 为自定义文件名,1 为使用和备注一致的文件名,2 为使用时间数据作为文件名
diff --git a/Netch/Resources/zh-CN b/Netch/Resources/zh-CN
index fdb37a1e..b31bde0c 100644
--- a/Netch/Resources/zh-CN
+++ b/Netch/Resources/zh-CN
@@ -74,8 +74,8 @@
"Update servers error from {0}": "从 {0} 更新服务器失败",
"Options": "选项",
- "Uninstall Service": "卸载服务",
- "Uninstalling Service": "正在卸载服务中",
+ "Uninstall NF Service": "卸载 NF 服务",
+ "Uninstalling NF Service": "正在 NF 卸载服务中",
"Service has been uninstalled": "服务已卸载",
"Reload Modes": "重载模式",
"Modes have been reload": "模式已重载",
@@ -157,6 +157,7 @@
"Port value illegal. Try again.": "端口值非法。请重试。",
"Check update when opened": "打开软件时检查更新",
"Start Shadowsocks from DLL (No support for ACL)": "SS DLL(推荐使用,不支持 ACL)",
+ "Modify System DNS": "修改系统 DNS",
"ProfileCount": "快捷配置数量",
"ProfileCount value illegal. Try again.": "快捷配置数值非法。请重试。",
"STUN_ServerPort value illegal. Try again.": "STUN 端口数值非法。请重试。",