From 4b3d6fb3bf52ead67b59d3aa6a515f1acf152bb4 Mon Sep 17 00:00:00 2001 From: AmazingDM Date: Sat, 6 Mar 2021 14:04:50 +0800 Subject: [PATCH] DNS , ICMP Redirector Child process handle --- Netch/Controllers/NFController.cs | 97 +++++++++---------- Netch/Forms/SettingForm.Designer.cs | 142 ++++++++++++++++++++-------- Netch/Forms/SettingForm.cs | 10 +- Netch/Forms/SettingForm.resx | 120 +++++++++++++++++++++++ Netch/Models/Setting.cs | 23 ++++- Netch/Resources/zh-CN | 3 + binaries | 2 +- 7 files changed, 303 insertions(+), 94 deletions(-) create mode 100644 Netch/Forms/SettingForm.resx diff --git a/Netch/Controllers/NFController.cs b/Netch/Controllers/NFController.cs index e3d1cf29..4c57973e 100644 --- a/Netch/Controllers/NFController.cs +++ b/Netch/Controllers/NFController.cs @@ -20,9 +20,6 @@ namespace Netch.Controllers private static readonly string BinDriver; private static readonly string SystemDriver = $"{Environment.SystemDirectory}\\drivers\\netfilter2.sys"; - private static string? _sysDns; - private OutboundAdapter? _outbound; - static NFController() { string fileName; @@ -54,11 +51,11 @@ namespace Netch.Controllers #region aio_dial - aio_dial((int) NameList.TYPE_FILTERLOOPBACK, "false"); - aio_dial((int) NameList.TYPE_TCPLISN, Global.Settings.RedirectorTCPPort.ToString()); + aio_dial((int)NameList.TYPE_FILTERLOOPBACK, "false"); + aio_dial((int)NameList.TYPE_TCPLISN, Global.Settings.RedirectorTCPPort.ToString()); - aio_dial((int) NameList.TYPE_FILTERUDP, (Global.Settings.ProcessProxyProtocol != PortType.TCP).ToString().ToLower()); - aio_dial((int) NameList.TYPE_FILTERTCP, (Global.Settings.ProcessProxyProtocol != PortType.UDP).ToString().ToLower()); + aio_dial((int)NameList.TYPE_FILTERUDP, (Global.Settings.ProcessProxyProtocol != PortType.TCP).ToString().ToLower()); + aio_dial((int)NameList.TYPE_FILTERTCP, (Global.Settings.ProcessProxyProtocol != PortType.UDP).ToString().ToLower()); SetServer(Global.Settings.ProcessProxyProtocol); if (!CheckRule(mode.FullRule, out var list)) @@ -68,16 +65,13 @@ namespace Netch.Controllers #endregion - if (Global.Settings.ModifySystemDNS) - { - _outbound = new OutboundAdapter(); - // 备份并替换系统 DNS - _sysDns = _outbound.DNS; - if (string.IsNullOrWhiteSpace(Global.Settings.ModifiedDNS)) - Global.Settings.ModifiedDNS = "1.1.1.1,8.8.8.8"; + if (Global.Settings.RedirectDNS) + aio_dial((int)NameList.TYPE_REDIRCTOR_DNS, Global.Settings.RedirectDNSAddr.ToString()); - _outbound.DNS = Global.Settings.ModifiedDNS; - } + if (Global.Settings.RedirectICMP) + aio_dial((int)NameList.TYPE_REDIRCTOR_ICMP, Global.Settings.RedirectICMPAddr.ToString()); + + aio_dial((int)NameList.TYPE_FILTERCHILDPROC, Global.Settings.ChildProcessHandle.ToString()); if (!aio_init()) throw new MessageException("Redirector Start failed, run Netch with \"-console\" argument"); @@ -85,13 +79,6 @@ namespace Netch.Controllers public void Stop() { - Task.Run(() => - { - if (Global.Settings.ModifySystemDNS) - //恢复系统DNS - _outbound!.DNS = _sysDns!; - }); - aio_free(); } @@ -103,7 +90,7 @@ namespace Netch.Controllers public static bool CheckRule(IEnumerable rules, out IEnumerable incompatibleRule) { incompatibleRule = rules.Where(r => !CheckCppRegex(r, false)); - aio_dial((int) NameList.TYPE_CLRNAME, ""); + aio_dial((int)NameList.TYPE_CLRNAME, ""); return !incompatibleRule.Any(); } @@ -117,14 +104,14 @@ namespace Netch.Controllers try { if (r.StartsWith("!")) - return aio_dial((int) NameList.TYPE_ADDNAME, r.Substring(1)); + return aio_dial((int)NameList.TYPE_ADDNAME, r.Substring(1)); - return aio_dial((int) NameList.TYPE_ADDNAME, r); + return aio_dial((int)NameList.TYPE_ADDNAME, r); } finally { if (clear) - aio_dial((int) NameList.TYPE_CLRNAME, ""); + aio_dial((int)NameList.TYPE_CLRNAME, ""); } } @@ -194,50 +181,50 @@ namespace Netch.Controllers if (server is Socks5 socks5) { - aio_dial((int) NameList.TYPE_TCPTYPE + offset, "Socks5"); - aio_dial((int) NameList.TYPE_TCPHOST + offset, $"{socks5.AutoResolveHostname()}:{socks5.Port}"); - aio_dial((int) NameList.TYPE_TCPUSER + offset, socks5.Username ?? string.Empty); - aio_dial((int) NameList.TYPE_TCPPASS + offset, socks5.Password ?? string.Empty); - aio_dial((int) NameList.TYPE_TCPMETH + offset, string.Empty); + aio_dial((int)NameList.TYPE_TCPTYPE + offset, "Socks5"); + aio_dial((int)NameList.TYPE_TCPHOST + offset, $"{socks5.AutoResolveHostname()}:{socks5.Port}"); + aio_dial((int)NameList.TYPE_TCPUSER + offset, socks5.Username ?? string.Empty); + aio_dial((int)NameList.TYPE_TCPPASS + offset, socks5.Password ?? string.Empty); + aio_dial((int)NameList.TYPE_TCPMETH + offset, string.Empty); } else if (server is Shadowsocks shadowsocks && !shadowsocks.HasPlugin() && Global.Settings.RedirectorSS) { - aio_dial((int) NameList.TYPE_TCPTYPE + offset, "Shadowsocks"); - aio_dial((int) NameList.TYPE_TCPHOST + offset, $"{shadowsocks.AutoResolveHostname()}:{shadowsocks.Port}"); - aio_dial((int) NameList.TYPE_TCPMETH + offset, shadowsocks.EncryptMethod ?? string.Empty); - aio_dial((int) NameList.TYPE_TCPPASS + offset, shadowsocks.Password ?? string.Empty); + aio_dial((int)NameList.TYPE_TCPTYPE + offset, "Shadowsocks"); + aio_dial((int)NameList.TYPE_TCPHOST + offset, $"{shadowsocks.AutoResolveHostname()}:{shadowsocks.Port}"); + aio_dial((int)NameList.TYPE_TCPMETH + offset, shadowsocks.EncryptMethod ?? string.Empty); + aio_dial((int)NameList.TYPE_TCPPASS + offset, shadowsocks.Password ?? string.Empty); } else { - aio_dial((int) NameList.TYPE_TCPTYPE + offset, "Socks5"); - aio_dial((int) NameList.TYPE_TCPHOST + offset, $"127.0.0.1:{controller.Socks5LocalPort()}"); - aio_dial((int) NameList.TYPE_TCPUSER + offset, string.Empty); - aio_dial((int) NameList.TYPE_TCPPASS + offset, string.Empty); - aio_dial((int) NameList.TYPE_TCPMETH + offset, string.Empty); + aio_dial((int)NameList.TYPE_TCPTYPE + offset, "Socks5"); + aio_dial((int)NameList.TYPE_TCPHOST + offset, $"127.0.0.1:{controller.Socks5LocalPort()}"); + aio_dial((int)NameList.TYPE_TCPUSER + offset, string.Empty); + aio_dial((int)NameList.TYPE_TCPPASS + offset, string.Empty); + aio_dial((int)NameList.TYPE_TCPMETH + offset, string.Empty); } } private void SetName(Mode mode) { - aio_dial((int) NameList.TYPE_CLRNAME, ""); + aio_dial((int)NameList.TYPE_CLRNAME, ""); foreach (var rule in mode.FullRule) { if (rule.StartsWith("!")) { - aio_dial((int) NameList.TYPE_BYPNAME, rule.Substring(1)); + aio_dial((int)NameList.TYPE_BYPNAME, rule.Substring(1)); continue; } - aio_dial((int) NameList.TYPE_ADDNAME, rule); + aio_dial((int)NameList.TYPE_ADDNAME, rule); } - aio_dial((int) NameList.TYPE_ADDNAME, @"NTT\.exe"); - aio_dial((int) NameList.TYPE_BYPNAME, "^" + Global.NetchDir.ToRegexString() + @"((?!NTT\.exe).)*$"); + aio_dial((int)NameList.TYPE_ADDNAME, @"NTT\.exe"); + aio_dial((int)NameList.TYPE_BYPNAME, "^" + Global.NetchDir.ToRegexString() + @"((?!NTT\.exe).)*$"); } #region NativeMethods - private const int UdpNameListOffset = (int) NameList.TYPE_UDPTYPE - (int) NameList.TYPE_TCPTYPE; + private const int UdpNameListOffset = (int)NameList.TYPE_UDPTYPE - (int)NameList.TYPE_TCPTYPE; [DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)] private static extern bool aio_dial(int name, [MarshalAs(UnmanagedType.LPWStr)] string value); @@ -256,23 +243,37 @@ namespace Netch.Controllers public enum NameList { + //bool TYPE_FILTERLOOPBACK, TYPE_FILTERTCP, TYPE_FILTERUDP, + TYPE_FILTERIP, + TYPE_FILTERCHILDPROC,//子进程捕获 + TYPE_TCPLISN, TYPE_TCPTYPE, TYPE_TCPHOST, TYPE_TCPUSER, TYPE_TCPPASS, TYPE_TCPMETH, + TYPE_UDPTYPE, TYPE_UDPHOST, TYPE_UDPUSER, TYPE_UDPPASS, TYPE_UDPMETH, + TYPE_ADDNAME, + TYPE_ADDFIP, + TYPE_BYPNAME, - TYPE_CLRNAME + + TYPE_CLRNAME, + TYPE_CLRFIP, + + //str addr x.x.x.x only ipv4 + TYPE_REDIRCTOR_DNS, + TYPE_REDIRCTOR_ICMP } #endregion diff --git a/Netch/Forms/SettingForm.Designer.cs b/Netch/Forms/SettingForm.Designer.cs index 284256e2..8c37c7d6 100644 --- a/Netch/Forms/SettingForm.Designer.cs +++ b/Netch/Forms/SettingForm.Designer.cs @@ -59,12 +59,17 @@ namespace Netch.Forms this.LanguageLabel = new System.Windows.Forms.Label(); this.LanguageComboBox = new System.Windows.Forms.ComboBox(); this.NFTabPage = new System.Windows.Forms.TabPage(); - this.ProcessProxyProtocolComboBox = new System.Windows.Forms.ComboBox(); - this.ModifySystemDNSCheckBox = new System.Windows.Forms.CheckBox(); - this.ProcessProxyProtocolLabel = new System.Windows.Forms.Label(); - this.ModifiedDNSLabel = new System.Windows.Forms.Label(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.DNSRedirectorCheckBox = new System.Windows.Forms.CheckBox(); this.ModifiedDNSTextBox = new System.Windows.Forms.TextBox(); + this.ModifiedICMPTextBox = new System.Windows.Forms.TextBox(); + this.ICMPRedirectorCheckBox = new System.Windows.Forms.CheckBox(); + this.label1 = new System.Windows.Forms.Label(); + this.ModifiedDNSLabel = new System.Windows.Forms.Label(); + this.ChildProcessHandleCheckBox = new System.Windows.Forms.CheckBox(); this.RedirectorSSCheckBox = new System.Windows.Forms.CheckBox(); + this.ProcessProxyProtocolLabel = new System.Windows.Forms.Label(); + this.ProcessProxyProtocolComboBox = new System.Windows.Forms.ComboBox(); this.TAPTabPage = new System.Windows.Forms.TabPage(); this.TUNTAPGroupBox = new System.Windows.Forms.GroupBox(); this.TUNTAPAddressLabel = new System.Windows.Forms.Label(); @@ -119,6 +124,7 @@ namespace Netch.Forms this.GeneralTabPage.SuspendLayout(); this.PortGroupBox.SuspendLayout(); this.NFTabPage.SuspendLayout(); + this.groupBox1.SuspendLayout(); this.TAPTabPage.SuspendLayout(); this.TUNTAPGroupBox.SuspendLayout(); this.v2rayTabPage.SuspendLayout(); @@ -406,9 +412,8 @@ namespace Netch.Forms // NFTabPage // this.NFTabPage.BackColor = System.Drawing.SystemColors.ButtonFace; - this.NFTabPage.Controls.Add(this.ModifySystemDNSCheckBox); - this.NFTabPage.Controls.Add(this.ModifiedDNSLabel); - this.NFTabPage.Controls.Add(this.ModifiedDNSTextBox); + this.NFTabPage.Controls.Add(this.groupBox1); + this.NFTabPage.Controls.Add(this.ChildProcessHandleCheckBox); this.NFTabPage.Controls.Add(this.RedirectorSSCheckBox); this.NFTabPage.Controls.Add(this.ProcessProxyProtocolLabel); this.NFTabPage.Controls.Add(this.ProcessProxyProtocolComboBox); @@ -419,62 +424,114 @@ namespace Netch.Forms this.NFTabPage.TabIndex = 1; this.NFTabPage.Text = "Process Mode"; // - // ProcessProxyProtocolComboBox + // groupBox1 // - this.ProcessProxyProtocolComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.ProcessProxyProtocolComboBox.FormattingEnabled = true; - this.ProcessProxyProtocolComboBox.Location = new System.Drawing.Point(167, 58); - this.ProcessProxyProtocolComboBox.Name = "ProcessProxyProtocolComboBox"; - this.ProcessProxyProtocolComboBox.Size = new System.Drawing.Size(121, 20); - this.ProcessProxyProtocolComboBox.TabIndex = 3; + this.groupBox1.Controls.Add(this.DNSRedirectorCheckBox); + this.groupBox1.Controls.Add(this.ModifiedDNSTextBox); + this.groupBox1.Controls.Add(this.ModifiedICMPTextBox); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Controls.Add(this.ModifiedDNSLabel); + this.groupBox1.Controls.Add(this.ICMPRedirectorCheckBox); + this.groupBox1.Location = new System.Drawing.Point(5, 6); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(450, 81); + this.groupBox1.TabIndex = 8; + this.groupBox1.TabStop = false; // - // ModifySystemDNSCheckBox + // DNSRedirectorCheckBox // - this.ModifySystemDNSCheckBox.AutoSize = true; - this.ModifySystemDNSCheckBox.Location = new System.Drawing.Point(8, 16); - this.ModifySystemDNSCheckBox.Name = "ModifySystemDNSCheckBox"; - this.ModifySystemDNSCheckBox.Size = new System.Drawing.Size(126, 16); - this.ModifySystemDNSCheckBox.TabIndex = 0; - this.ModifySystemDNSCheckBox.Text = "Modify System DNS"; - this.ModifySystemDNSCheckBox.UseVisualStyleBackColor = true; + this.DNSRedirectorCheckBox.AutoSize = true; + this.DNSRedirectorCheckBox.Location = new System.Drawing.Point(6, 20); + this.DNSRedirectorCheckBox.Name = "DNSRedirectorCheckBox"; + this.DNSRedirectorCheckBox.Size = new System.Drawing.Size(108, 16); + this.DNSRedirectorCheckBox.TabIndex = 0; + this.DNSRedirectorCheckBox.Text = "DNS Redirector"; + this.DNSRedirectorCheckBox.UseVisualStyleBackColor = true; // - // ProcessProxyProtocolLabel + // ModifiedDNSTextBox // - this.ProcessProxyProtocolLabel.AutoSize = true; - this.ProcessProxyProtocolLabel.Location = new System.Drawing.Point(24, 61); - this.ProcessProxyProtocolLabel.Name = "ProcessProxyProtocolLabel"; - this.ProcessProxyProtocolLabel.Size = new System.Drawing.Size(89, 12); - this.ProcessProxyProtocolLabel.TabIndex = 2; - this.ProcessProxyProtocolLabel.Text = "Proxy Protocol"; + this.ModifiedDNSTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Enabled", this.DNSRedirectorCheckBox, "Checked", true)); + this.ModifiedDNSTextBox.Location = new System.Drawing.Point(253, 15); + this.ModifiedDNSTextBox.Name = "ModifiedDNSTextBox"; + this.ModifiedDNSTextBox.Size = new System.Drawing.Size(191, 21); + this.ModifiedDNSTextBox.TabIndex = 1; + this.ModifiedDNSTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // ModifiedICMPTextBox + // + this.ModifiedICMPTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Enabled", this.ICMPRedirectorCheckBox, "Checked", true)); + this.ModifiedICMPTextBox.Location = new System.Drawing.Point(253, 47); + this.ModifiedICMPTextBox.Name = "ModifiedICMPTextBox"; + this.ModifiedICMPTextBox.Size = new System.Drawing.Size(191, 21); + this.ModifiedICMPTextBox.TabIndex = 5; + this.ModifiedICMPTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // ICMPRedirectorCheckBox + // + this.ICMPRedirectorCheckBox.AutoSize = true; + this.ICMPRedirectorCheckBox.Location = new System.Drawing.Point(6, 50); + this.ICMPRedirectorCheckBox.Name = "ICMPRedirectorCheckBox"; + this.ICMPRedirectorCheckBox.Size = new System.Drawing.Size(114, 16); + this.ICMPRedirectorCheckBox.TabIndex = 4; + this.ICMPRedirectorCheckBox.Text = "ICMP Redirector"; + this.ICMPRedirectorCheckBox.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(218, 50); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(29, 12); + this.label1.TabIndex = 6; + this.label1.Text = "ICMP"; // // ModifiedDNSLabel // this.ModifiedDNSLabel.AutoSize = true; - this.ModifiedDNSLabel.Location = new System.Drawing.Point(223, 17); + this.ModifiedDNSLabel.Location = new System.Drawing.Point(224, 21); this.ModifiedDNSLabel.Name = "ModifiedDNSLabel"; this.ModifiedDNSLabel.Size = new System.Drawing.Size(23, 12); this.ModifiedDNSLabel.TabIndex = 2; this.ModifiedDNSLabel.Text = "DNS"; // - // ModifiedDNSTextBox + // ChildProcessHandleCheckBox // - this.ModifiedDNSTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Enabled", this.ModifySystemDNSCheckBox, "Checked", true)); - this.ModifiedDNSTextBox.Location = new System.Drawing.Point(264, 14); - this.ModifiedDNSTextBox.Name = "ModifiedDNSTextBox"; - this.ModifiedDNSTextBox.Size = new System.Drawing.Size(194, 21); - this.ModifiedDNSTextBox.TabIndex = 1; - this.ModifiedDNSTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.ChildProcessHandleCheckBox.AutoSize = true; + this.ChildProcessHandleCheckBox.Location = new System.Drawing.Point(11, 119); + this.ChildProcessHandleCheckBox.Name = "ChildProcessHandleCheckBox"; + this.ChildProcessHandleCheckBox.Size = new System.Drawing.Size(144, 16); + this.ChildProcessHandleCheckBox.TabIndex = 7; + this.ChildProcessHandleCheckBox.Text = "Child Process Handle"; + this.ChildProcessHandleCheckBox.UseVisualStyleBackColor = true; // // RedirectorSSCheckBox // this.RedirectorSSCheckBox.AutoSize = true; - this.RedirectorSSCheckBox.Location = new System.Drawing.Point(8, 38); + this.RedirectorSSCheckBox.Location = new System.Drawing.Point(11, 97); this.RedirectorSSCheckBox.Name = "RedirectorSSCheckBox"; this.RedirectorSSCheckBox.Size = new System.Drawing.Size(102, 16); this.RedirectorSSCheckBox.TabIndex = 0; this.RedirectorSSCheckBox.Text = "Redirector SS"; this.RedirectorSSCheckBox.UseVisualStyleBackColor = true; // + // ProcessProxyProtocolLabel + // + this.ProcessProxyProtocolLabel.AutoSize = true; + this.ProcessProxyProtocolLabel.Location = new System.Drawing.Point(163, 98); + this.ProcessProxyProtocolLabel.Name = "ProcessProxyProtocolLabel"; + this.ProcessProxyProtocolLabel.Size = new System.Drawing.Size(89, 12); + this.ProcessProxyProtocolLabel.TabIndex = 2; + this.ProcessProxyProtocolLabel.Text = "Proxy Protocol"; + // + // ProcessProxyProtocolComboBox + // + this.ProcessProxyProtocolComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.ProcessProxyProtocolComboBox.FormattingEnabled = true; + this.ProcessProxyProtocolComboBox.Location = new System.Drawing.Point(258, 93); + this.ProcessProxyProtocolComboBox.Name = "ProcessProxyProtocolComboBox"; + this.ProcessProxyProtocolComboBox.Size = new System.Drawing.Size(191, 20); + this.ProcessProxyProtocolComboBox.TabIndex = 3; + // // TAPTabPage // this.TAPTabPage.BackColor = System.Drawing.SystemColors.ButtonFace; @@ -1012,6 +1069,8 @@ namespace Netch.Forms this.PortGroupBox.PerformLayout(); this.NFTabPage.ResumeLayout(false); this.NFTabPage.PerformLayout(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); this.TAPTabPage.ResumeLayout(false); this.TUNTAPGroupBox.ResumeLayout(false); this.TUNTAPGroupBox.PerformLayout(); @@ -1061,7 +1120,7 @@ namespace Netch.Forms private System.Windows.Forms.Label TUNTAPAddressLabel; private System.Windows.Forms.TextBox TUNTAPAddressTextBox; private System.Windows.Forms.Button GlobalBypassIPsButton; - private System.Windows.Forms.CheckBox ModifySystemDNSCheckBox; + private System.Windows.Forms.CheckBox DNSRedirectorCheckBox; private System.Windows.Forms.Button ControlButton; private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; private System.Windows.Forms.TabPage OtherTabPage; @@ -1115,5 +1174,10 @@ namespace Netch.Forms private System.Windows.Forms.RadioButton ICMPingRadioBtn; private System.Windows.Forms.ComboBox ProcessProxyProtocolComboBox; private System.Windows.Forms.Label ProcessProxyProtocolLabel; + private System.Windows.Forms.CheckBox ICMPRedirectorCheckBox; + private System.Windows.Forms.TextBox ModifiedICMPTextBox; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.CheckBox ChildProcessHandleCheckBox; + private System.Windows.Forms.GroupBox groupBox1; } } \ No newline at end of file diff --git a/Netch/Forms/SettingForm.cs b/Netch/Forms/SettingForm.cs index 3c45cc76..e1596c92 100644 --- a/Netch/Forms/SettingForm.cs +++ b/Netch/Forms/SettingForm.cs @@ -109,12 +109,18 @@ namespace Netch.Forms #region Process Mode - BindCheckBox(ModifySystemDNSCheckBox, b => Global.Settings.ModifySystemDNS = b, Global.Settings.ModifySystemDNS); + BindCheckBox(DNSRedirectorCheckBox, b => Global.Settings.RedirectDNS = b, Global.Settings.RedirectDNS); - BindTextBox(ModifiedDNSTextBox, s => DnsUtils.TrySplit(s, out _, 2), s => Global.Settings.ModifiedDNS = s, Global.Settings.ModifiedDNS); + BindTextBox(ModifiedDNSTextBox, s => DnsUtils.TrySplit(s, out _, 2), s => Global.Settings.RedirectDNSAddr = s, Global.Settings.RedirectDNSAddr); + + BindCheckBox(ICMPRedirectorCheckBox, b => Global.Settings.RedirectICMP = b, Global.Settings.RedirectICMP); + + BindTextBox(ModifiedICMPTextBox, s => DnsUtils.TrySplit(s, out _, 2), s => Global.Settings.RedirectICMPAddr = s, Global.Settings.RedirectICMPAddr); BindCheckBox(RedirectorSSCheckBox, s => Global.Settings.RedirectorSS = s, Global.Settings.RedirectorSS); + BindCheckBox(ChildProcessHandleCheckBox, s => Global.Settings.ChildProcessHandle = s, Global.Settings.ChildProcessHandle); + BindListComboBox(ProcessProxyProtocolComboBox, s => Global.Settings.ProcessProxyProtocol = (PortType) Enum.Parse(typeof(PortType), s.ToString(), false), Enum.GetNames(typeof(PortType)).Cast().ToArray(), diff --git a/Netch/Forms/SettingForm.resx b/Netch/Forms/SettingForm.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/Netch/Forms/SettingForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Netch/Models/Setting.cs b/Netch/Models/Setting.cs index 6c9e220c..5a7a83f8 100644 --- a/Netch/Models/Setting.cs +++ b/Netch/Models/Setting.cs @@ -158,14 +158,24 @@ namespace Netch.Models public int ModeComboBoxSelectedIndex { get; set; } = 0; /// - /// 要修改为的系统 DNS + /// 转发DNS地址 /// - public string ModifiedDNS { get; set; } = "1.1.1.1,8.8.8.8"; + public string RedirectDNSAddr { get; set; } = "8.8.8.8"; /// - /// 修改系统 DNS + /// 是否开启DNS转发 /// - public bool ModifySystemDNS { get; set; } = false; + public bool RedirectDNS { get; set; } = false; + + /// + /// 转发ICMP地址 + /// + public string RedirectICMPAddr { get; set; } = "1.2.4.8"; + + /// + /// 是否开启ICMP转发 + /// + public bool RedirectICMP { get; set; } = false; /// /// GFWList @@ -202,6 +212,11 @@ namespace Netch.Models /// public bool RedirectorSS { get; set; } = false; + /// + /// 是否代理子进程 + /// + public bool ChildProcessHandle { get; set; } = false; + /// /// Redirector TCP 占用端口 /// diff --git a/Netch/Resources/zh-CN b/Netch/Resources/zh-CN index 549a0afb..75650e9c 100644 --- a/Netch/Resources/zh-CN +++ b/Netch/Resources/zh-CN @@ -165,6 +165,9 @@ "SS DLL": "SS DLL", "Modify System DNS": "修改系统 DNS", "Proxy Protocol": "代理协议", + "DNS Redirector": "DNS转发", + "ICMP Redirector": "ICMP转发", + "Child Process Handle": "子进程代理", "ProfileCount": "快捷配置数量", "Delay test after start": "启动后延迟测试", "ServerPingType": "测速方式", diff --git a/binaries b/binaries index f3ff2428..c86b3a70 160000 --- a/binaries +++ b/binaries @@ -1 +1 @@ -Subproject commit f3ff242872f5206b672b0d6421c4d18899a3f57e +Subproject commit c86b3a70b14f3a73f6950bf0b7ce8b5fc1e12a20