mirror of
https://github.com/netchx/netch.git
synced 2026-03-14 17:43:18 +08:00
Update Redirector
extract RedirectorConfig move BypassIPs to Setting.TUNTAP
This commit is contained in:
@@ -25,21 +25,21 @@ namespace Netch.Controllers
|
||||
{
|
||||
CheckDriver();
|
||||
|
||||
Dial(NameList.TYPE_FILTERLOOPBACK, "false");
|
||||
Dial(NameList.TYPE_TCPLISN, Global.Settings.RedirectorTCPPort.ToString());
|
||||
Dial(NameList.TYPE_FILTLOP, "false");
|
||||
var p = PortHelper.GetAvailablePort();
|
||||
Dial(NameList.TYPE_TCPLISN, p.ToString());
|
||||
Dial(NameList.TYPE_UDPLISN, p.ToString());
|
||||
|
||||
// Server
|
||||
Dial(NameList.TYPE_FILTERUDP, (Global.Settings.ProcessProxyProtocol != PortType.TCP).ToString().ToLower());
|
||||
Dial(NameList.TYPE_FILTERTCP, (Global.Settings.ProcessProxyProtocol != PortType.UDP).ToString().ToLower());
|
||||
dial_Server(Global.Settings.ProcessProxyProtocol);
|
||||
Dial(NameList.TYPE_FILTUDP, (Global.Settings.Redirector.ProxyProtocol != PortType.TCP).ToString().ToLower());
|
||||
Dial(NameList.TYPE_FILTTCP, (Global.Settings.Redirector.ProxyProtocol != PortType.UDP).ToString().ToLower());
|
||||
dial_Server(Global.Settings.Redirector.ProxyProtocol);
|
||||
|
||||
// Mode Rule
|
||||
dial_Name(mode);
|
||||
|
||||
// Features
|
||||
Dial(NameList.TYPE_REDIRCTOR_DNS, Global.Settings.RedirectDNS ? Global.Settings.RedirectDNSAddr : "");
|
||||
Dial(NameList.TYPE_REDIRCTOR_ICMP, Global.Settings.RedirectICMP ? Global.Settings.RedirectICMPAddr : "");
|
||||
Dial(NameList.TYPE_FILTERCHILDPROC, Global.Settings.ChildProcessHandle.ToString().ToLower());
|
||||
Dial(NameList.TYPE_DNSHOST, Global.Settings.Redirector.DNSHijack ? Global.Settings.Redirector.DNSHijackHost : "");
|
||||
|
||||
if (!Init())
|
||||
throw new MessageException("Redirector Start failed, run Netch with \"-console\" argument");
|
||||
@@ -126,7 +126,7 @@ namespace Netch.Controllers
|
||||
Dial(NameList.TYPE_TCPPASS + offset, socks5.Password ?? string.Empty);
|
||||
Dial(NameList.TYPE_TCPMETH + offset, string.Empty);
|
||||
}
|
||||
else if (server is Shadowsocks shadowsocks && !shadowsocks.HasPlugin() && Global.Settings.RedirectorSS)
|
||||
else if (server is Shadowsocks shadowsocks && !shadowsocks.HasPlugin() && Global.Settings.Redirector.RedirectorSS)
|
||||
{
|
||||
Dial(NameList.TYPE_TCPTYPE + offset, "Shadowsocks");
|
||||
Dial(NameList.TYPE_TCPHOST + offset, $"{shadowsocks.AutoResolveHostname()}:{shadowsocks.Port}");
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace Netch.Controllers
|
||||
RouteAction(Action.Create, $"{_serverAddresses}/32", RouteType.Outbound);
|
||||
|
||||
Logging.Info("绕行 → 全局绕过 IP");
|
||||
RouteAction(Action.Create, Global.Settings.BypassIPs, RouteType.Outbound);
|
||||
RouteAction(Action.Create, Global.Settings.TUNTAP.BypassIPs, RouteType.Outbound);
|
||||
|
||||
#region Rule IPs
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Windows.Forms;
|
||||
using Netch.Properties;
|
||||
@@ -18,7 +19,7 @@ namespace Netch.Forms
|
||||
{
|
||||
i18N.TranslateForm(this);
|
||||
|
||||
IPListBox.Items.AddRange(Global.Settings.BypassIPs.ToArray());
|
||||
IPListBox.Items.AddRange(Global.Settings.TUNTAP.BypassIPs.Cast<object>().ToArray());
|
||||
|
||||
for (var i = 32; i >= 1; i--)
|
||||
PrefixComboBox.Items.Add(i);
|
||||
@@ -31,7 +32,7 @@ namespace Netch.Forms
|
||||
if (!string.IsNullOrEmpty(IPTextBox.Text))
|
||||
{
|
||||
if (IPAddress.TryParse(IPTextBox.Text, out var address))
|
||||
IPListBox.Items.Add(string.Format("{0}/{1}", address, PrefixComboBox.SelectedItem));
|
||||
IPListBox.Items.Add($"{address}/{PrefixComboBox.SelectedItem}");
|
||||
else
|
||||
MessageBoxX.Show(i18N.Translate("Please enter a correct IP address"));
|
||||
}
|
||||
@@ -51,9 +52,9 @@ namespace Netch.Forms
|
||||
|
||||
private void ControlButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Settings.BypassIPs.Clear();
|
||||
Global.Settings.TUNTAP.BypassIPs.Clear();
|
||||
foreach (var ip in IPListBox.Items)
|
||||
Global.Settings.BypassIPs.Add((string) ip);
|
||||
Global.Settings.TUNTAP.BypassIPs.Add((string) ip);
|
||||
|
||||
Configuration.Save();
|
||||
MessageBoxX.Show(i18N.Translate("Saved"));
|
||||
|
||||
112
Netch/Forms/SettingForm.Designer.cs
generated
112
Netch/Forms/SettingForm.Designer.cs
generated
@@ -38,8 +38,6 @@ namespace Netch.Forms
|
||||
this.Socks5PortTextBox = new System.Windows.Forms.TextBox();
|
||||
this.HTTPPortLabel = new System.Windows.Forms.Label();
|
||||
this.HTTPPortTextBox = new System.Windows.Forms.TextBox();
|
||||
this.RedirectorLabel = new System.Windows.Forms.Label();
|
||||
this.RedirectorTextBox = new System.Windows.Forms.TextBox();
|
||||
this.AllowDevicesCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.ResolveServerHostnameCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.ServerPingTypeLabel = new System.Windows.Forms.Label();
|
||||
@@ -59,10 +57,10 @@ namespace Netch.Forms
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.ProcessProxyProtocolLabel = new System.Windows.Forms.Label();
|
||||
this.ProcessProxyProtocolComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.DNSRedirectorCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.RDRDNSTextBox = new System.Windows.Forms.TextBox();
|
||||
this.ICMPRedirectorCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.ModifiedICMPTextBox = new System.Windows.Forms.TextBox();
|
||||
this.DNSHijackCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.DNSHijackHostTextBox = new System.Windows.Forms.TextBox();
|
||||
this.ICMPHijackCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.ICMPHijackHostTextBox = new System.Windows.Forms.TextBox();
|
||||
this.RedirectorSSCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.ChildProcessHandleCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.TAPTabPage = new System.Windows.Forms.TabPage();
|
||||
@@ -174,8 +172,6 @@ namespace Netch.Forms
|
||||
this.PortGroupBox.Controls.Add(this.Socks5PortTextBox);
|
||||
this.PortGroupBox.Controls.Add(this.HTTPPortLabel);
|
||||
this.PortGroupBox.Controls.Add(this.HTTPPortTextBox);
|
||||
this.PortGroupBox.Controls.Add(this.RedirectorLabel);
|
||||
this.PortGroupBox.Controls.Add(this.RedirectorTextBox);
|
||||
this.PortGroupBox.Controls.Add(this.AllowDevicesCheckBox);
|
||||
this.PortGroupBox.Location = new System.Drawing.Point(8, 6);
|
||||
this.PortGroupBox.Name = "PortGroupBox";
|
||||
@@ -218,23 +214,6 @@ namespace Netch.Forms
|
||||
this.HTTPPortTextBox.TabIndex = 3;
|
||||
this.HTTPPortTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// RedirectorLabel
|
||||
//
|
||||
this.RedirectorLabel.AutoSize = true;
|
||||
this.RedirectorLabel.Location = new System.Drawing.Point(9, 83);
|
||||
this.RedirectorLabel.Name = "RedirectorLabel";
|
||||
this.RedirectorLabel.Size = new System.Drawing.Size(95, 17);
|
||||
this.RedirectorLabel.TabIndex = 4;
|
||||
this.RedirectorLabel.Text = "Redirector TCP";
|
||||
//
|
||||
// RedirectorTextBox
|
||||
//
|
||||
this.RedirectorTextBox.Location = new System.Drawing.Point(120, 80);
|
||||
this.RedirectorTextBox.Name = "RedirectorTextBox";
|
||||
this.RedirectorTextBox.Size = new System.Drawing.Size(90, 23);
|
||||
this.RedirectorTextBox.TabIndex = 5;
|
||||
this.RedirectorTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// AllowDevicesCheckBox
|
||||
//
|
||||
this.AllowDevicesCheckBox.AutoSize = true;
|
||||
@@ -358,7 +337,7 @@ namespace Netch.Forms
|
||||
// LanguageLabel
|
||||
//
|
||||
this.LanguageLabel.AutoSize = true;
|
||||
this.LanguageLabel.Location = new System.Drawing.Point(17, 254);
|
||||
this.LanguageLabel.Location = new System.Drawing.Point(12, 254);
|
||||
this.LanguageLabel.Name = "LanguageLabel";
|
||||
this.LanguageLabel.Size = new System.Drawing.Size(65, 17);
|
||||
this.LanguageLabel.TabIndex = 15;
|
||||
@@ -390,10 +369,10 @@ namespace Netch.Forms
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.ProcessProxyProtocolLabel);
|
||||
this.groupBox1.Controls.Add(this.ProcessProxyProtocolComboBox);
|
||||
this.groupBox1.Controls.Add(this.DNSRedirectorCheckBox);
|
||||
this.groupBox1.Controls.Add(this.RDRDNSTextBox);
|
||||
this.groupBox1.Controls.Add(this.ICMPRedirectorCheckBox);
|
||||
this.groupBox1.Controls.Add(this.ModifiedICMPTextBox);
|
||||
this.groupBox1.Controls.Add(this.DNSHijackCheckBox);
|
||||
this.groupBox1.Controls.Add(this.DNSHijackHostTextBox);
|
||||
this.groupBox1.Controls.Add(this.ICMPHijackCheckBox);
|
||||
this.groupBox1.Controls.Add(this.ICMPHijackHostTextBox);
|
||||
this.groupBox1.Location = new System.Drawing.Point(5, 6);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(450, 117);
|
||||
@@ -418,43 +397,45 @@ namespace Netch.Forms
|
||||
this.ProcessProxyProtocolComboBox.Size = new System.Drawing.Size(191, 25);
|
||||
this.ProcessProxyProtocolComboBox.TabIndex = 1;
|
||||
//
|
||||
// DNSRedirectorCheckBox
|
||||
// DNSHijackCheckBox
|
||||
//
|
||||
this.DNSRedirectorCheckBox.AutoSize = true;
|
||||
this.DNSRedirectorCheckBox.Location = new System.Drawing.Point(6, 51);
|
||||
this.DNSRedirectorCheckBox.Name = "DNSRedirectorCheckBox";
|
||||
this.DNSRedirectorCheckBox.Size = new System.Drawing.Size(196, 21);
|
||||
this.DNSRedirectorCheckBox.TabIndex = 2;
|
||||
this.DNSRedirectorCheckBox.Text = "Handle process\'s DNS Hijack";
|
||||
this.DNSRedirectorCheckBox.UseVisualStyleBackColor = true;
|
||||
this.DNSHijackCheckBox.AutoSize = true;
|
||||
this.DNSHijackCheckBox.Location = new System.Drawing.Point(6, 51);
|
||||
this.DNSHijackCheckBox.Name = "DNSHijackCheckBox";
|
||||
this.DNSHijackCheckBox.Size = new System.Drawing.Size(196, 21);
|
||||
this.DNSHijackCheckBox.TabIndex = 2;
|
||||
this.DNSHijackCheckBox.Text = "Handle process\'s DNS Hijack";
|
||||
this.DNSHijackCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// RDRDNSTextBox
|
||||
// DNSHijackHostTextBox
|
||||
//
|
||||
this.RDRDNSTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Enabled", this.DNSRedirectorCheckBox, "Checked", true));
|
||||
this.RDRDNSTextBox.Location = new System.Drawing.Point(253, 46);
|
||||
this.RDRDNSTextBox.Name = "RDRDNSTextBox";
|
||||
this.RDRDNSTextBox.Size = new System.Drawing.Size(191, 23);
|
||||
this.RDRDNSTextBox.TabIndex = 4;
|
||||
this.RDRDNSTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.DNSHijackHostTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Enabled", this.DNSHijackCheckBox, "Checked", true));
|
||||
this.DNSHijackHostTextBox.Location = new System.Drawing.Point(253, 46);
|
||||
this.DNSHijackHostTextBox.Name = "DNSHijackHostTextBox";
|
||||
this.DNSHijackHostTextBox.Size = new System.Drawing.Size(191, 23);
|
||||
this.DNSHijackHostTextBox.TabIndex = 4;
|
||||
this.DNSHijackHostTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// ICMPRedirectorCheckBox
|
||||
// ICMPHijackCheckBox
|
||||
//
|
||||
this.ICMPRedirectorCheckBox.AutoSize = true;
|
||||
this.ICMPRedirectorCheckBox.Location = new System.Drawing.Point(6, 81);
|
||||
this.ICMPRedirectorCheckBox.Name = "ICMPRedirectorCheckBox";
|
||||
this.ICMPRedirectorCheckBox.Size = new System.Drawing.Size(139, 21);
|
||||
this.ICMPRedirectorCheckBox.TabIndex = 5;
|
||||
this.ICMPRedirectorCheckBox.Text = "Global ICMP Hijack";
|
||||
this.ICMPRedirectorCheckBox.UseVisualStyleBackColor = true;
|
||||
this.ICMPHijackCheckBox.AutoSize = true;
|
||||
this.ICMPHijackCheckBox.Enabled = false;
|
||||
this.ICMPHijackCheckBox.Location = new System.Drawing.Point(6, 81);
|
||||
this.ICMPHijackCheckBox.Name = "ICMPHijackCheckBox";
|
||||
this.ICMPHijackCheckBox.Size = new System.Drawing.Size(139, 21);
|
||||
this.ICMPHijackCheckBox.TabIndex = 5;
|
||||
this.ICMPHijackCheckBox.Text = "Global ICMP Hijack";
|
||||
this.ICMPHijackCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ModifiedICMPTextBox
|
||||
// ICMPHijackHostTextBox
|
||||
//
|
||||
this.ModifiedICMPTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Enabled", this.ICMPRedirectorCheckBox, "Checked", true));
|
||||
this.ModifiedICMPTextBox.Location = new System.Drawing.Point(253, 78);
|
||||
this.ModifiedICMPTextBox.Name = "ModifiedICMPTextBox";
|
||||
this.ModifiedICMPTextBox.Size = new System.Drawing.Size(191, 23);
|
||||
this.ModifiedICMPTextBox.TabIndex = 7;
|
||||
this.ModifiedICMPTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.ICMPHijackHostTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Enabled", this.ICMPHijackCheckBox, "Checked", true));
|
||||
this.ICMPHijackHostTextBox.Enabled = false;
|
||||
this.ICMPHijackHostTextBox.Location = new System.Drawing.Point(253, 78);
|
||||
this.ICMPHijackHostTextBox.Name = "ICMPHijackHostTextBox";
|
||||
this.ICMPHijackHostTextBox.Size = new System.Drawing.Size(191, 23);
|
||||
this.ICMPHijackHostTextBox.TabIndex = 7;
|
||||
this.ICMPHijackHostTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// RedirectorSSCheckBox
|
||||
//
|
||||
@@ -469,6 +450,7 @@ namespace Netch.Forms
|
||||
// ChildProcessHandleCheckBox
|
||||
//
|
||||
this.ChildProcessHandleCheckBox.AutoSize = true;
|
||||
this.ChildProcessHandleCheckBox.Enabled = false;
|
||||
this.ChildProcessHandleCheckBox.Location = new System.Drawing.Point(11, 151);
|
||||
this.ChildProcessHandleCheckBox.Name = "ChildProcessHandleCheckBox";
|
||||
this.ChildProcessHandleCheckBox.Size = new System.Drawing.Size(150, 21);
|
||||
@@ -1029,8 +1011,6 @@ namespace Netch.Forms
|
||||
private System.Windows.Forms.TabPage TAPTabPage;
|
||||
private System.Windows.Forms.TabPage v2rayTabPage;
|
||||
private System.Windows.Forms.GroupBox PortGroupBox;
|
||||
private System.Windows.Forms.Label RedirectorLabel;
|
||||
private System.Windows.Forms.TextBox RedirectorTextBox;
|
||||
private System.Windows.Forms.CheckBox AllowDevicesCheckBox;
|
||||
private System.Windows.Forms.Label HTTPPortLabel;
|
||||
private System.Windows.Forms.TextBox HTTPPortTextBox;
|
||||
@@ -1049,7 +1029,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 DNSRedirectorCheckBox;
|
||||
private System.Windows.Forms.CheckBox DNSHijackCheckBox;
|
||||
private System.Windows.Forms.Button ControlButton;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
|
||||
private System.Windows.Forms.TabPage OtherTabPage;
|
||||
@@ -1093,16 +1073,16 @@ namespace Netch.Forms
|
||||
private System.Windows.Forms.Label ChinaDNSLabel;
|
||||
private System.Windows.Forms.TextBox OtherDNSTextBox;
|
||||
private System.Windows.Forms.TextBox ChinaDNSTextBox;
|
||||
private System.Windows.Forms.TextBox RDRDNSTextBox;
|
||||
private System.Windows.Forms.TextBox DNSHijackHostTextBox;
|
||||
private System.Windows.Forms.CheckBox RedirectorSSCheckBox;
|
||||
private System.Windows.Forms.Label ServerPingTypeLabel;
|
||||
private System.Windows.Forms.RadioButton TCPingRadioBtn;
|
||||
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.CheckBox ICMPHijackCheckBox;
|
||||
private System.Windows.Forms.CheckBox ChildProcessHandleCheckBox;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.TextBox ICMPHijackHostTextBox;
|
||||
}
|
||||
}
|
||||
@@ -26,20 +26,15 @@ namespace Netch.Forms
|
||||
#region General
|
||||
|
||||
BindTextBox<ushort>(Socks5PortTextBox,
|
||||
p => p.ToString() != HTTPPortTextBox.Text && p.ToString() != RedirectorTextBox.Text,
|
||||
p => p.ToString() != HTTPPortTextBox.Text,
|
||||
p => Global.Settings.Socks5LocalPort = p,
|
||||
Global.Settings.Socks5LocalPort);
|
||||
|
||||
BindTextBox<ushort>(HTTPPortTextBox,
|
||||
p => p.ToString() != Socks5PortTextBox.Text && p.ToString() != RedirectorTextBox.Text,
|
||||
p => p.ToString() != Socks5PortTextBox.Text,
|
||||
p => Global.Settings.HTTPLocalPort = p,
|
||||
Global.Settings.HTTPLocalPort);
|
||||
|
||||
BindTextBox<ushort>(RedirectorTextBox,
|
||||
p => p.ToString() != Socks5PortTextBox.Text && p.ToString() != HTTPPortTextBox.Text,
|
||||
p => Global.Settings.RedirectorTCPPort = p,
|
||||
Global.Settings.RedirectorTCPPort);
|
||||
|
||||
BindCheckBox(AllowDevicesCheckBox,
|
||||
c => Global.Settings.LocalAddress = AllowDevicesCheckBox.Checked ? "0.0.0.0" : "127.0.0.1",
|
||||
Global.Settings.LocalAddress switch {"127.0.0.1" => false, "0.0.0.0" => true, _ => false});
|
||||
@@ -103,28 +98,27 @@ namespace Netch.Forms
|
||||
|
||||
#region Process Mode
|
||||
|
||||
BindCheckBox(DNSRedirectorCheckBox, b => Global.Settings.RedirectDNS = b, Global.Settings.RedirectDNS);
|
||||
BindCheckBox(DNSHijackCheckBox, b => Global.Settings.Redirector.DNSHijack = b, Global.Settings.Redirector.DNSHijack);
|
||||
|
||||
BindTextBox(RDRDNSTextBox,
|
||||
s => DnsUtils.TrySplit(s, out _, 2),
|
||||
s => Global.Settings.RedirectDNSAddr = s,
|
||||
Global.Settings.RedirectDNSAddr);
|
||||
BindTextBox(DNSHijackHostTextBox, s => true, s => Global.Settings.Redirector.DNSHijackHost = s, Global.Settings.Redirector.DNSHijackHost);
|
||||
|
||||
BindCheckBox(ICMPRedirectorCheckBox, b => Global.Settings.RedirectICMP = b, Global.Settings.RedirectICMP);
|
||||
BindCheckBox(ICMPHijackCheckBox, b => Global.Settings.Redirector.ICMPHijack = b, Global.Settings.Redirector.ICMPHijack);
|
||||
|
||||
BindTextBox(ModifiedICMPTextBox,
|
||||
s => DnsUtils.TrySplit(s, out _, 2),
|
||||
s => Global.Settings.RedirectICMPAddr = s,
|
||||
Global.Settings.RedirectICMPAddr);
|
||||
BindTextBox(ICMPHijackHostTextBox,
|
||||
s => IPAddress.TryParse(s, out _),
|
||||
s => Global.Settings.Redirector.ICMPHost = s,
|
||||
Global.Settings.Redirector.ICMPHost);
|
||||
|
||||
BindCheckBox(RedirectorSSCheckBox, s => Global.Settings.RedirectorSS = s, Global.Settings.RedirectorSS);
|
||||
BindCheckBox(RedirectorSSCheckBox, s => Global.Settings.Redirector.RedirectorSS = s, Global.Settings.Redirector.RedirectorSS);
|
||||
|
||||
BindCheckBox(ChildProcessHandleCheckBox, s => Global.Settings.ChildProcessHandle = s, Global.Settings.ChildProcessHandle);
|
||||
BindCheckBox(ChildProcessHandleCheckBox,
|
||||
s => Global.Settings.Redirector.ChildProcessHandle = s,
|
||||
Global.Settings.Redirector.ChildProcessHandle);
|
||||
|
||||
BindListComboBox(ProcessProxyProtocolComboBox,
|
||||
s => Global.Settings.ProcessProxyProtocol = (PortType) Enum.Parse(typeof(PortType), s.ToString(), false),
|
||||
s => Global.Settings.Redirector.ProxyProtocol = (PortType) Enum.Parse(typeof(PortType), s.ToString(), false),
|
||||
Enum.GetNames(typeof(PortType)),
|
||||
Global.Settings.ProcessProxyProtocol.ToString());
|
||||
Global.Settings.Redirector.ProxyProtocol.ToString());
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -7,12 +7,13 @@ namespace Netch.Interops
|
||||
{
|
||||
public enum NameList
|
||||
{
|
||||
//bool
|
||||
TYPE_FILTERLOOPBACK,
|
||||
TYPE_FILTERTCP,
|
||||
TYPE_FILTERUDP,
|
||||
TYPE_FILTERIP,
|
||||
TYPE_FILTERCHILDPROC, //子进程捕获
|
||||
TYPE_FILTLOP,
|
||||
TYPE_FILTTCP,
|
||||
TYPE_FILTUDP,
|
||||
TYPE_CLRNAME,
|
||||
TYPE_ADDNAME,
|
||||
TYPE_BYPNAME,
|
||||
TYPE_DNSHOST,
|
||||
|
||||
TYPE_TCPLISN,
|
||||
TYPE_TCPTYPE,
|
||||
@@ -20,24 +21,21 @@ namespace Netch.Interops
|
||||
TYPE_TCPUSER,
|
||||
TYPE_TCPPASS,
|
||||
TYPE_TCPMETH,
|
||||
TYPE_TCPPROT,
|
||||
TYPE_TCPPRPA,
|
||||
TYPE_TCPOBFS,
|
||||
TYPE_TCPOBPA,
|
||||
|
||||
TYPE_UDPLISN,
|
||||
TYPE_UDPTYPE,
|
||||
TYPE_UDPHOST,
|
||||
TYPE_UDPUSER,
|
||||
TYPE_UDPPASS,
|
||||
TYPE_UDPMETH,
|
||||
|
||||
TYPE_ADDNAME,
|
||||
TYPE_ADDFIP,
|
||||
|
||||
TYPE_BYPNAME,
|
||||
|
||||
TYPE_CLRNAME,
|
||||
TYPE_CLRFIP,
|
||||
|
||||
//str addr x.x.x.x only ipv4
|
||||
TYPE_REDIRCTOR_DNS,
|
||||
TYPE_REDIRCTOR_ICMP
|
||||
TYPE_UDPPROT,
|
||||
TYPE_UDPPRPA,
|
||||
TYPE_UDPOBFS,
|
||||
TYPE_UDPOBPA
|
||||
}
|
||||
|
||||
public static bool Dial(NameList name, string value)
|
||||
@@ -56,7 +54,7 @@ namespace Netch.Interops
|
||||
return aio_free();
|
||||
}
|
||||
|
||||
public const int UdpNameListOffset = (int) NameList.TYPE_UDPTYPE - (int) NameList.TYPE_TCPTYPE;
|
||||
public const int UdpNameListOffset = (int) NameList.TYPE_UDPLISN - (int) NameList.TYPE_TCPLISN;
|
||||
|
||||
private const string Redirector_bin = "Redirector.bin";
|
||||
|
||||
|
||||
@@ -37,6 +37,11 @@ namespace Netch.Models
|
||||
/// 使用自定义 DNS 设置
|
||||
/// </summary>
|
||||
public bool UseCustomDNS { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 全局绕过 IP 列表
|
||||
/// </summary>
|
||||
public List<string> BypassIPs { get; set; } = new();
|
||||
}
|
||||
|
||||
public class KcpConfig
|
||||
@@ -80,11 +85,45 @@ namespace Netch.Models
|
||||
public string RulePath { get; set; } = "bin\\aiodns.conf";
|
||||
}
|
||||
|
||||
public class RedirectorConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 不代理TCP
|
||||
/// </summary>
|
||||
public PortType ProxyProtocol { get; set; } = PortType.Both;
|
||||
|
||||
/// <summary>
|
||||
/// 是否开启DNS转发
|
||||
/// </summary>
|
||||
public bool DNSHijack { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 转发DNS地址
|
||||
/// </summary>
|
||||
public string DNSHijackHost { get; set; } = "1.1.1.1:53";
|
||||
|
||||
public string ICMPHost { get; set; } = "1.2.4.8";
|
||||
|
||||
public bool ICMPHijack { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 是否使用RDR内置SS
|
||||
/// </summary>
|
||||
public bool RedirectorSS { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 是否代理子进程
|
||||
/// </summary>
|
||||
public bool ChildProcessHandle { get; set; } = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用于读取和写入的配置的类
|
||||
/// </summary>
|
||||
public class Setting
|
||||
{
|
||||
public RedirectorConfig Redirector { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 服务器列表
|
||||
/// </summary>
|
||||
@@ -92,11 +131,6 @@ namespace Netch.Models
|
||||
|
||||
public AioDNSConfig AioDNS { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 全局绕过 IP 列表
|
||||
/// </summary>
|
||||
public List<string> BypassIPs { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 是否检查 Beta 更新
|
||||
/// </summary>
|
||||
@@ -142,31 +176,6 @@ namespace Netch.Models
|
||||
/// </summary>
|
||||
public int ModeComboBoxSelectedIndex { get; set; } = -1;
|
||||
|
||||
/// <summary>
|
||||
/// 转发DNS地址
|
||||
/// </summary>
|
||||
public string RedirectDNSAddr { get; set; } = "1.1.1.1";
|
||||
|
||||
/// <summary>
|
||||
/// 是否开启DNS转发
|
||||
/// </summary>
|
||||
public bool RedirectDNS { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 转发ICMP地址
|
||||
/// </summary>
|
||||
public string RedirectICMPAddr { get; set; } = "1.2.4.8";
|
||||
|
||||
/// <summary>
|
||||
/// 是否开启ICMP转发
|
||||
/// </summary>
|
||||
public bool RedirectICMP { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 不代理TCP
|
||||
/// </summary>
|
||||
public PortType ProcessProxyProtocol { get; set; } = PortType.Both;
|
||||
|
||||
/// <summary>
|
||||
/// 快捷配置数量
|
||||
/// </summary>
|
||||
@@ -182,21 +191,6 @@ namespace Netch.Models
|
||||
/// </summary>
|
||||
public byte ProfileTableColumnCount { get; set; } = 5;
|
||||
|
||||
/// <summary>
|
||||
/// 是否使用RDR内置SS
|
||||
/// </summary>
|
||||
public bool RedirectorSS { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 是否代理子进程
|
||||
/// </summary>
|
||||
public bool ChildProcessHandle { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Redirector TCP 占用端口
|
||||
/// </summary>
|
||||
public ushort RedirectorTCPPort { get; set; } = 3901;
|
||||
|
||||
/// <summary>
|
||||
/// 网页请求超时 毫秒
|
||||
/// </summary>
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Netch.Utils
|
||||
return server switch
|
||||
{
|
||||
Socks5 => true,
|
||||
Shadowsocks shadowsocks when !shadowsocks.HasPlugin() && Global.Settings.RedirectorSS => true,
|
||||
Shadowsocks shadowsocks when !shadowsocks.HasPlugin() && Global.Settings.Redirector.RedirectorSS => true,
|
||||
_ => false
|
||||
};
|
||||
case 1:
|
||||
@@ -135,8 +135,6 @@ namespace Netch.Utils
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
port = Global.Settings.RedirectorTCPPort;
|
||||
portName = "Redirector TCP";
|
||||
return new NFController();
|
||||
case 1:
|
||||
case 2:
|
||||
|
||||
Reference in New Issue
Block a user