mirror of
https://github.com/netchx/netch.git
synced 2026-03-18 18:13:21 +08:00
Update Redirector settings
Update Redirector interop Update NFController Create Netch.JsonConverter namespace
This commit is contained in:
@@ -34,7 +34,8 @@ namespace Netch.Controllers
|
||||
CheckDriver();
|
||||
|
||||
Dial(NameList.AIO_FILTERLOOPBACK, "false");
|
||||
Dial(NameList.AIO_FILTERINTRANET, "false");
|
||||
Dial(NameList.AIO_FILTERINTRANET, "true");
|
||||
Dial(NameList.AIO_FILTERPARENT, _rdrConfig.ChildProcessHandle.ToString().ToLower());
|
||||
Dial(NameList.AIO_FILTERICMP, _rdrConfig.FilterICMP.ToString().ToLower());
|
||||
Dial(NameList.AIO_ICMPING, _rdrConfig.ICMPDelay.ToString());
|
||||
|
||||
@@ -50,8 +51,14 @@ namespace Netch.Controllers
|
||||
// Mode Rule
|
||||
DialRule(_mode);
|
||||
|
||||
// Features TODO
|
||||
// Dial(NameList.AIO_DNSHOST, _rdrConfig.DNSHijack ? _rdrConfig.DNSHijackHost : "");
|
||||
// DNS
|
||||
Dial(NameList.AIO_FILTERDNS, _rdrConfig.DNSHijack.ToString().ToLower());
|
||||
if (_rdrConfig.DNSHijack)
|
||||
{
|
||||
var dns = new Uri(DnsUtils.AppendScheme(DnsUtils.AppendPort(_rdrConfig.DNSHijackHost), "udp"));
|
||||
Dial(NameList.AIO_DNSHOST, dns.Host);
|
||||
Dial(NameList.AIO_DNSPORT, dns.Port.ToString());
|
||||
}
|
||||
|
||||
if (!await InitAsync())
|
||||
throw new MessageException("Redirector start failed.");
|
||||
|
||||
48
Netch/Forms/SettingForm.Designer.cs
generated
48
Netch/Forms/SettingForm.Designer.cs
generated
@@ -95,9 +95,9 @@ namespace Netch.Forms
|
||||
this.StopWhenExitedCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.StartWhenOpenedCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.MinimizeWhenStartedCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.NoSupportDialogCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.RunAtStartupCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.CheckUpdateWhenOpenedCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.NoSupportDialogCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.CheckBetaUpdateCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.UpdateServersWhenOpenedCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.AioDNSTabPage = new System.Windows.Forms.TabPage();
|
||||
@@ -109,6 +109,7 @@ namespace Netch.Forms
|
||||
this.AioDNSListenPortTextBox = new System.Windows.Forms.TextBox();
|
||||
this.ControlButton = new System.Windows.Forms.Button();
|
||||
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.DNSHijackLabel = new System.Windows.Forms.Label();
|
||||
this.TabControl.SuspendLayout();
|
||||
this.GeneralTabPage.SuspendLayout();
|
||||
this.PortGroupBox.SuspendLayout();
|
||||
@@ -324,6 +325,7 @@ namespace Netch.Forms
|
||||
this.NFTabPage.Controls.Add(this.ProcessFilterProtocolLabel);
|
||||
this.NFTabPage.Controls.Add(this.ProcessFilterProtocolComboBox);
|
||||
this.NFTabPage.Controls.Add(this.FilterICMPCheckBox);
|
||||
this.NFTabPage.Controls.Add(this.DNSHijackLabel);
|
||||
this.NFTabPage.Controls.Add(this.ICMPDelayLabel);
|
||||
this.NFTabPage.Controls.Add(this.ICMPDelayTextBox);
|
||||
this.NFTabPage.Controls.Add(this.DNSHijackCheckBox);
|
||||
@@ -367,7 +369,7 @@ namespace Netch.Forms
|
||||
// ICMPDelayLabel
|
||||
//
|
||||
this.ICMPDelayLabel.AutoSize = true;
|
||||
this.ICMPDelayLabel.Location = new System.Drawing.Point(30, 80);
|
||||
this.ICMPDelayLabel.Location = new System.Drawing.Point(65, 80);
|
||||
this.ICMPDelayLabel.Name = "ICMPDelayLabel";
|
||||
this.ICMPDelayLabel.Size = new System.Drawing.Size(100, 17);
|
||||
this.ICMPDelayLabel.TabIndex = 3;
|
||||
@@ -387,33 +389,29 @@ namespace Netch.Forms
|
||||
this.DNSHijackCheckBox.AutoSize = true;
|
||||
this.DNSHijackCheckBox.Location = new System.Drawing.Point(15, 110);
|
||||
this.DNSHijackCheckBox.Name = "DNSHijackCheckBox";
|
||||
this.DNSHijackCheckBox.Size = new System.Drawing.Size(196, 21);
|
||||
this.DNSHijackCheckBox.Size = new System.Drawing.Size(92, 21);
|
||||
this.DNSHijackCheckBox.TabIndex = 5;
|
||||
this.DNSHijackCheckBox.Text = "Handle process\'s DNS Hijack";
|
||||
this.DNSHijackCheckBox.Text = "DNS Hijack";
|
||||
this.DNSHijackCheckBox.UseVisualStyleBackColor = true;
|
||||
this.DNSHijackCheckBox.Visible = false;
|
||||
//
|
||||
// DNSHijackHostTextBox
|
||||
//
|
||||
this.DNSHijackHostTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Enabled", this.DNSHijackCheckBox, "Checked", true));
|
||||
this.DNSHijackHostTextBox.Location = new System.Drawing.Point(237, 108);
|
||||
this.DNSHijackHostTextBox.Location = new System.Drawing.Point(237, 138);
|
||||
this.DNSHijackHostTextBox.Name = "DNSHijackHostTextBox";
|
||||
this.DNSHijackHostTextBox.Size = new System.Drawing.Size(191, 23);
|
||||
this.DNSHijackHostTextBox.TabIndex = 6;
|
||||
this.DNSHijackHostTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.DNSHijackHostTextBox.Visible = false;
|
||||
//
|
||||
// ChildProcessHandleCheckBox
|
||||
//
|
||||
this.ChildProcessHandleCheckBox.AutoSize = true;
|
||||
this.ChildProcessHandleCheckBox.Enabled = false;
|
||||
this.ChildProcessHandleCheckBox.Location = new System.Drawing.Point(15, 140);
|
||||
this.ChildProcessHandleCheckBox.Location = new System.Drawing.Point(15, 170);
|
||||
this.ChildProcessHandleCheckBox.Name = "ChildProcessHandleCheckBox";
|
||||
this.ChildProcessHandleCheckBox.Size = new System.Drawing.Size(150, 21);
|
||||
this.ChildProcessHandleCheckBox.TabIndex = 7;
|
||||
this.ChildProcessHandleCheckBox.Text = "Child Process Handle";
|
||||
this.ChildProcessHandleCheckBox.UseVisualStyleBackColor = true;
|
||||
this.ChildProcessHandleCheckBox.Visible = false;
|
||||
//
|
||||
// WinTUNTabPage
|
||||
//
|
||||
@@ -785,16 +783,6 @@ namespace Netch.Forms
|
||||
this.MinimizeWhenStartedCheckBox.Text = "Minimize when started";
|
||||
this.MinimizeWhenStartedCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// NoSupportDialogCheckBox
|
||||
//
|
||||
this.NoSupportDialogCheckBox.AutoSize = true;
|
||||
this.NoSupportDialogCheckBox.Location = new System.Drawing.Point(6, 72);
|
||||
this.NoSupportDialogCheckBox.Name = "NoSupportDialogCheckBox";
|
||||
this.NoSupportDialogCheckBox.Size = new System.Drawing.Size(174, 21);
|
||||
this.NoSupportDialogCheckBox.TabIndex = 6;
|
||||
this.NoSupportDialogCheckBox.Text = "Disable Support Warning";
|
||||
this.NoSupportDialogCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// RunAtStartupCheckBox
|
||||
//
|
||||
this.RunAtStartupCheckBox.AutoSize = true;
|
||||
@@ -816,6 +804,16 @@ namespace Netch.Forms
|
||||
this.CheckUpdateWhenOpenedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
this.CheckUpdateWhenOpenedCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// NoSupportDialogCheckBox
|
||||
//
|
||||
this.NoSupportDialogCheckBox.AutoSize = true;
|
||||
this.NoSupportDialogCheckBox.Location = new System.Drawing.Point(6, 72);
|
||||
this.NoSupportDialogCheckBox.Name = "NoSupportDialogCheckBox";
|
||||
this.NoSupportDialogCheckBox.Size = new System.Drawing.Size(174, 21);
|
||||
this.NoSupportDialogCheckBox.TabIndex = 6;
|
||||
this.NoSupportDialogCheckBox.Text = "Disable Support Warning";
|
||||
this.NoSupportDialogCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// CheckBetaUpdateCheckBox
|
||||
//
|
||||
this.CheckBetaUpdateCheckBox.AutoSize = true;
|
||||
@@ -929,6 +927,15 @@ namespace Netch.Forms
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(480, 400);
|
||||
this.flowLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// DNSHijackLabel
|
||||
//
|
||||
this.DNSHijackLabel.AutoSize = true;
|
||||
this.DNSHijackLabel.Location = new System.Drawing.Point(65, 140);
|
||||
this.DNSHijackLabel.Name = "DNSHijackLabel";
|
||||
this.DNSHijackLabel.Size = new System.Drawing.Size(34, 17);
|
||||
this.DNSHijackLabel.TabIndex = 3;
|
||||
this.DNSHijackLabel.Text = "DNS";
|
||||
//
|
||||
// SettingForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
@@ -1047,5 +1054,6 @@ namespace Netch.Forms
|
||||
private System.Windows.Forms.TextBox ICMPDelayTextBox;
|
||||
private System.Windows.Forms.Label ICMPDelayLabel;
|
||||
private System.Windows.Forms.CheckBox NoSupportDialogCheckBox;
|
||||
private System.Windows.Forms.Label DNSHijackLabel;
|
||||
}
|
||||
}
|
||||
@@ -94,14 +94,14 @@ namespace Netch.Forms
|
||||
Enum.GetNames(typeof(PortType)),
|
||||
Global.Settings.Redirector.FilterProtocol.ToString());
|
||||
|
||||
BindCheckBox(DNSHijackCheckBox, b => Global.Settings.Redirector.DNSHijack = b, Global.Settings.Redirector.DNSHijack);
|
||||
|
||||
BindTextBox(DNSHijackHostTextBox, s => true, s => Global.Settings.Redirector.DNSHijackHost = s, Global.Settings.Redirector.DNSHijackHost);
|
||||
|
||||
BindCheckBox(FilterICMPCheckBox, b => Global.Settings.Redirector.FilterICMP = b, Global.Settings.Redirector.FilterICMP);
|
||||
|
||||
BindTextBox<int>(ICMPDelayTextBox, s => true, s => Global.Settings.Redirector.ICMPDelay = s, Global.Settings.Redirector.ICMPDelay);
|
||||
|
||||
BindCheckBox(DNSHijackCheckBox, b => Global.Settings.Redirector.DNSHijack = b, Global.Settings.Redirector.DNSHijack);
|
||||
|
||||
BindTextBox(DNSHijackHostTextBox, s => true, s => Global.Settings.Redirector.DNSHijackHost = s, Global.Settings.Redirector.DNSHijackHost);
|
||||
|
||||
BindCheckBox(ChildProcessHandleCheckBox,
|
||||
s => Global.Settings.Redirector.ChildProcessHandle = s,
|
||||
Global.Settings.Redirector.ChildProcessHandle);
|
||||
|
||||
@@ -10,12 +10,17 @@ namespace Netch.Interops
|
||||
{
|
||||
AIO_FILTERLOOPBACK,
|
||||
AIO_FILTERINTRANET, // LAN
|
||||
AIO_FILTERPARENT,
|
||||
AIO_FILTERICMP,
|
||||
AIO_FILTERTCP,
|
||||
AIO_FILTERUDP,
|
||||
AIO_FILTERDNS,
|
||||
|
||||
AIO_ICMPING,
|
||||
|
||||
AIO_DNSHOST,
|
||||
AIO_DNSPORT,
|
||||
|
||||
AIO_TGTHOST,
|
||||
AIO_TGTPORT,
|
||||
AIO_TGTUSER,
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Netch.Models;
|
||||
using Netch.Utils;
|
||||
|
||||
namespace Netch.Utils
|
||||
namespace Netch.JsonConverter
|
||||
{
|
||||
public class ServerConverterWithTypeDiscriminator : JsonConverter<Server>
|
||||
{
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Netch.Utils;
|
||||
|
||||
namespace Netch.Models
|
||||
@@ -111,7 +110,6 @@ namespace Netch.Models
|
||||
/// <summary>
|
||||
/// 是否代理子进程
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public bool ChildProcessHandle { get; set; } = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,10 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="NativeMethods.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Condition="'$(PublishSingleFile)' == 'true'" AfterTargets="_ComputeFilesToBundle" Name="RemoveDupeAssemblies">
|
||||
<ItemGroup>
|
||||
<_FilesToBundle Remove="$(PkgMicrosoft_Diagnostics_Tracing_TraceEvent)\build\native\x86\**" />
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.Threading;
|
||||
using Netch.JsonConverter;
|
||||
using Netch.Models;
|
||||
using Serilog;
|
||||
|
||||
@@ -90,8 +91,8 @@ namespace Netch.Utils
|
||||
for (var i = 0; i < settings.Profiles.Count; i++)
|
||||
settings.Profiles[i].Index = i;
|
||||
|
||||
settings.AioDNS.ChinaDNS = Utils.HostAppendPort(settings.AioDNS.ChinaDNS);
|
||||
settings.AioDNS.OtherDNS = Utils.HostAppendPort(settings.AioDNS.OtherDNS);
|
||||
settings.AioDNS.ChinaDNS = DnsUtils.AppendPort(settings.AioDNS.ChinaDNS);
|
||||
settings.AioDNS.OtherDNS = DnsUtils.AppendPort(settings.AioDNS.OtherDNS);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -101,5 +101,21 @@ namespace Netch.Utils
|
||||
{
|
||||
return string.Join(",", dns);
|
||||
}
|
||||
|
||||
public static string AppendPort(string host, ushort port = 53)
|
||||
{
|
||||
if (!host.Contains(':'))
|
||||
return host + $":{port}";
|
||||
|
||||
return host;
|
||||
}
|
||||
|
||||
public static string AppendScheme(string value, string scheme = "tcp")
|
||||
{
|
||||
if (!value.Contains(Uri.SchemeDelimiter))
|
||||
return scheme + Uri.SchemeDelimiter + value;
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using Netch.JsonConverter;
|
||||
using Netch.Models;
|
||||
using Netch.Servers;
|
||||
using Serilog;
|
||||
|
||||
@@ -246,14 +246,6 @@ namespace Netch.Utils
|
||||
return subnet.GetAddressBytes().Sum(b => Convert.ToString(b, 2).Count(c => c == '1'));
|
||||
}
|
||||
|
||||
public static string HostAppendPort(string host, ushort port = 53)
|
||||
{
|
||||
if (!host.Contains(':'))
|
||||
host += $":{port}";
|
||||
|
||||
return host;
|
||||
}
|
||||
|
||||
public static string GetHostFromUri(string str)
|
||||
{
|
||||
var startIndex = str.LastIndexOf('/');
|
||||
|
||||
Reference in New Issue
Block a user