Compare commits

..

4 Commits
1.9.1 ... 1.9.2

Author SHA1 Message Date
ChsBuffer
0d535aa27e Bump version to 1.9.2 2021-10-15 20:44:50 +08:00
ChsBuffer
03c3c151bf Update CI 2021-10-15 20:44:07 +08:00
ChsBuffer
7a3b5ff487 Update Redirector settings
Update Redirector interop
Update NFController
Create Netch.JsonConverter namespace
2021-10-15 20:23:10 +08:00
ChsBuffer
598ff19535 Nice properties reuse, v2rayN. 2021-10-14 20:26:11 +08:00
16 changed files with 83 additions and 44 deletions

View File

@@ -1,5 +1,8 @@
name: Netch Build CI name: Netch Build CI
on: [push, pull_request] on:
push:
branches: [ master ]
pull_request:
jobs: jobs:
build: build:

View File

@@ -41,6 +41,9 @@ jobs:
Netch.7z Netch.7z
body: | body: |
[![](https://img.shields.io/badge/Telegram-Channel-blue)](https://t.me/netch_channel) [![](https://img.shields.io/badge/Telegram-Group-green)](https://t.me/netch_group) [![](https://img.shields.io/badge/Telegram-Channel-blue)](https://t.me/netch_channel) [![](https://img.shields.io/badge/Telegram-Group-green)](https://t.me/netch_group)
[**第一次使用请务必先安装 .NET 5.0 运行库**](https://aka.ms/dotnet/5.0/windowsdesktop-runtime-win-x64.exe)
## Changelogs ## Changelogs
* This is an automated deployment of GitHub Actions, the change log should be updated manually soon * This is an automated deployment of GitHub Actions, the change log should be updated manually soon

View File

@@ -34,7 +34,8 @@ namespace Netch.Controllers
CheckDriver(); CheckDriver();
Dial(NameList.AIO_FILTERLOOPBACK, "false"); 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_FILTERICMP, _rdrConfig.FilterICMP.ToString().ToLower());
Dial(NameList.AIO_ICMPING, _rdrConfig.ICMPDelay.ToString()); Dial(NameList.AIO_ICMPING, _rdrConfig.ICMPDelay.ToString());
@@ -50,8 +51,14 @@ namespace Netch.Controllers
// Mode Rule // Mode Rule
DialRule(_mode); DialRule(_mode);
// Features TODO // DNS
// Dial(NameList.AIO_DNSHOST, _rdrConfig.DNSHijack ? _rdrConfig.DNSHijackHost : ""); 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()) if (!await InitAsync())
throw new MessageException("Redirector start failed."); throw new MessageException("Redirector start failed.");

View File

@@ -20,7 +20,7 @@ namespace Netch.Controllers
public const string Name = @"Netch"; public const string Name = @"Netch";
public const string Copyright = @"Copyright © 2019 - 2021"; public const string Copyright = @"Copyright © 2019 - 2021";
public const string AssemblyVersion = @"1.9.1"; public const string AssemblyVersion = @"1.9.2";
private const string Suffix = @""; private const string Suffix = @"";
public static readonly string Version = $"{AssemblyVersion}{(string.IsNullOrEmpty(Suffix) ? "" : $"-{Suffix}")}"; public static readonly string Version = $"{AssemblyVersion}{(string.IsNullOrEmpty(Suffix) ? "" : $"-{Suffix}")}";

View File

@@ -95,9 +95,9 @@ namespace Netch.Forms
this.StopWhenExitedCheckBox = new System.Windows.Forms.CheckBox(); this.StopWhenExitedCheckBox = new System.Windows.Forms.CheckBox();
this.StartWhenOpenedCheckBox = new System.Windows.Forms.CheckBox(); this.StartWhenOpenedCheckBox = new System.Windows.Forms.CheckBox();
this.MinimizeWhenStartedCheckBox = 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.RunAtStartupCheckBox = new System.Windows.Forms.CheckBox();
this.CheckUpdateWhenOpenedCheckBox = 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.CheckBetaUpdateCheckBox = new System.Windows.Forms.CheckBox();
this.UpdateServersWhenOpenedCheckBox = new System.Windows.Forms.CheckBox(); this.UpdateServersWhenOpenedCheckBox = new System.Windows.Forms.CheckBox();
this.AioDNSTabPage = new System.Windows.Forms.TabPage(); this.AioDNSTabPage = new System.Windows.Forms.TabPage();
@@ -109,6 +109,7 @@ namespace Netch.Forms
this.AioDNSListenPortTextBox = new System.Windows.Forms.TextBox(); this.AioDNSListenPortTextBox = new System.Windows.Forms.TextBox();
this.ControlButton = new System.Windows.Forms.Button(); this.ControlButton = new System.Windows.Forms.Button();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.DNSHijackLabel = new System.Windows.Forms.Label();
this.TabControl.SuspendLayout(); this.TabControl.SuspendLayout();
this.GeneralTabPage.SuspendLayout(); this.GeneralTabPage.SuspendLayout();
this.PortGroupBox.SuspendLayout(); this.PortGroupBox.SuspendLayout();
@@ -324,6 +325,7 @@ namespace Netch.Forms
this.NFTabPage.Controls.Add(this.ProcessFilterProtocolLabel); this.NFTabPage.Controls.Add(this.ProcessFilterProtocolLabel);
this.NFTabPage.Controls.Add(this.ProcessFilterProtocolComboBox); this.NFTabPage.Controls.Add(this.ProcessFilterProtocolComboBox);
this.NFTabPage.Controls.Add(this.FilterICMPCheckBox); this.NFTabPage.Controls.Add(this.FilterICMPCheckBox);
this.NFTabPage.Controls.Add(this.DNSHijackLabel);
this.NFTabPage.Controls.Add(this.ICMPDelayLabel); this.NFTabPage.Controls.Add(this.ICMPDelayLabel);
this.NFTabPage.Controls.Add(this.ICMPDelayTextBox); this.NFTabPage.Controls.Add(this.ICMPDelayTextBox);
this.NFTabPage.Controls.Add(this.DNSHijackCheckBox); this.NFTabPage.Controls.Add(this.DNSHijackCheckBox);
@@ -367,7 +369,7 @@ namespace Netch.Forms
// ICMPDelayLabel // ICMPDelayLabel
// //
this.ICMPDelayLabel.AutoSize = true; 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.Name = "ICMPDelayLabel";
this.ICMPDelayLabel.Size = new System.Drawing.Size(100, 17); this.ICMPDelayLabel.Size = new System.Drawing.Size(100, 17);
this.ICMPDelayLabel.TabIndex = 3; this.ICMPDelayLabel.TabIndex = 3;
@@ -387,33 +389,29 @@ namespace Netch.Forms
this.DNSHijackCheckBox.AutoSize = true; this.DNSHijackCheckBox.AutoSize = true;
this.DNSHijackCheckBox.Location = new System.Drawing.Point(15, 110); this.DNSHijackCheckBox.Location = new System.Drawing.Point(15, 110);
this.DNSHijackCheckBox.Name = "DNSHijackCheckBox"; 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.TabIndex = 5;
this.DNSHijackCheckBox.Text = "Handle process\'s DNS Hijack"; this.DNSHijackCheckBox.Text = "DNS Hijack";
this.DNSHijackCheckBox.UseVisualStyleBackColor = true; this.DNSHijackCheckBox.UseVisualStyleBackColor = true;
this.DNSHijackCheckBox.Visible = false;
// //
// DNSHijackHostTextBox // DNSHijackHostTextBox
// //
this.DNSHijackHostTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Enabled", this.DNSHijackCheckBox, "Checked", true)); 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.Name = "DNSHijackHostTextBox";
this.DNSHijackHostTextBox.Size = new System.Drawing.Size(191, 23); this.DNSHijackHostTextBox.Size = new System.Drawing.Size(191, 23);
this.DNSHijackHostTextBox.TabIndex = 6; this.DNSHijackHostTextBox.TabIndex = 6;
this.DNSHijackHostTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this.DNSHijackHostTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.DNSHijackHostTextBox.Visible = false;
// //
// ChildProcessHandleCheckBox // ChildProcessHandleCheckBox
// //
this.ChildProcessHandleCheckBox.AutoSize = true; this.ChildProcessHandleCheckBox.AutoSize = true;
this.ChildProcessHandleCheckBox.Enabled = false; this.ChildProcessHandleCheckBox.Location = new System.Drawing.Point(15, 170);
this.ChildProcessHandleCheckBox.Location = new System.Drawing.Point(15, 140);
this.ChildProcessHandleCheckBox.Name = "ChildProcessHandleCheckBox"; this.ChildProcessHandleCheckBox.Name = "ChildProcessHandleCheckBox";
this.ChildProcessHandleCheckBox.Size = new System.Drawing.Size(150, 21); this.ChildProcessHandleCheckBox.Size = new System.Drawing.Size(150, 21);
this.ChildProcessHandleCheckBox.TabIndex = 7; this.ChildProcessHandleCheckBox.TabIndex = 7;
this.ChildProcessHandleCheckBox.Text = "Child Process Handle"; this.ChildProcessHandleCheckBox.Text = "Child Process Handle";
this.ChildProcessHandleCheckBox.UseVisualStyleBackColor = true; this.ChildProcessHandleCheckBox.UseVisualStyleBackColor = true;
this.ChildProcessHandleCheckBox.Visible = false;
// //
// WinTUNTabPage // WinTUNTabPage
// //
@@ -785,16 +783,6 @@ namespace Netch.Forms
this.MinimizeWhenStartedCheckBox.Text = "Minimize when started"; this.MinimizeWhenStartedCheckBox.Text = "Minimize when started";
this.MinimizeWhenStartedCheckBox.UseVisualStyleBackColor = true; 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 // RunAtStartupCheckBox
// //
this.RunAtStartupCheckBox.AutoSize = true; this.RunAtStartupCheckBox.AutoSize = true;
@@ -816,6 +804,16 @@ namespace Netch.Forms
this.CheckUpdateWhenOpenedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.CheckUpdateWhenOpenedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CheckUpdateWhenOpenedCheckBox.UseVisualStyleBackColor = true; 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 // CheckBetaUpdateCheckBox
// //
this.CheckBetaUpdateCheckBox.AutoSize = true; this.CheckBetaUpdateCheckBox.AutoSize = true;
@@ -929,6 +927,15 @@ namespace Netch.Forms
this.flowLayoutPanel1.Size = new System.Drawing.Size(480, 400); this.flowLayoutPanel1.Size = new System.Drawing.Size(480, 400);
this.flowLayoutPanel1.TabIndex = 0; 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 // SettingForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); 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.TextBox ICMPDelayTextBox;
private System.Windows.Forms.Label ICMPDelayLabel; private System.Windows.Forms.Label ICMPDelayLabel;
private System.Windows.Forms.CheckBox NoSupportDialogCheckBox; private System.Windows.Forms.CheckBox NoSupportDialogCheckBox;
private System.Windows.Forms.Label DNSHijackLabel;
} }
} }

View File

@@ -94,14 +94,14 @@ namespace Netch.Forms
Enum.GetNames(typeof(PortType)), Enum.GetNames(typeof(PortType)),
Global.Settings.Redirector.FilterProtocol.ToString()); 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); 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); 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, BindCheckBox(ChildProcessHandleCheckBox,
s => Global.Settings.Redirector.ChildProcessHandle = s, s => Global.Settings.Redirector.ChildProcessHandle = s,
Global.Settings.Redirector.ChildProcessHandle); Global.Settings.Redirector.ChildProcessHandle);

View File

@@ -10,12 +10,17 @@ namespace Netch.Interops
{ {
AIO_FILTERLOOPBACK, AIO_FILTERLOOPBACK,
AIO_FILTERINTRANET, // LAN AIO_FILTERINTRANET, // LAN
AIO_FILTERPARENT,
AIO_FILTERICMP, AIO_FILTERICMP,
AIO_FILTERTCP, AIO_FILTERTCP,
AIO_FILTERUDP, AIO_FILTERUDP,
AIO_FILTERDNS,
AIO_ICMPING, AIO_ICMPING,
AIO_DNSHOST,
AIO_DNSPORT,
AIO_TGTHOST, AIO_TGTHOST,
AIO_TGTPORT, AIO_TGTPORT,
AIO_TGTUSER, AIO_TGTUSER,

View File

@@ -2,8 +2,9 @@
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using Netch.Models; using Netch.Models;
using Netch.Utils;
namespace Netch.Utils namespace Netch.JsonConverter
{ {
public class ServerConverterWithTypeDiscriminator : JsonConverter<Server> public class ServerConverterWithTypeDiscriminator : JsonConverter<Server>
{ {

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization;
using Netch.Utils; using Netch.Utils;
namespace Netch.Models namespace Netch.Models
@@ -111,7 +110,6 @@ namespace Netch.Models
/// <summary> /// <summary>
/// 是否代理子进程 /// 是否代理子进程
/// </summary> /// </summary>
[JsonIgnore]
public bool ChildProcessHandle { get; set; } = false; public bool ChildProcessHandle { get; set; } = false;
} }

View File

@@ -70,6 +70,10 @@
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Remove="NativeMethods.txt" />
</ItemGroup>
<Target Condition="'$(PublishSingleFile)' == 'true'" AfterTargets="_ComputeFilesToBundle" Name="RemoveDupeAssemblies"> <Target Condition="'$(PublishSingleFile)' == 'true'" AfterTargets="_ComputeFilesToBundle" Name="RemoveDupeAssemblies">
<ItemGroup> <ItemGroup>
<_FilesToBundle Remove="$(PkgMicrosoft_Diagnostics_Tracing_TraceEvent)\build\native\x86\**" /> <_FilesToBundle Remove="$(PkgMicrosoft_Diagnostics_Tracing_TraceEvent)\build\native\x86\**" />

View File

@@ -152,7 +152,7 @@ namespace Netch.Servers
var tlsSettings = new TlsSettings var tlsSettings = new TlsSettings
{ {
allowInsecure = Global.Settings.V2RayConfig.AllowInsecure, allowInsecure = Global.Settings.V2RayConfig.AllowInsecure,
serverName = server.ServerName.ValueOrDefault() ?? server.Hostname serverName = server.ServerName.ValueOrDefault() ?? server.Host.SplitOrDefault()?[0]
}; };
switch (server.TLSSecureType) switch (server.TLSSecureType)

View File

@@ -5,6 +5,7 @@ using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.VisualStudio.Threading; using Microsoft.VisualStudio.Threading;
using Netch.JsonConverter;
using Netch.Models; using Netch.Models;
using Serilog; using Serilog;
@@ -90,8 +91,8 @@ namespace Netch.Utils
for (var i = 0; i < settings.Profiles.Count; i++) for (var i = 0; i < settings.Profiles.Count; i++)
settings.Profiles[i].Index = i; settings.Profiles[i].Index = i;
settings.AioDNS.ChinaDNS = Utils.HostAppendPort(settings.AioDNS.ChinaDNS); settings.AioDNS.ChinaDNS = DnsUtils.AppendPort(settings.AioDNS.ChinaDNS);
settings.AioDNS.OtherDNS = Utils.HostAppendPort(settings.AioDNS.OtherDNS); settings.AioDNS.OtherDNS = DnsUtils.AppendPort(settings.AioDNS.OtherDNS);
} }
/// <summary> /// <summary>

View File

@@ -101,5 +101,21 @@ namespace Netch.Utils
{ {
return string.Join(",", dns); 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;
}
} }
} }

View File

@@ -4,6 +4,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
using Netch.JsonConverter;
using Netch.Models; using Netch.Models;
using Netch.Servers; using Netch.Servers;
using Serilog; using Serilog;

View File

@@ -246,14 +246,6 @@ namespace Netch.Utils
return subnet.GetAddressBytes().Sum(b => Convert.ToString(b, 2).Count(c => c == '1')); 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) public static string GetHostFromUri(string str)
{ {
var startIndex = str.LastIndexOf('/'); var startIndex = str.LastIndexOf('/');

View File

@@ -1,5 +1,5 @@
param([string]$OutputPath) param([string]$OutputPath)
$address="https://github.com/XTLS/Xray-core/releases/download/v1.4.3/Xray-windows-64.zip" $address="https://github.com/XTLS/Xray-core/releases/download/v1.4.5/Xray-windows-64.zip"
Invoke-WebRequest -Uri $address -OutFile xray-core.zip Invoke-WebRequest -Uri $address -OutFile xray-core.zip
Expand-Archive -Force -Path xray-core.zip -DestinationPath xray-core Expand-Archive -Force -Path xray-core.zip -DestinationPath xray-core