Compare commits

...

12 Commits
1.8.9 ... 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
ChsBuffer
d02135f31b Bump version to 1.9.1 2021-10-01 12:39:57 +08:00
ChsBuffer
a7756dabc1 Fix GetReservedPortRange 2021-10-01 12:39:46 +08:00
ChsBuffer
7ce1127006 Move bin folder check before create directories exist.
cleanup Core.bin strings
2021-10-01 12:30:57 +08:00
ChsBuffer
fec84a4952 Update NFController
Update ICMPDelay setting
Update WebUtil Default UserAgent
Hide unimplemented features' settings
Remove unused HTTP Port setting
2021-10-01 12:11:45 +08:00
ChsBuffer
d335c69fab Fix Import Server from Clipboard not set default group 2021-09-28 18:11:52 +08:00
ChsBuffer
1228a565c1 Update texts
rename Subscribe Link (WTF??) to Subscription
Full English log
Remove Debug Logging Sink
Add Console Logging Sink
2021-09-23 20:17:45 +08:00
ChsBuffer
dc904c9c0b Fix start failed deadlock 2021-09-21 17:16:40 +08:00
ChsBuffer
d829e347d3 Bump version to 1.9.0 2021-09-21 10:30:04 +08:00
40 changed files with 573 additions and 513 deletions

View File

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

View File

@@ -41,6 +41,9 @@ jobs:
Netch.7z
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)
[**第一次使用请务必先安装 .NET 5.0 运行库**](https://aka.ms/dotnet/5.0/windowsdesktop-runtime-win-x64.exe)
## Changelogs
* This is an automated deployment of GitHub Actions, the change log should be updated manually soon

View File

@@ -7,7 +7,6 @@
public const string AioDnsRuleFile = "bin\\aiodns.conf";
public const string NFDriver = "bin\\nfdriver.sys";
public const string NFCore = "bin\\core.bin";
public const string STUNServersFile = "bin\\stun.txt";
public const string LogFile = "logging\\application.log";

View File

@@ -157,7 +157,7 @@ namespace Netch.Controllers
}
catch (Win32Exception e)
{
Log.Error(e, "停止 {Name} 异常", Instance.ProcessName);
Log.Error(e, "Stop {Name} failed", Instance.ProcessName);
}
catch
{

View File

@@ -10,7 +10,6 @@ using Netch.Models;
using Netch.Servers;
using Netch.Utils;
using Serilog;
using Serilog.Events;
namespace Netch.Controllers
{
@@ -32,7 +31,7 @@ namespace Netch.Controllers
public static async Task StartAsync(Server server, Mode mode)
{
using var _ = await Lock.EnterAsync();
using var releaser = await Lock.EnterAsync();
Log.Information("Start MainController: {Server} {Mode}", $"{server.Type}", $"[{(int)mode.Type}]{mode.Remark}");
@@ -48,14 +47,6 @@ namespace Netch.Controllers
await Task.WhenAll(Task.Run(NativeMethods.RefreshDNSCache), Task.Run(Firewall.AddNetchFwRules));
if (Log.IsEnabled(LogEventLevel.Debug))
Task.Run(() =>
{
// TODO log level setting
Log.Debug("Running Processes: \n{Processes}", string.Join("\n", SystemInfo.Processes(false)));
})
.Forget();
try
{
(ModeController, ModeFeatures) = ModeHelper.GetModeControllerByType(mode.Type, out var modePort, out var portName);
@@ -88,6 +79,7 @@ namespace Netch.Controllers
}
catch (Exception e)
{
releaser.Dispose();
await StopAsync();
switch (e)

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.ServiceProcess;
@@ -33,24 +32,33 @@ namespace Netch.Controllers
_mode = mode;
_rdrConfig = Global.Settings.Redirector;
CheckDriver();
CheckCore();
Dial(NameList.TYPE_FILTERLOOPBACK, "false");
Dial(NameList.TYPE_FILTERICMP, "true");
var p = PortHelper.GetAvailablePort();
Dial(NameList.TYPE_TCPLISN, p.ToString());
Dial(NameList.TYPE_UDPLISN, p.ToString());
Dial(NameList.AIO_FILTERLOOPBACK, "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());
// Server
Dial(NameList.TYPE_FILTERUDP, _rdrConfig.FilterProtocol.HasFlag(PortType.UDP).ToString().ToLower());
Dial(NameList.TYPE_FILTERTCP, _rdrConfig.FilterProtocol.HasFlag(PortType.TCP).ToString().ToLower());
await DialServerAsync(_rdrConfig.FilterProtocol, _server);
Dial(NameList.AIO_FILTERUDP, _rdrConfig.FilterProtocol.HasFlag(PortType.UDP).ToString().ToLower());
Dial(NameList.AIO_FILTERTCP, _rdrConfig.FilterProtocol.HasFlag(PortType.TCP).ToString().ToLower());
Dial(NameList.AIO_TGTHOST, await server.AutoResolveHostnameAsync());
Dial(NameList.AIO_TGTPORT, server.Port.ToString());
Dial(NameList.AIO_TGTUSER, server.Username ?? string.Empty);
Dial(NameList.AIO_TGTPASS, server.Password ?? string.Empty);
// Mode Rule
dial_Name(_mode);
DialRule(_mode);
// Features
Dial(NameList.TYPE_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.");
@@ -73,14 +81,14 @@ namespace Netch.Controllers
try
{
if (r.StartsWith("!"))
return Dial(NameList.TYPE_ADDNAME, r.Substring(1));
return Dial(NameList.AIO_ADDNAME, r.Substring(1));
return Dial(NameList.TYPE_ADDNAME, r);
return Dial(NameList.AIO_ADDNAME, r);
}
finally
{
if (clear)
Dial(NameList.TYPE_CLRNAME, "");
Dial(NameList.AIO_CLRNAME, "");
}
}
@@ -92,71 +100,40 @@ namespace Netch.Controllers
public static bool CheckRules(IEnumerable<string> rules, out IEnumerable<string> results)
{
results = rules.Where(r => !CheckCppRegex(r, false));
Dial(NameList.TYPE_CLRNAME, "");
Dial(NameList.AIO_CLRNAME, "");
return !results.Any();
}
public static string GenerateInvalidRulesMessage(IEnumerable<string> rules)
{
return $"{string.Join("\n", rules)}\nAbove rules does not conform to C++ regular expression syntax";
return $"{string.Join("\n", rules)}\n" + i18N.Translate("Above rules does not conform to C++ regular expression syntax");
}
#endregion
private async Task DialServerAsync(PortType portType, Server server)
private void DialRule(Mode mode)
{
if (portType == PortType.Both)
{
await DialServerAsync(PortType.TCP, server);
await DialServerAsync(PortType.UDP, server);
return;
}
var offset = portType == PortType.UDP ? UdpNameListOffset : 0;
if (server is Socks5Server socks5)
{
Dial(NameList.TYPE_TCPTYPE + offset, "Socks5");
Dial(NameList.TYPE_TCPHOST + offset, $"{await socks5.AutoResolveHostnameAsync()}:{socks5.Port}");
Dial(NameList.TYPE_TCPUSER + offset, socks5.Username ?? string.Empty);
Dial(NameList.TYPE_TCPPASS + offset, socks5.Password ?? string.Empty);
Dial(NameList.TYPE_TCPMETH + offset, string.Empty);
}
else
{
Trace.Assert(false);
}
}
private void dial_Name(Mode mode)
{
Dial(NameList.TYPE_CLRNAME, "");
Dial(NameList.AIO_CLRNAME, "");
var invalidList = new List<string>();
foreach (var s in mode.GetRules())
{
if (s.StartsWith("!"))
{
if (!Dial(NameList.TYPE_BYPNAME, s.Substring(1)))
if (!Dial(NameList.AIO_BYPNAME, s.Substring(1)))
invalidList.Add(s);
continue;
}
if (!Dial(NameList.TYPE_ADDNAME, s))
if (!Dial(NameList.AIO_ADDNAME, s))
invalidList.Add(s);
}
if (invalidList.Any())
throw new MessageException(GenerateInvalidRulesMessage(invalidList));
Dial(NameList.TYPE_ADDNAME, @"NTT\.exe");
Dial(NameList.TYPE_BYPNAME, "^" + Global.NetchDir.ToRegexString() + @"((?!NTT\.exe).)*$");
}
private void CheckCore()
{
if (!File.Exists(Constants.NFCore))
throw new MessageException(i18N.Translate("\"Core.bin\" is missing. Please check your Antivirus software"));
// Bypass Self
Dial(NameList.AIO_BYPNAME, "^" + Global.NetchDir.ToRegexString());
}
#region DriverUtil
@@ -166,8 +143,8 @@ namespace Netch.Controllers
var binFileVersion = Utils.Utils.GetFileVersion(Constants.NFDriver);
var systemFileVersion = Utils.Utils.GetFileVersion(SystemDriver);
Log.Information("内置驱动版本: {Name}", binFileVersion);
Log.Information("系统驱动版本: {Name}", systemFileVersion);
Log.Information("Built-in netfilter2 driver version: {Name}", binFileVersion);
Log.Information("Installed netfilter2 driver version: {Name}", systemFileVersion);
if (!File.Exists(SystemDriver))
{
@@ -197,7 +174,7 @@ namespace Netch.Controllers
if (!reinstall)
return;
Log.Information("更新驱动");
Log.Information("Update netfilter2 driver");
UninstallDriver();
InstallDriver();
}
@@ -208,7 +185,8 @@ namespace Netch.Controllers
/// <returns>驱动是否安装成功</returns>
private static void InstallDriver()
{
Log.Information("安装 NF 驱动");
Log.Information("Install netfilter2 driver");
Global.MainForm.StatusText(i18N.Translate("Installing netfilter2 driver"));
if (!File.Exists(Constants.NFDriver))
throw new MessageException(i18N.Translate("builtin driver files missing, can't install NF driver"));
@@ -219,21 +197,20 @@ namespace Netch.Controllers
}
catch (Exception e)
{
Log.Error(e, "驱动复制失败\n");
throw new MessageException($"Copy NF driver file failed\n{e.Message}");
Log.Error(e, "Copy netfilter2.sys failed\n");
throw new MessageException($"Copy netfilter2.sys failed\n{e.Message}");
}
Global.MainForm.StatusText(i18N.Translate("Register driver"));
// 注册驱动文件
var result = NFAPI.nf_registerDriver("netfilter2");
if (result == NF_STATUS.NF_STATUS_SUCCESS)
{
Log.Information("驱动安装成功");
Log.Information("Install netfilter2 driver finished");
}
else
{
Log.Error("注册驱动失败: {Result}", result);
throw new MessageException($"Register NF driver failed\n{result}");
Log.Error("Register netfilter2 failed: {Result}", result);
throw new MessageException($"Register netfilter2 failed\n{result}");
}
}
@@ -243,7 +220,7 @@ namespace Netch.Controllers
/// <returns>是否成功卸载</returns>
public static bool UninstallDriver()
{
Log.Information("卸载 NF 驱动");
Log.Information("Uninstall netfilter2");
try
{
if (NFService.Status == ServiceControllerStatus.Running)

View File

@@ -125,8 +125,8 @@ namespace Netch.Controllers
var binHash = Utils.Utils.SHA256CheckSum(binDriver);
var sysHash = Utils.Utils.SHA256CheckSum(sysDriver);
Log.Information("自带 wintun.dll Hash: {Hash}", binHash);
Log.Information("系统 wintun.dll Hash: {Hash}", sysHash);
Log.Information("Built-in wintun.dll Hash: {Hash}", binHash);
Log.Information("Installed wintun.dll Hash: {Hash}", sysHash);
if (binHash == sysHash)
return;
@@ -137,7 +137,7 @@ namespace Netch.Controllers
}
catch (Exception e)
{
Log.Error(e, "复制 wintun.dll 异常");
Log.Error(e, "Copy wintun.dll failed");
throw new MessageException($"Failed to copy wintun.dll to system directory: {e.Message}");
}
}

View File

@@ -20,7 +20,7 @@ namespace Netch.Controllers
public const string Name = @"Netch";
public const string Copyright = @"Copyright © 2019 - 2021";
public const string AssemblyVersion = @"1.8.9";
public const string AssemblyVersion = @"1.9.2";
private const string Suffix = @"";
public static readonly string Version = $"{AssemblyVersion}{(string.IsNullOrEmpty(Suffix) ? "" : $"-{Suffix}")}";
@@ -48,24 +48,24 @@ namespace Netch.Controllers
var releases = JsonSerializer.Deserialize<List<Release>>(json)!;
LatestRelease = GetLatestRelease(releases, isPreRelease);
Log.Information("Github 最新发布版本: {Version}", LatestRelease.tag_name);
Log.Information("Github latest release: {Version}", LatestRelease.tag_name);
if (VersionUtil.CompareVersion(LatestRelease.tag_name, Version) > 0)
{
Log.Information("发现新版本");
Log.Information("Found newer version");
NewVersionFound?.Invoke(null, EventArgs.Empty);
}
else
{
Log.Information("目前是最新版本");
Log.Information("Already the latest version");
NewVersionNotFound?.Invoke(null, EventArgs.Empty);
}
}
catch (Exception e)
{
if (e is WebException)
Log.Warning(e, "获取新版本失败");
Log.Warning(e, "Get releases failed");
else
Log.Error(e, "获取新版本异常");
Log.Error(e, "Get releases error");
NewVersionFoundFailed?.Invoke(null, EventArgs.Empty);
}

View File

@@ -35,19 +35,19 @@
this.ModeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.CreateProcessModeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.CreateRouteTableRuleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SubscribeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ManageSubscribeLinksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.UpdateServersFromSubscribeLinksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SubscriptionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ManageSubscriptionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.UpdateServersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.OptionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.OpenDirectoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ShowHideConsoleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.CleanDNSCacheToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.UninstallServiceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeNetchFirewallRulesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.RemoveNetchFirewallRulesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.HelpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.CheckForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.fAQToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.CheckForUpdateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.FAQToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ForceExitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AboutToolStripButton = new System.Windows.Forms.ToolStripButton();
this.NewVersionLabel = new System.Windows.Forms.ToolStripLabel();
this.VersionLabel = new System.Windows.Forms.ToolStripLabel();
@@ -111,10 +111,10 @@
this.MenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ServerToolStripMenuItem,
this.ModeToolStripMenuItem,
this.SubscribeToolStripMenuItem,
this.SubscriptionToolStripMenuItem,
this.OptionsToolStripMenuItem,
this.HelpToolStripMenuItem,
this.exitToolStripMenuItem,
this.ForceExitToolStripMenuItem,
this.AboutToolStripButton,
this.NewVersionLabel,
this.VersionLabel});
@@ -164,29 +164,29 @@
this.CreateRouteTableRuleToolStripMenuItem.Text = "Create Route Table Rule";
this.CreateRouteTableRuleToolStripMenuItem.Click += new System.EventHandler(this.createRouteTableModeToolStripMenuItem_Click);
//
// SubscribeToolStripMenuItem
// SubscriptionToolStripMenuItem
//
this.SubscribeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ManageSubscribeLinksToolStripMenuItem,
this.UpdateServersFromSubscribeLinksToolStripMenuItem});
this.SubscribeToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
this.SubscribeToolStripMenuItem.Name = "SubscribeToolStripMenuItem";
this.SubscribeToolStripMenuItem.Size = new System.Drawing.Size(77, 21);
this.SubscribeToolStripMenuItem.Text = "Subscribe";
this.SubscriptionToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ManageSubscriptionsToolStripMenuItem,
this.UpdateServersToolStripMenuItem});
this.SubscriptionToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
this.SubscriptionToolStripMenuItem.Name = "SubscriptionToolStripMenuItem";
this.SubscriptionToolStripMenuItem.Size = new System.Drawing.Size(92, 21);
this.SubscriptionToolStripMenuItem.Text = "Subscription";
//
// ManageSubscribeLinksToolStripMenuItem
// ManageSubscriptionsToolStripMenuItem
//
this.ManageSubscribeLinksToolStripMenuItem.Name = "ManageSubscribeLinksToolStripMenuItem";
this.ManageSubscribeLinksToolStripMenuItem.Size = new System.Drawing.Size(294, 22);
this.ManageSubscribeLinksToolStripMenuItem.Text = "Manage Subscribe Links";
this.ManageSubscribeLinksToolStripMenuItem.Click += new System.EventHandler(this.ManageSubscribeLinksToolStripMenuItem_Click);
this.ManageSubscriptionsToolStripMenuItem.Name = "ManageSubscriptionsToolStripMenuItem";
this.ManageSubscriptionsToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
this.ManageSubscriptionsToolStripMenuItem.Text = "Manage Subscriptions";
this.ManageSubscriptionsToolStripMenuItem.Click += new System.EventHandler(this.ManageSubscriptionLinksToolStripMenuItem_Click);
//
// UpdateServersFromSubscribeLinksToolStripMenuItem
// UpdateServersToolStripMenuItem
//
this.UpdateServersFromSubscribeLinksToolStripMenuItem.Name = "UpdateServersFromSubscribeLinksToolStripMenuItem";
this.UpdateServersFromSubscribeLinksToolStripMenuItem.Size = new System.Drawing.Size(294, 22);
this.UpdateServersFromSubscribeLinksToolStripMenuItem.Text = "Update Servers From Subscribe Links";
this.UpdateServersFromSubscribeLinksToolStripMenuItem.Click += new System.EventHandler(this.UpdateServersFromSubscribeLinksToolStripMenuItem_Click);
this.UpdateServersToolStripMenuItem.Name = "UpdateServersToolStripMenuItem";
this.UpdateServersToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
this.UpdateServersToolStripMenuItem.Text = "Update Servers";
this.UpdateServersToolStripMenuItem.Click += new System.EventHandler(this.UpdateServersFromSubscriptionLinksToolStripMenuItem_Click);
//
// OptionsToolStripMenuItem
//
@@ -195,7 +195,7 @@
this.ShowHideConsoleToolStripMenuItem,
this.CleanDNSCacheToolStripMenuItem,
this.UninstallServiceToolStripMenuItem,
this.removeNetchFirewallRulesToolStripMenuItem});
this.RemoveNetchFirewallRulesToolStripMenuItem});
this.OptionsToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
this.OptionsToolStripMenuItem.Name = "OptionsToolStripMenuItem";
this.OptionsToolStripMenuItem.Size = new System.Drawing.Size(66, 21);
@@ -229,43 +229,43 @@
this.UninstallServiceToolStripMenuItem.Text = "Uninstall NF Service";
this.UninstallServiceToolStripMenuItem.Click += new System.EventHandler(this.UninstallServiceToolStripMenuItem_Click);
//
// removeNetchFirewallRulesToolStripMenuItem
// RemoveNetchFirewallRulesToolStripMenuItem
//
this.removeNetchFirewallRulesToolStripMenuItem.Name = "removeNetchFirewallRulesToolStripMenuItem";
this.removeNetchFirewallRulesToolStripMenuItem.Size = new System.Drawing.Size(243, 22);
this.removeNetchFirewallRulesToolStripMenuItem.Text = "Remove Netch Firewall Rules";
this.removeNetchFirewallRulesToolStripMenuItem.Click += new System.EventHandler(this.RemoveNetchFirewallRulesToolStripMenuItem_Click);
this.RemoveNetchFirewallRulesToolStripMenuItem.Name = "RemoveNetchFirewallRulesToolStripMenuItem";
this.RemoveNetchFirewallRulesToolStripMenuItem.Size = new System.Drawing.Size(243, 22);
this.RemoveNetchFirewallRulesToolStripMenuItem.Text = "Remove Netch Firewall Rules";
this.RemoveNetchFirewallRulesToolStripMenuItem.Click += new System.EventHandler(this.RemoveNetchFirewallRulesToolStripMenuItem_Click);
//
// HelpToolStripMenuItem
//
this.HelpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.CheckForUpdatesToolStripMenuItem,
this.fAQToolStripMenuItem});
this.CheckForUpdateToolStripMenuItem,
this.FAQToolStripMenuItem});
this.HelpToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
this.HelpToolStripMenuItem.Name = "HelpToolStripMenuItem";
this.HelpToolStripMenuItem.Size = new System.Drawing.Size(47, 21);
this.HelpToolStripMenuItem.Text = "Help";
//
// CheckForUpdatesToolStripMenuItem
// CheckForUpdateToolStripMenuItem
//
this.CheckForUpdatesToolStripMenuItem.Name = "CheckForUpdatesToolStripMenuItem";
this.CheckForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.CheckForUpdatesToolStripMenuItem.Text = "Check for updates";
this.CheckForUpdatesToolStripMenuItem.Click += new System.EventHandler(this.CheckForUpdatesToolStripMenuItem_Click);
this.CheckForUpdateToolStripMenuItem.Name = "CheckForUpdateToolStripMenuItem";
this.CheckForUpdateToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.CheckForUpdateToolStripMenuItem.Text = "Check for update";
this.CheckForUpdateToolStripMenuItem.Click += new System.EventHandler(this.CheckForUpdatesToolStripMenuItem_Click);
//
// fAQToolStripMenuItem
// FAQToolStripMenuItem
//
this.fAQToolStripMenuItem.Name = "fAQToolStripMenuItem";
this.fAQToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.fAQToolStripMenuItem.Text = "FAQ";
this.fAQToolStripMenuItem.Click += new System.EventHandler(this.fAQToolStripMenuItem_Click);
this.FAQToolStripMenuItem.Name = "FAQToolStripMenuItem";
this.FAQToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.FAQToolStripMenuItem.Text = "FAQ";
this.FAQToolStripMenuItem.Click += new System.EventHandler(this.fAQToolStripMenuItem_Click);
//
// exitToolStripMenuItem
// ForceExitToolStripMenuItem
//
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(40, 22);
this.exitToolStripMenuItem.Text = "Exit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
this.ForceExitToolStripMenuItem.Name = "ForceExitToolStripMenuItem";
this.ForceExitToolStripMenuItem.Size = new System.Drawing.Size(40, 22);
this.ForceExitToolStripMenuItem.Text = "Exit";
this.ForceExitToolStripMenuItem.Click += new System.EventHandler(this.ForceExitToolStripMenuItem_Click);
//
// AboutToolStripButton
//
@@ -562,7 +562,7 @@
// blankToolStripStatusLabel
//
this.blankToolStripStatusLabel.Name = "blankToolStripStatusLabel";
this.blankToolStripStatusLabel.Size = new System.Drawing.Size(240, 17);
this.blankToolStripStatusLabel.Size = new System.Drawing.Size(494, 17);
this.blankToolStripStatusLabel.Spring = true;
//
// HttpStatusLabel
@@ -620,19 +620,19 @@
this.ExitToolStripButton});
this.NotifyMenu.Name = "NotifyMenu";
this.NotifyMenu.ShowItemToolTips = false;
this.NotifyMenu.Size = new System.Drawing.Size(108, 48);
this.NotifyMenu.Size = new System.Drawing.Size(181, 70);
//
// ShowMainFormToolStripButton
//
this.ShowMainFormToolStripButton.Name = "ShowMainFormToolStripButton";
this.ShowMainFormToolStripButton.Size = new System.Drawing.Size(107, 22);
this.ShowMainFormToolStripButton.Size = new System.Drawing.Size(180, 22);
this.ShowMainFormToolStripButton.Text = "Show";
this.ShowMainFormToolStripButton.Click += new System.EventHandler(this.ShowMainFormToolStripButton_Click);
//
// ExitToolStripButton
//
this.ExitToolStripButton.Name = "ExitToolStripButton";
this.ExitToolStripButton.Size = new System.Drawing.Size(107, 22);
this.ExitToolStripButton.Size = new System.Drawing.Size(180, 22);
this.ExitToolStripButton.Text = "Exit";
this.ExitToolStripButton.Click += new System.EventHandler(this.ExitToolStripButton_Click);
//
@@ -744,7 +744,7 @@
private System.Windows.Forms.ToolStripMenuItem CreateRouteTableRuleToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem removeNetchFirewallRulesToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem RemoveNetchFirewallRulesToolStripMenuItem;
private System.Windows.Forms.ToolStripButton AboutToolStripButton;
private System.Windows.Forms.ToolStripMenuItem CleanDNSCacheToolStripMenuItem;
@@ -759,9 +759,9 @@
private System.Windows.Forms.PictureBox EditModePictureBox;
private System.Windows.Forms.PictureBox EditServerPictureBox;
private System.Windows.Forms.ToolStripMenuItem ExitToolStripButton;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ForceExitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ImportServersFromClipboardToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ManageSubscribeLinksToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ManageSubscriptionsToolStripMenuItem;
private System.Windows.Forms.MenuStrip MenuStrip;
public System.Windows.Forms.ComboBox ModeComboBox;
private System.Windows.Forms.Label ModeLabel;
@@ -776,7 +776,7 @@
private System.Windows.Forms.Label ProfileLabel;
private System.Windows.Forms.TextBox ProfileNameText;
private System.Windows.Forms.TableLayoutPanel ProfileTable;
private System.Windows.Forms.ToolStripMenuItem CheckForUpdatesToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem CheckForUpdateToolStripMenuItem;
private System.Windows.Forms.ComboBox ServerComboBox;
private System.Windows.Forms.Label ServerLabel;
private System.Windows.Forms.ToolStripMenuItem ServerToolStripMenuItem;
@@ -785,18 +785,18 @@
private System.Windows.Forms.PictureBox SpeedPictureBox;
private System.Windows.Forms.ToolStripStatusLabel StatusLabel;
private System.Windows.Forms.StatusStrip StatusStrip;
private System.Windows.Forms.ToolStripMenuItem SubscribeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem SubscriptionToolStripMenuItem;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
private System.Windows.Forms.ToolStripMenuItem UninstallServiceToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem UpdateServersFromSubscribeLinksToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem UpdateServersToolStripMenuItem;
private System.Windows.Forms.ToolStripStatusLabel UploadSpeedLabel;
private System.Windows.Forms.ToolStripStatusLabel UsedBandwidthLabel;
private System.Windows.Forms.ToolStripLabel NewVersionLabel;
private System.Windows.Forms.ToolStripLabel VersionLabel;
private System.Windows.Forms.ToolStripStatusLabel NatTypeStatusLightLabel;
private System.Windows.Forms.ToolStripStatusLabel blankToolStripStatusLabel;
private System.Windows.Forms.ToolStripMenuItem fAQToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem FAQToolStripMenuItem;
#endregion

View File

@@ -103,7 +103,7 @@ namespace Netch.Forms
// 检查订阅更新
if (Global.Settings.UpdateServersWhenOpened)
UpdateServersFromSubscribeAsync().Forget();
UpdateServersFromSubscriptionAsync().Forget();
// 打开软件时启动加速,产生开始按钮点击事件
if (Global.Settings.StartWhenOpened)
@@ -215,15 +215,18 @@ namespace Netch.Forms
private async void ImportServersFromClipboardToolStripMenuItem_Click(object sender, EventArgs e)
{
var texts = Clipboard.GetText();
if (!string.IsNullOrWhiteSpace(texts))
{
var servers = ShareLink.ParseText(texts);
Global.Settings.Server.AddRange(servers);
NotifyTip(i18N.TranslateFormat("Import {0} server(s) form Clipboard", servers.Count));
if (string.IsNullOrWhiteSpace(texts))
return;
LoadServers();
await Configuration.SaveAsync();
}
var servers = ShareLink.ParseText(texts);
foreach (var server in servers)
server.Group = Constants.DefaultGroup;
Global.Settings.Server.AddRange(servers);
NotifyTip(i18N.TranslateFormat("Import {0} server(s) form Clipboard", servers.Count));
LoadServers();
await Configuration.SaveAsync();
}
private async void AddServerToolStripMenuItem_Click([NotNull] object? sender, EventArgs? e)
@@ -263,47 +266,47 @@ namespace Netch.Forms
#region Subscription
private void ManageSubscribeLinksToolStripMenuItem_Click(object sender, EventArgs e)
private void ManageSubscriptionLinksToolStripMenuItem_Click(object sender, EventArgs e)
{
Hide();
new SubscribeForm().ShowDialog();
new SubscriptionForm().ShowDialog();
LoadServers();
Show();
}
private async void UpdateServersFromSubscribeLinksToolStripMenuItem_Click(object sender, EventArgs e)
private async void UpdateServersFromSubscriptionLinksToolStripMenuItem_Click(object sender, EventArgs e)
{
await UpdateServersFromSubscribeAsync();
await UpdateServersFromSubscriptionAsync();
}
private async Task UpdateServersFromSubscribeAsync()
private async Task UpdateServersFromSubscriptionAsync()
{
void DisableItems(bool v)
{
MenuStrip.Enabled = ConfigurationGroupBox.Enabled = ProfileGroupBox.Enabled = ControlButton.Enabled = v;
}
if (Global.Settings.SubscribeLink.Count <= 0)
if (Global.Settings.Subscription.Count <= 0)
{
MessageBoxX.Show(i18N.Translate("No subscription link"));
return;
}
StatusText(i18N.Translate("Starting update subscription"));
StatusText(i18N.Translate("Updating servers"));
DisableItems(false);
try
{
await Subscription.UpdateServersAsync();
await SubscriptionUtil.UpdateServersAsync();
LoadServers();
await Configuration.SaveAsync();
StatusText(i18N.Translate("Subscription updated"));
StatusText(i18N.Translate("Servers updated"));
}
catch (Exception e)
{
NotifyTip(i18N.Translate("update servers failed") + "\n" + e.Message, info: false);
Log.Error("更新服务器 失败!" + e);
NotifyTip(i18N.Translate("Unhandled update servers error") + "\n" + e.Message, info: false);
Log.Error(e, "Unhandled Update servers error");
}
finally
{
@@ -324,7 +327,7 @@ namespace Netch.Forms
void OnNewVersionFoundFailed(object? o, EventArgs? args)
{
NotifyTip(i18N.Translate("New version found failed"), info: false);
NotifyTip(i18N.Translate("Check for update failed"), info: false);
}
try
@@ -402,7 +405,7 @@ namespace Netch.Forms
/// <summary>
/// 菜单栏强制退出
/// </summary>
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
private void ForceExitToolStripMenuItem_Click(object sender, EventArgs e)
{
Exit(true);
}
@@ -482,7 +485,7 @@ namespace Netch.Forms
}
catch (Exception exception)
{
Log.Error(exception, "更新未处理异常");
Log.Error(exception, "Unhandled Update error");
NotifyTip(exception.Message, info: false);
}
finally
@@ -582,7 +585,7 @@ namespace Netch.Forms
private void SettingsButton_Click(object sender, EventArgs e)
{
var oldSettings = Global.Settings.Clone();
var oldSettings = Global.Settings.ShallowCopy();
Hide();
new SettingForm().ShowDialog();
@@ -995,7 +998,7 @@ namespace Netch.Forms
// 启动需要禁用的控件
ServerToolStripMenuItem.Enabled = ModeToolStripMenuItem.Enabled =
SubscribeToolStripMenuItem.Enabled = UninstallServiceToolStripMenuItem.Enabled = enabled;
SubscriptionToolStripMenuItem.Enabled = UninstallServiceToolStripMenuItem.Enabled = enabled;
}
_state = value;
@@ -1172,7 +1175,7 @@ namespace Netch.Forms
private async Task DiscoveryNatTypeAsync()
{
NatTypeStatusLabel.Enabled = false;
UpdateNatTypeStatusLabelText("Testing NAT Type");
UpdateNatTypeStatusLabelText(i18N.Translate("Testing NAT Type"));
_discoveryNatCts = new CancellationTokenSource();
@@ -1253,7 +1256,7 @@ namespace Netch.Forms
if (!IsWaiting())
{
_resumeFlag = true;
Log.Information("操作系统即将挂起,自动停止");
Log.Information("OS Suspend, Stop");
ControlButton_Click(null, null);
}
@@ -1262,7 +1265,7 @@ namespace Netch.Forms
if (_resumeFlag)
{
_resumeFlag = false;
Log.Information("操作系统即将从挂起状态继续,自动重启");
Log.Information("OS Resume, Restart");
ControlButton_Click(null, null);
}

View File

@@ -36,8 +36,6 @@ namespace Netch.Forms
this.PortGroupBox = new System.Windows.Forms.GroupBox();
this.Socks5PortLabel = new System.Windows.Forms.Label();
this.Socks5PortTextBox = new System.Windows.Forms.TextBox();
this.HTTPPortLabel = new System.Windows.Forms.Label();
this.HTTPPortTextBox = new System.Windows.Forms.TextBox();
this.AllowDevicesCheckBox = new System.Windows.Forms.CheckBox();
this.ServerPingTypeLabel = new System.Windows.Forms.Label();
this.ICMPingRadioBtn = new System.Windows.Forms.RadioButton();
@@ -55,11 +53,11 @@ namespace Netch.Forms
this.NFTabPage = new System.Windows.Forms.TabPage();
this.ProcessFilterProtocolLabel = new System.Windows.Forms.Label();
this.ProcessFilterProtocolComboBox = new System.Windows.Forms.ComboBox();
this.DNSHijackCheckBox = new System.Windows.Forms.CheckBox();
this.DNSHijackHostTextBox = new System.Windows.Forms.TextBox();
this.FilterICMPCheckBox = new System.Windows.Forms.CheckBox();
this.ICMPDelayLabel = new System.Windows.Forms.Label();
this.ICMPDelayTextBox = new System.Windows.Forms.TextBox();
this.DNSHijackCheckBox = new System.Windows.Forms.CheckBox();
this.DNSHijackHostTextBox = new System.Windows.Forms.TextBox();
this.ChildProcessHandleCheckBox = new System.Windows.Forms.CheckBox();
this.WinTUNTabPage = new System.Windows.Forms.TabPage();
this.WinTUNGroupBox = new System.Windows.Forms.GroupBox();
@@ -97,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();
@@ -111,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();
@@ -167,8 +166,6 @@ namespace Netch.Forms
//
this.PortGroupBox.Controls.Add(this.Socks5PortLabel);
this.PortGroupBox.Controls.Add(this.Socks5PortTextBox);
this.PortGroupBox.Controls.Add(this.HTTPPortLabel);
this.PortGroupBox.Controls.Add(this.HTTPPortTextBox);
this.PortGroupBox.Controls.Add(this.AllowDevicesCheckBox);
this.PortGroupBox.Location = new System.Drawing.Point(8, 6);
this.PortGroupBox.Name = "PortGroupBox";
@@ -194,23 +191,6 @@ namespace Netch.Forms
this.Socks5PortTextBox.TabIndex = 1;
this.Socks5PortTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// HTTPPortLabel
//
this.HTTPPortLabel.AutoSize = true;
this.HTTPPortLabel.Location = new System.Drawing.Point(9, 54);
this.HTTPPortLabel.Name = "HTTPPortLabel";
this.HTTPPortLabel.Size = new System.Drawing.Size(38, 17);
this.HTTPPortLabel.TabIndex = 2;
this.HTTPPortLabel.Text = "HTTP";
//
// HTTPPortTextBox
//
this.HTTPPortTextBox.Location = new System.Drawing.Point(120, 51);
this.HTTPPortTextBox.Name = "HTTPPortTextBox";
this.HTTPPortTextBox.Size = new System.Drawing.Size(90, 23);
this.HTTPPortTextBox.TabIndex = 3;
this.HTTPPortTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// AllowDevicesCheckBox
//
this.AllowDevicesCheckBox.AutoSize = true;
@@ -344,11 +324,12 @@ namespace Netch.Forms
this.NFTabPage.BackColor = System.Drawing.SystemColors.ButtonFace;
this.NFTabPage.Controls.Add(this.ProcessFilterProtocolLabel);
this.NFTabPage.Controls.Add(this.ProcessFilterProtocolComboBox);
this.NFTabPage.Controls.Add(this.DNSHijackCheckBox);
this.NFTabPage.Controls.Add(this.DNSHijackHostTextBox);
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);
this.NFTabPage.Controls.Add(this.DNSHijackHostTextBox);
this.NFTabPage.Controls.Add(this.ChildProcessHandleCheckBox);
this.NFTabPage.Location = new System.Drawing.Point(4, 29);
this.NFTabPage.Name = "NFTabPage";
@@ -375,61 +356,60 @@ namespace Netch.Forms
this.ProcessFilterProtocolComboBox.Size = new System.Drawing.Size(98, 25);
this.ProcessFilterProtocolComboBox.TabIndex = 1;
//
// DNSHijackCheckBox
//
this.DNSHijackCheckBox.AutoSize = true;
this.DNSHijackCheckBox.Location = new System.Drawing.Point(15, 50);
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;
//
// DNSHijackHostTextBox
//
this.DNSHijackHostTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Enabled", this.DNSHijackCheckBox, "Checked", true));
this.DNSHijackHostTextBox.Location = new System.Drawing.Point(237, 48);
this.DNSHijackHostTextBox.Name = "DNSHijackHostTextBox";
this.DNSHijackHostTextBox.Size = new System.Drawing.Size(191, 23);
this.DNSHijackHostTextBox.TabIndex = 3;
this.DNSHijackHostTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// FilterICMPCheckBox
//
this.FilterICMPCheckBox.AutoSize = true;
this.FilterICMPCheckBox.Location = new System.Drawing.Point(13, 80);
this.FilterICMPCheckBox.Location = new System.Drawing.Point(15, 50);
this.FilterICMPCheckBox.Name = "FilterICMPCheckBox";
this.FilterICMPCheckBox.Size = new System.Drawing.Size(90, 21);
this.FilterICMPCheckBox.TabIndex = 4;
this.FilterICMPCheckBox.TabIndex = 2;
this.FilterICMPCheckBox.Text = "Filter ICMP";
this.FilterICMPCheckBox.UseVisualStyleBackColor = true;
//
// ICMPDelayLabel
//
this.ICMPDelayLabel.AutoSize = true;
this.ICMPDelayLabel.Location = new System.Drawing.Point(30, 110);
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 = 5;
this.ICMPDelayLabel.TabIndex = 3;
this.ICMPDelayLabel.Text = "ICMP Delay(ms)";
//
// ICMPDelayTextBox
//
this.ICMPDelayTextBox.Location = new System.Drawing.Point(237, 107);
this.ICMPDelayTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Enabled", this.FilterICMPCheckBox, "Checked", true));
this.ICMPDelayTextBox.Location = new System.Drawing.Point(237, 77);
this.ICMPDelayTextBox.Name = "ICMPDelayTextBox";
this.ICMPDelayTextBox.ReadOnly = true;
this.ICMPDelayTextBox.Size = new System.Drawing.Size(98, 23);
this.ICMPDelayTextBox.TabIndex = 6;
this.ICMPDelayTextBox.TabIndex = 4;
this.ICMPDelayTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// DNSHijackCheckBox
//
this.DNSHijackCheckBox.AutoSize = true;
this.DNSHijackCheckBox.Location = new System.Drawing.Point(15, 110);
this.DNSHijackCheckBox.Name = "DNSHijackCheckBox";
this.DNSHijackCheckBox.Size = new System.Drawing.Size(92, 21);
this.DNSHijackCheckBox.TabIndex = 5;
this.DNSHijackCheckBox.Text = "DNS Hijack";
this.DNSHijackCheckBox.UseVisualStyleBackColor = true;
//
// DNSHijackHostTextBox
//
this.DNSHijackHostTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Enabled", this.DNSHijackCheckBox, "Checked", true));
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;
//
// 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 = 8;
this.ChildProcessHandleCheckBox.TabIndex = 7;
this.ChildProcessHandleCheckBox.Text = "Child Process Handle";
this.ChildProcessHandleCheckBox.UseVisualStyleBackColor = true;
//
@@ -748,9 +728,9 @@ namespace Netch.Forms
this.OtherTabPage.Controls.Add(this.StopWhenExitedCheckBox);
this.OtherTabPage.Controls.Add(this.StartWhenOpenedCheckBox);
this.OtherTabPage.Controls.Add(this.MinimizeWhenStartedCheckBox);
this.OtherTabPage.Controls.Add(this.NoSupportDialogCheckBox);
this.OtherTabPage.Controls.Add(this.RunAtStartupCheckBox);
this.OtherTabPage.Controls.Add(this.CheckUpdateWhenOpenedCheckBox);
this.OtherTabPage.Controls.Add(this.NoSupportDialogCheckBox);
this.OtherTabPage.Controls.Add(this.CheckBetaUpdateCheckBox);
this.OtherTabPage.Controls.Add(this.UpdateServersWhenOpenedCheckBox);
this.OtherTabPage.Location = new System.Drawing.Point(4, 29);
@@ -803,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 = 4;
this.NoSupportDialogCheckBox.Text = "Disable Support Warning";
this.NoSupportDialogCheckBox.UseVisualStyleBackColor = true;
//
// RunAtStartupCheckBox
//
this.RunAtStartupCheckBox.AutoSize = true;
@@ -834,13 +804,23 @@ 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;
this.CheckBetaUpdateCheckBox.Location = new System.Drawing.Point(200, 72);
this.CheckBetaUpdateCheckBox.Name = "CheckBetaUpdateCheckBox";
this.CheckBetaUpdateCheckBox.Size = new System.Drawing.Size(137, 21);
this.CheckBetaUpdateCheckBox.TabIndex = 6;
this.CheckBetaUpdateCheckBox.TabIndex = 7;
this.CheckBetaUpdateCheckBox.Text = "Check Beta update";
this.CheckBetaUpdateCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CheckBetaUpdateCheckBox.UseVisualStyleBackColor = true;
@@ -851,7 +831,7 @@ namespace Netch.Forms
this.UpdateServersWhenOpenedCheckBox.Location = new System.Drawing.Point(200, 94);
this.UpdateServersWhenOpenedCheckBox.Name = "UpdateServersWhenOpenedCheckBox";
this.UpdateServersWhenOpenedCheckBox.Size = new System.Drawing.Size(200, 21);
this.UpdateServersWhenOpenedCheckBox.TabIndex = 7;
this.UpdateServersWhenOpenedCheckBox.TabIndex = 8;
this.UpdateServersWhenOpenedCheckBox.Text = "Update Servers when opened";
this.UpdateServersWhenOpenedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.UpdateServersWhenOpenedCheckBox.UseVisualStyleBackColor = true;
@@ -947,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);
@@ -996,8 +985,6 @@ namespace Netch.Forms
private System.Windows.Forms.TabPage v2rayTabPage;
private System.Windows.Forms.GroupBox PortGroupBox;
private System.Windows.Forms.CheckBox AllowDevicesCheckBox;
private System.Windows.Forms.Label HTTPPortLabel;
private System.Windows.Forms.TextBox HTTPPortTextBox;
private System.Windows.Forms.Label Socks5PortLabel;
private System.Windows.Forms.TextBox Socks5PortTextBox;
private System.Windows.Forms.GroupBox WinTUNGroupBox;
@@ -1067,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;
}
}

View File

@@ -26,15 +26,7 @@ namespace Netch.Forms
#region General
BindTextBox<ushort>(Socks5PortTextBox,
p => p.ToString() != HTTPPortTextBox.Text,
p => Global.Settings.Socks5LocalPort = p,
Global.Settings.Socks5LocalPort);
BindTextBox<ushort>(HTTPPortTextBox,
p => p.ToString() != Socks5PortTextBox.Text,
p => Global.Settings.HTTPLocalPort = p,
Global.Settings.HTTPLocalPort);
BindTextBox<ushort>(Socks5PortTextBox, p => true, p => Global.Settings.Socks5LocalPort = p, Global.Settings.Socks5LocalPort);
BindCheckBox(AllowDevicesCheckBox,
c => Global.Settings.LocalAddress = AllowDevicesCheckBox.Checked ? "0.0.0.0" : "127.0.0.1",
@@ -102,14 +94,14 @@ namespace Netch.Forms
Enum.GetNames(typeof(PortType)),
Global.Settings.Redirector.FilterProtocol.ToString());
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(FilterICMPCheckBox, b => Global.Settings.Redirector.FilterICMP = b, Global.Settings.Redirector.FilterICMP);
BindTextBox(ICMPDelayTextBox, s => int.TryParse(s, out _), s => { }, Global.Settings.Redirector.ICMPDelay);
BindCheckBox(ChildProcessHandleCheckBox,
s => Global.Settings.Redirector.ChildProcessHandle = s,
Global.Settings.Redirector.ChildProcessHandle);

View File

@@ -1,6 +1,6 @@
namespace Netch.Forms
{
partial class SubscribeForm
partial class SubscriptionForm
{
/// <summary>
/// Required designer variable.
@@ -29,24 +29,23 @@
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SubscribeForm));
this.AddSubscriptionBox = new System.Windows.Forms.GroupBox();
this.RemarkLabel = new System.Windows.Forms.Label();
this.RemarkTextBox = new System.Windows.Forms.TextBox();
this.LinkLabel = new System.Windows.Forms.Label();
this.LinkTextBox = new System.Windows.Forms.TextBox();
this.UserAgentLabel = new System.Windows.Forms.Label();
this.UserAgentTextBox = new System.Windows.Forms.TextBox();
this.UnselectButton = new System.Windows.Forms.Button();
this.AddButton = new System.Windows.Forms.Button();
this.UserAgentLabel = new System.Windows.Forms.Label();
this.LinkTextBox = new System.Windows.Forms.TextBox();
this.LinkLabel = new System.Windows.Forms.Label();
this.RemarkTextBox = new System.Windows.Forms.TextBox();
this.RemarkLabel = new System.Windows.Forms.Label();
this.SubscribeLinkListView = new System.Windows.Forms.ListView();
this.SubscriptionLinkListView = new System.Windows.Forms.ListView();
this.EnableColumnHeader = new System.Windows.Forms.ColumnHeader();
this.RemarkColumnHeader = new System.Windows.Forms.ColumnHeader();
this.LinkColumnHeader = new System.Windows.Forms.ColumnHeader();
this.UserAgentHeader = new System.Windows.Forms.ColumnHeader();
this.pContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.DeleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.deleteServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.DeleteServersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.CopyLinkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.MainTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
this.AddSubscriptionBox.SuspendLayout();
@@ -56,14 +55,14 @@
//
// AddSubscriptionBox
//
this.AddSubscriptionBox.Controls.Add(this.RemarkLabel);
this.AddSubscriptionBox.Controls.Add(this.RemarkTextBox);
this.AddSubscriptionBox.Controls.Add(this.LinkLabel);
this.AddSubscriptionBox.Controls.Add(this.LinkTextBox);
this.AddSubscriptionBox.Controls.Add(this.UserAgentLabel);
this.AddSubscriptionBox.Controls.Add(this.UserAgentTextBox);
this.AddSubscriptionBox.Controls.Add(this.UnselectButton);
this.AddSubscriptionBox.Controls.Add(this.AddButton);
this.AddSubscriptionBox.Controls.Add(this.UserAgentLabel);
this.AddSubscriptionBox.Controls.Add(this.LinkTextBox);
this.AddSubscriptionBox.Controls.Add(this.LinkLabel);
this.AddSubscriptionBox.Controls.Add(this.RemarkTextBox);
this.AddSubscriptionBox.Controls.Add(this.RemarkLabel);
this.AddSubscriptionBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.AddSubscriptionBox.Location = new System.Drawing.Point(8, 248);
this.AddSubscriptionBox.Name = "AddSubscriptionBox";
@@ -71,6 +70,47 @@
this.AddSubscriptionBox.TabIndex = 1;
this.AddSubscriptionBox.TabStop = false;
//
// RemarkLabel
//
this.RemarkLabel.AutoSize = true;
this.RemarkLabel.Location = new System.Drawing.Point(11, 19);
this.RemarkLabel.Name = "RemarkLabel";
this.RemarkLabel.Size = new System.Drawing.Size(53, 17);
this.RemarkLabel.TabIndex = 1;
this.RemarkLabel.Text = "Remark";
//
// RemarkTextBox
//
this.RemarkTextBox.Location = new System.Drawing.Point(109, 16);
this.RemarkTextBox.Name = "RemarkTextBox";
this.RemarkTextBox.Size = new System.Drawing.Size(545, 23);
this.RemarkTextBox.TabIndex = 2;
//
// LinkLabel
//
this.LinkLabel.AutoSize = true;
this.LinkLabel.Location = new System.Drawing.Point(11, 48);
this.LinkLabel.Name = "LinkLabel";
this.LinkLabel.Size = new System.Drawing.Size(31, 17);
this.LinkLabel.TabIndex = 3;
this.LinkLabel.Text = "Link";
//
// LinkTextBox
//
this.LinkTextBox.Location = new System.Drawing.Point(109, 45);
this.LinkTextBox.Name = "LinkTextBox";
this.LinkTextBox.Size = new System.Drawing.Size(545, 23);
this.LinkTextBox.TabIndex = 4;
//
// UserAgentLabel
//
this.UserAgentLabel.AutoSize = true;
this.UserAgentLabel.Location = new System.Drawing.Point(11, 77);
this.UserAgentLabel.Name = "UserAgentLabel";
this.UserAgentLabel.Size = new System.Drawing.Size(74, 17);
this.UserAgentLabel.TabIndex = 5;
this.UserAgentLabel.Text = "User-Agent";
//
// UserAgentTextBox
//
this.UserAgentTextBox.Location = new System.Drawing.Point(109, 74);
@@ -98,68 +138,28 @@
this.AddButton.UseVisualStyleBackColor = true;
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
//
// UserAgentLabel
// SubscriptionLinkListView
//
this.UserAgentLabel.AutoSize = true;
this.UserAgentLabel.Location = new System.Drawing.Point(11, 77);
this.UserAgentLabel.Name = "UserAgentLabel";
this.UserAgentLabel.Size = new System.Drawing.Size(74, 17);
this.UserAgentLabel.TabIndex = 5;
this.UserAgentLabel.Text = "User-Agent";
//
// LinkTextBox
//
this.LinkTextBox.Location = new System.Drawing.Point(109, 45);
this.LinkTextBox.Name = "LinkTextBox";
this.LinkTextBox.Size = new System.Drawing.Size(545, 23);
this.LinkTextBox.TabIndex = 4;
//
// LinkLabel
//
this.LinkLabel.AutoSize = true;
this.LinkLabel.Location = new System.Drawing.Point(11, 48);
this.LinkLabel.Name = "LinkLabel";
this.LinkLabel.Size = new System.Drawing.Size(31, 17);
this.LinkLabel.TabIndex = 3;
this.LinkLabel.Text = "Link";
//
// RemarkTextBox
//
this.RemarkTextBox.Location = new System.Drawing.Point(109, 16);
this.RemarkTextBox.Name = "RemarkTextBox";
this.RemarkTextBox.Size = new System.Drawing.Size(545, 23);
this.RemarkTextBox.TabIndex = 2;
//
// RemarkLabel
//
this.RemarkLabel.AutoSize = true;
this.RemarkLabel.Location = new System.Drawing.Point(11, 19);
this.RemarkLabel.Name = "RemarkLabel";
this.RemarkLabel.Size = new System.Drawing.Size(53, 17);
this.RemarkLabel.TabIndex = 1;
this.RemarkLabel.Text = "Remark";
//
// SubscribeLinkListView
//
this.SubscribeLinkListView.AllowColumnReorder = true;
this.SubscribeLinkListView.CheckBoxes = true;
this.SubscribeLinkListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[]
{
this.EnableColumnHeader, this.RemarkColumnHeader, this.LinkColumnHeader, this.UserAgentHeader
});
this.SubscribeLinkListView.Dock = System.Windows.Forms.DockStyle.Fill;
this.SubscribeLinkListView.FullRowSelect = true;
this.SubscribeLinkListView.HideSelection = false;
this.SubscribeLinkListView.Location = new System.Drawing.Point(8, 8);
this.SubscribeLinkListView.MultiSelect = false;
this.SubscribeLinkListView.Name = "SubscribeLinkListView";
this.SubscribeLinkListView.Size = new System.Drawing.Size(668, 234);
this.SubscribeLinkListView.TabIndex = 0;
this.SubscribeLinkListView.UseCompatibleStateImageBehavior = false;
this.SubscribeLinkListView.View = System.Windows.Forms.View.Details;
this.SubscribeLinkListView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.SubscribeLinkListView_ItemChecked);
this.SubscribeLinkListView.SelectedIndexChanged += new System.EventHandler(this.SubscribeLinkListView_SelectedIndexChanged);
this.SubscribeLinkListView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.SubscribeLinkListView_MouseUp);
this.SubscriptionLinkListView.AllowColumnReorder = true;
this.SubscriptionLinkListView.CheckBoxes = true;
this.SubscriptionLinkListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.EnableColumnHeader,
this.RemarkColumnHeader,
this.LinkColumnHeader,
this.UserAgentHeader});
this.SubscriptionLinkListView.Dock = System.Windows.Forms.DockStyle.Fill;
this.SubscriptionLinkListView.FullRowSelect = true;
this.SubscriptionLinkListView.HideSelection = false;
this.SubscriptionLinkListView.Location = new System.Drawing.Point(8, 8);
this.SubscriptionLinkListView.MultiSelect = false;
this.SubscriptionLinkListView.Name = "SubscriptionLinkListView";
this.SubscriptionLinkListView.Size = new System.Drawing.Size(668, 234);
this.SubscriptionLinkListView.TabIndex = 0;
this.SubscriptionLinkListView.UseCompatibleStateImageBehavior = false;
this.SubscriptionLinkListView.View = System.Windows.Forms.View.Details;
this.SubscriptionLinkListView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.SubscriptionLinkListView_ItemChecked);
this.SubscriptionLinkListView.SelectedIndexChanged += new System.EventHandler(this.SubscriptionLinkListView_SelectedIndexChanged);
this.SubscriptionLinkListView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.SubscriptionLinkListView_MouseUp);
//
// EnableColumnHeader
//
@@ -182,39 +182,39 @@
//
// pContextMenuStrip
//
this.pContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[]
{
this.DeleteToolStripMenuItem, this.deleteServerToolStripMenuItem, this.CopyLinkToolStripMenuItem
});
this.pContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.DeleteToolStripMenuItem,
this.DeleteServersToolStripMenuItem,
this.CopyLinkToolStripMenuItem});
this.pContextMenuStrip.Name = "pContextMenuStrip";
this.pContextMenuStrip.Size = new System.Drawing.Size(151, 70);
this.pContextMenuStrip.Size = new System.Drawing.Size(161, 70);
//
// DeleteToolStripMenuItem
//
this.DeleteToolStripMenuItem.Name = "DeleteToolStripMenuItem";
this.DeleteToolStripMenuItem.Size = new System.Drawing.Size(150, 22);
this.DeleteToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
this.DeleteToolStripMenuItem.Text = "Delete";
this.DeleteToolStripMenuItem.Click += new System.EventHandler(this.DeleteToolStripMenuItem_Click);
//
// deleteServerToolStripMenuItem
// DeleteServersToolStripMenuItem
//
this.deleteServerToolStripMenuItem.Name = "deleteServerToolStripMenuItem";
this.deleteServerToolStripMenuItem.Size = new System.Drawing.Size(150, 22);
this.deleteServerToolStripMenuItem.Text = "DeleteServer";
this.deleteServerToolStripMenuItem.Click += new System.EventHandler(this.deleteServerToolStripMenuItem_Click);
this.DeleteServersToolStripMenuItem.Name = "DeleteServersToolStripMenuItem";
this.DeleteServersToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
this.DeleteServersToolStripMenuItem.Text = "Delete Servers";
this.DeleteServersToolStripMenuItem.Click += new System.EventHandler(this.DeleteServersToolStripMenuItem_Click);
//
// CopyLinkToolStripMenuItem
//
this.CopyLinkToolStripMenuItem.Name = "CopyLinkToolStripMenuItem";
this.CopyLinkToolStripMenuItem.Size = new System.Drawing.Size(150, 22);
this.CopyLinkToolStripMenuItem.Text = "CopyLink";
this.CopyLinkToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
this.CopyLinkToolStripMenuItem.Text = "Copy link";
this.CopyLinkToolStripMenuItem.Click += new System.EventHandler(this.CopyLinkToolStripMenuItem_Click);
//
// MainTableLayoutPanel
//
this.MainTableLayoutPanel.ColumnCount = 1;
this.MainTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.MainTableLayoutPanel.Controls.Add(this.SubscribeLinkListView, 0, 0);
this.MainTableLayoutPanel.Controls.Add(this.SubscriptionLinkListView, 0, 0);
this.MainTableLayoutPanel.Controls.Add(this.AddSubscriptionBox, 0, 1);
this.MainTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.MainTableLayoutPanel.Location = new System.Drawing.Point(0, 0);
@@ -227,25 +227,26 @@
this.MainTableLayoutPanel.Size = new System.Drawing.Size(684, 391);
this.MainTableLayoutPanel.TabIndex = 11;
//
// SubscribeForm
// SubscriptionForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(684, 391);
this.Controls.Add(this.MainTableLayoutPanel);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (134)));
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.MaximizeBox = false;
this.Name = "SubscribeForm";
this.Name = "SubscriptionForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Subscribe";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SubscribeForm_FormClosing);
this.Text = "Subscription";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SubscriptionForm_FormClosing);
this.AddSubscriptionBox.ResumeLayout(false);
this.AddSubscriptionBox.PerformLayout();
this.pContextMenuStrip.ResumeLayout(false);
this.MainTableLayoutPanel.ResumeLayout(false);
this.ResumeLayout(false);
}
private System.Windows.Forms.ColumnHeader EnableColumnHeader;
@@ -257,7 +258,7 @@
private System.Windows.Forms.Label LinkLabel;
private System.Windows.Forms.TextBox RemarkTextBox;
private System.Windows.Forms.Button AddButton;
private System.Windows.Forms.ListView SubscribeLinkListView;
private System.Windows.Forms.ListView SubscriptionLinkListView;
private System.Windows.Forms.ColumnHeader RemarkColumnHeader;
private System.Windows.Forms.ColumnHeader LinkColumnHeader;
private System.Windows.Forms.ContextMenuStrip pContextMenuStrip;
@@ -269,6 +270,6 @@
#endregion
private System.Windows.Forms.ToolStripMenuItem deleteServerToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem DeleteServersToolStripMenuItem;
}
}

View File

@@ -1,15 +1,15 @@
using Netch.Models;
using Netch.Properties;
using Netch.Utils;
using System;
using System;
using System.Linq;
using System.Windows.Forms;
using Netch.Models;
using Netch.Properties;
using Netch.Utils;
namespace Netch.Forms
{
public partial class SubscribeForm : Form
public partial class SubscriptionForm : Form
{
public SubscribeForm()
public SubscriptionForm()
{
InitializeComponent();
Icon = Resources.icon;
@@ -17,33 +17,33 @@ namespace Netch.Forms
i18N.TranslateForm(this);
i18N.TranslateForm(pContextMenuStrip);
InitSubscribeLink();
LoadSubscriptionLinks();
}
private int SelectedIndex
{
get
{
if (SubscribeLinkListView.MultiSelect)
if (SubscriptionLinkListView.MultiSelect)
throw new Exception();
return SubscribeLinkListView.SelectedIndices.Count == 0 ? -1 : SubscribeLinkListView.SelectedIndices[0];
return SubscriptionLinkListView.SelectedIndices.Count == 0 ? -1 : SubscriptionLinkListView.SelectedIndices[0];
}
}
#region EventHandler
private void SubscribeLinkListView_MouseUp(object sender, MouseEventArgs e)
private void SubscriptionLinkListView_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
if (SelectedIndex != -1)
pContextMenuStrip.Show(SubscribeLinkListView, e.Location);
pContextMenuStrip.Show(SubscriptionLinkListView, e.Location);
}
/// <summary>
/// 选中/取消选中
/// </summary>
private void SubscribeLinkListView_SelectedIndexChanged(object sender, EventArgs e)
private void SubscriptionLinkListView_SelectedIndexChanged(object sender, EventArgs e)
{
SetEditingGroup(SelectedIndex);
}
@@ -51,13 +51,13 @@ namespace Netch.Forms
/// <summary>
/// 订阅启/禁用
/// </summary>
private void SubscribeLinkListView_ItemChecked(object sender, ItemCheckedEventArgs e)
private void SubscriptionLinkListView_ItemChecked(object sender, ItemCheckedEventArgs e)
{
var index = e.Item.Index;
Global.Settings.SubscribeLink[index].Enable = SubscribeLinkListView.Items[index].Checked;
Global.Settings.Subscription[index].Enable = SubscriptionLinkListView.Items[index].Checked;
}
private async void SubscribeForm_FormClosing(object sender, FormClosingEventArgs e)
private async void SubscriptionForm_FormClosing(object sender, FormClosingEventArgs e)
{
await Configuration.SaveAsync();
}
@@ -94,13 +94,13 @@ namespace Netch.Forms
if (SelectedIndex == -1)
{
if (Global.Settings.SubscribeLink.Any(link => link.Remark.Equals(RemarkTextBox.Text)))
if (Global.Settings.Subscription.Any(link => link.Remark.Equals(RemarkTextBox.Text)))
{
MessageBoxX.Show("Remark Name Duplicate!");
MessageBoxX.Show(i18N.Translate("Subscription with the specified remark already exists"));
return;
}
Global.Settings.SubscribeLink.Add(new SubscribeLink
Global.Settings.Subscription.Add(new Subscription
{
Enable = true,
Remark = RemarkTextBox.Text,
@@ -110,7 +110,7 @@ namespace Netch.Forms
}
else
{
var subscribeLink = Global.Settings.SubscribeLink[SelectedIndex];
var subscribeLink = Global.Settings.Subscription[SelectedIndex];
RenameServers(subscribeLink.Remark, RemarkTextBox.Text);
subscribeLink.Link = LinkTextBox.Text;
@@ -118,7 +118,7 @@ namespace Netch.Forms
subscribeLink.UserAgent = UserAgentTextBox.Text;
}
InitSubscribeLink();
LoadSubscriptionLinks();
}
#endregion
@@ -131,24 +131,24 @@ namespace Netch.Forms
confirm: true) != DialogResult.OK)
return;
var subscribeLink = Global.Settings.SubscribeLink[SelectedIndex];
var subscribeLink = Global.Settings.Subscription[SelectedIndex];
DeleteServers(subscribeLink.Remark);
Global.Settings.SubscribeLink.Remove(subscribeLink);
Global.Settings.Subscription.Remove(subscribeLink);
InitSubscribeLink();
LoadSubscriptionLinks();
}
private void deleteServerToolStripMenuItem_Click(object sender, EventArgs e)
private void DeleteServersToolStripMenuItem_Click(object sender, EventArgs e)
{
if (MessageBoxX.Show(i18N.Translate("Confirm deletion?"), confirm: true) != DialogResult.OK)
return;
DeleteServers(Global.Settings.SubscribeLink[SelectedIndex].Remark);
DeleteServers(Global.Settings.Subscription[SelectedIndex].Remark);
}
private void CopyLinkToolStripMenuItem_Click(object sender, EventArgs e)
{
Clipboard.SetText(Global.Settings.SubscribeLink[SelectedIndex].Link);
Clipboard.SetText(Global.Settings.Subscription[SelectedIndex].Link);
}
#endregion
@@ -166,12 +166,12 @@ namespace Netch.Forms
server.Group = newGroup;
}
private void InitSubscribeLink()
private void LoadSubscriptionLinks()
{
SubscribeLinkListView.Items.Clear();
SubscriptionLinkListView.Items.Clear();
foreach (var item in Global.Settings.SubscribeLink)
SubscribeLinkListView.Items.Add(new ListViewItem(new[]
foreach (var item in Global.Settings.Subscription)
SubscriptionLinkListView.Items.Add(new ListViewItem(new[]
{
"",
item.Remark,
@@ -202,7 +202,7 @@ namespace Netch.Forms
return;
}
var item = Global.Settings.SubscribeLink[index];
var item = Global.Settings.Subscription[index];
AddSubscriptionBox.Text = item.Remark;
RemarkTextBox.Text = item.Remark;
LinkTextBox.Text = item.Link;

View File

@@ -0,0 +1,63 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="pContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Windows.Forms;
using Netch.Forms;
using Netch.Models;
@@ -42,7 +43,7 @@ namespace Netch
public static JsonSerializerOptions NewCustomJsonSerializerOptions() => new()
{
WriteIndented = true,
IgnoreNullValues = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
};
}

View File

@@ -8,38 +8,27 @@ namespace Netch.Interops
{
public enum NameList
{
TYPE_FILTERLOOPBACK,
TYPE_FILTERICMP,
TYPE_FILTERTCP,
TYPE_FILTERUDP,
AIO_FILTERLOOPBACK,
AIO_FILTERINTRANET, // LAN
AIO_FILTERPARENT,
AIO_FILTERICMP,
AIO_FILTERTCP,
AIO_FILTERUDP,
AIO_FILTERDNS,
TYPE_CLRNAME,
TYPE_ADDNAME,
TYPE_BYPNAME,
AIO_ICMPING,
TYPE_DNSHOST,
AIO_DNSHOST,
AIO_DNSPORT,
TYPE_TCPLISN,
TYPE_TCPTYPE,
TYPE_TCPHOST,
TYPE_TCPUSER,
TYPE_TCPPASS,
TYPE_TCPMETH,
TYPE_TCPPROT,
TYPE_TCPPRPA,
TYPE_TCPOBFS,
TYPE_TCPOBPA,
AIO_TGTHOST,
AIO_TGTPORT,
AIO_TGTUSER,
AIO_TGTPASS,
TYPE_UDPLISN,
TYPE_UDPTYPE,
TYPE_UDPHOST,
TYPE_UDPUSER,
TYPE_UDPPASS,
TYPE_UDPMETH,
TYPE_UDPPROT,
TYPE_UDPPRPA,
TYPE_UDPOBFS,
TYPE_UDPOBPA
AIO_CLRNAME,
AIO_ADDNAME,
AIO_BYPNAME
}
public static bool Dial(NameList name, string value)
@@ -58,8 +47,6 @@ namespace Netch.Interops
return await Task.Run(aio_free).ConfigureAwait(false);
}
public const int UdpNameListOffset = (int)NameList.TYPE_UDPLISN - (int)NameList.TYPE_TCPLISN;
private const string Redirector_bin = "Redirector.bin";
[DllImport(Redirector_bin, CallingConvention = CallingConvention.Cdecl)]
@@ -71,10 +58,12 @@ namespace Netch.Interops
[DllImport(Redirector_bin, CallingConvention = CallingConvention.Cdecl)]
private static extern bool aio_free();
/*
[DllImport(Redirector_bin, CallingConvention = CallingConvention.Cdecl)]
private static extern ulong aio_getUP();
[DllImport(Redirector_bin, CallingConvention = CallingConvention.Cdecl)]
private static extern ulong aio_getDL();
*/
}
}

View File

@@ -1,9 +1,10 @@
using Netch.Models;
using System;
using System;
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>
{
@@ -13,7 +14,7 @@ namespace Netch.Utils
{
var jsonElement = JsonSerializer.Deserialize<JsonElement>(ref reader);
var type = ServerHelper.GetTypeByTypeName(jsonElement.GetProperty("Type").GetString()!);
return (Server)JsonSerializer.Deserialize(jsonElement.GetRawText(), type)!;
return (Server)jsonElement.Deserialize(type)!;
}
public override void Write(Utf8JsonWriter writer, Server value, JsonSerializerOptions options)

View File

@@ -1,5 +1,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Netch.Utils;
namespace Netch.Models
@@ -101,15 +103,13 @@ namespace Netch.Models
/// </summary>
public string DNSHijackHost { get; set; } = "1.1.1.1:53";
[JsonIgnore]
public int ICMPDelay { get; } = 0;
public int ICMPDelay { get; set; } = 0;
public bool FilterICMP { get; set; } = false;
/// <summary>
/// 是否代理子进程
/// </summary>
[JsonIgnore]
public bool ChildProcessHandle { get; set; } = false;
}
@@ -240,7 +240,7 @@ namespace Netch.Models
/// <summary>
/// 订阅链接列表
/// </summary>
public List<SubscribeLink> SubscribeLink { get; set; } = new();
public List<Subscription> Subscription { get; set; } = new();
/// <summary>
/// TUNTAP 适配器配置
@@ -256,7 +256,21 @@ namespace Netch.Models
public bool NoSupportDialog { get; set; } = false;
public Setting Clone()
#region Migration
[Obsolete]
public JsonElement SubscribeLink
{
set
{
if (Subscription == null! || !Subscription.Any())
Subscription = value.Deserialize<List<Subscription>>()!;
}
}
#endregion
public Setting ShallowCopy()
{
return (Setting)MemberwiseClone();
}

View File

@@ -1,6 +1,6 @@
namespace Netch.Models
{
public class SubscribeLink
public class Subscription
{
/// <summary>
/// 启用状态

View File

@@ -45,6 +45,13 @@ namespace Netch
var binPath = Path.Combine(Global.NetchDir, "bin");
Environment.SetEnvironmentVariable("PATH", $"{Environment.GetEnvironmentVariable("PATH")};{binPath}");
if (!Directory.Exists("bin") || !Directory.EnumerateFileSystemEntries("bin").Any())
{
i18N.Load("System");
MessageBoxX.Show(i18N.Translate("Please extract all files then run the program!"));
Environment.Exit(2);
}
Updater.CleanOld(Global.NetchDir);
// 预创建目录
@@ -86,12 +93,6 @@ namespace Netch
// 加载语言
i18N.Load(Global.Settings.Language);
if (!Directory.Exists("bin") || !Directory.EnumerateFileSystemEntries("bin").Any())
{
MessageBoxX.Show(i18N.Translate("Please extract all files then run the program!"));
Environment.Exit(2);
}
Task.Run(LogEnvironment).Forget();
CheckClr();
CheckOS();
@@ -113,8 +114,13 @@ namespace Netch
Log.Information("OS: {OSVersion}", Environment.OSVersion);
Log.Information("SHA256: {Hash}", $"{Utils.Utils.SHA256CheckSum(Global.NetchExecutable)}");
Log.Information("System Language: {Language}", CultureInfo.CurrentCulture.Name);
if (Log.IsEnabled(LogEventLevel.Debug))
Log.Debug("Third-party Drivers:\n{Drivers}", string.Join("\n", SystemInfo.SystemDrivers(false)));
{
// TODO log level setting
Task.Run(() => Log.Debug("Third-party Drivers:\n{Drivers}", string.Join(Constants.EOF, SystemInfo.SystemDrivers(false)))).Forget();
Task.Run(() => Log.Debug("Running Processes: \n{Processes}", string.Join(Constants.EOF, SystemInfo.Processes(false)))).Forget();
}
}
private static void CheckClr()
@@ -132,8 +138,11 @@ namespace Netch
{
Log.Information("CLR: {Version}", Environment.Version);
Flags.NoSupport = true;
if(!Global.Settings.NoSupportDialog)
MessageBoxX.Show(i18N.TranslateFormat("{0} won't get developers' support, Please do not report any issues or seek help from developers.", "CLR " + Environment.Version), LogLevel.WARNING);
if (!Global.Settings.NoSupportDialog)
MessageBoxX.Show(
i18N.TranslateFormat("{0} won't get developers' support, Please do not report any issues or seek help from developers.",
"CLR " + Environment.Version),
LogLevel.WARNING);
}
}
@@ -142,8 +151,11 @@ namespace Netch
if (Environment.OSVersion.Version.Build < 17763)
{
Flags.NoSupport = true;
if(!Global.Settings.NoSupportDialog)
MessageBoxX.Show(i18N.TranslateFormat("{0} won't get developers' support, Please do not report any issues or seek help from developers.", Environment.OSVersion), LogLevel.WARNING);
if (!Global.Settings.NoSupportDialog)
MessageBoxX.Show(
i18N.TranslateFormat("{0} won't get developers' support, Please do not report any issues or seek help from developers.",
Environment.OSVersion),
LogLevel.WARNING);
}
}
@@ -162,13 +174,13 @@ namespace Netch
Log.Logger = new LoggerConfiguration()
#if DEBUG
.MinimumLevel.Verbose()
.WriteTo.Async(c => c.Debug(outputTemplate: Constants.OutputTemplate))
#else
.MinimumLevel.Debug()
#endif
.WriteTo.Async(c => c.File(Path.Combine(Global.NetchDir, Constants.LogFile),
outputTemplate: Constants.OutputTemplate,
rollOnFileSizeLimit: false))
.WriteTo.Console(outputTemplate: Constants.OutputTemplate)
.MinimumLevel.Override(@"Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.CreateLogger();
@@ -176,7 +188,7 @@ namespace Netch
private static void Application_OnException(object sender, ThreadExceptionEventArgs e)
{
Log.Error(e.Exception, "未处理异常");
Log.Error(e.Exception, "Unhandled error");
}
private static void Application_OnExit(object? sender, EventArgs eventArgs)

View File

@@ -32,7 +32,7 @@
<ItemGroup>
<PackageReference Include="HMBSbige.SingleInstance" Version="5.0.7" />
<PackageReference Include="MaxMind.GeoIP2" Version="4.0.1" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.71" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.72" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="16.10.56" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.1.506-beta">
<PrivateAssets>all</PrivateAssets>
@@ -45,11 +45,12 @@
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="4.1.2" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0" />
<PackageReference Include="Stun.Net" Version="5.0.0" />
<PackageReference Include="System.Management" Version="5.0.0" />
<PackageReference Include="System.Reactive" Version="5.0.0" />
<PackageReference Include="System.Text.Json" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="TaskScheduler" Version="2.9.1" />
<PackageReference Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.4" />
<PackageReference Include="WindowsFirewallHelper" Version="2.1.4.81" />
@@ -69,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\**" />

View File

@@ -18,9 +18,9 @@
"Testing NAT Type": "正在测试 NAT 类型",
"Setup Route Table Rule": "配置路由规则",
"Test failed": "测试失败",
"Starting update subscription": "正在更新订阅",
"Subscription updated": "订阅更新完毕",
"Register driver": "正在注册驱动",
"Updating servers": "正在更新服务器",
"Servers updated": "服务器更新完毕",
"Installing netfilter2 driver": "正在安装 netfilter2 驱动",
"Server": "服务器",
"Import Servers From Clipboard": "从剪贴板导入服务器",
@@ -28,10 +28,10 @@
"Netch is now minimized to the notification bar, double click this icon to restore.": "Netch 已最小化至通知栏,双击此图标恢复窗口",
"New version available": "发现新版本",
"Already latest version": "已经是最新版本",
"New version found failed": "寻找新版本失败",
"Check for update failed": "检查更新失败",
"Mode": "模式",
"Help": "帮助",
"Check for updates": "检查更新",
"Check for update": "检查更新",
"Download and install now?": "立即下载并安装?",
"Start downloading new version": "开始下载新版本",
"Download update failed": "下载更新错误",
@@ -64,16 +64,16 @@
"Plugin": "插件",
"Plugin Options": "插件参数",
"Subscribe": "订阅",
"Manage Subscribe Links": "管理订阅链接",
"Update Servers From Subscribe Links": "从订阅链接更新服务器",
"Subscription": "订阅",
"Manage Subscriptions": "管理订阅",
"Update Servers": "更新服务器",
"No subscription link": "没有任何一条订阅链接",
"Updating {0}": "正在更新 {0}",
"Update {1} server(s) from {0}": "从 {0} 更新 {1} 个服务器",
"Update servers error from {0}": "从 {0} 更新服务器失败",
"Update {1} server(s) from {0}": "从 {0} 更新 {1} 个服务器",
"Update servers failed from {0}": "从 {0} 更新服务器失败",
"Confirm deletion?": "确认删除?",
"DeleteServer": "删除订阅节点",
"CopyLink": "复制链接",
"Delete Servers": "删除订阅节点",
"Copy link": "复制链接",
"Status": "状态",
"Link": "链接",
"Unselect": "取消选择",
@@ -115,6 +115,9 @@
"Scan": "扫描",
"Save": "保存",
"Modify": "修改",
"Select": "选择",
"Validation": "验证",
"Action": "动作",
"Select a folder": "选择一个目录",
"Please enter an process name (xxx.exe)": "请输入一个进程名xxx.exe",
"Rule does not conform to C++ regular expression syntax": "规则不符合 C++ 正则表达式语法",
@@ -125,6 +128,7 @@
"Please enter a mode remark": "请输入模式的备注",
"File already exists.\n Please Change the filename": "文件名已存在,请修改文件名",
"Please enter a mode filename": "请输入模式的文件名",
"Above rules does not conform to C++ regular expression syntax": "以上规则不符合 C++ 正则表达式语法",
"Proxy Rule IPs": "代理规则 IP",
"Bypass Rule IPs": "绕过规则 IP",
@@ -133,6 +137,7 @@
"Delete or not ? Will clean up the corresponding group of items in the server list": "是否删除?将会清理服务器列表中对应组的项目",
"Remark can not be empty": "备注不可为空",
"Link can not be empty": "链接不可为空",
"Subscription with the specified remark already exists": "带有指定备注的订阅已存在",
"Link must start with http:// or https://": "链接必须以 http:// 或 https:// 开头",
"Settings": "设置",
@@ -173,8 +178,7 @@
"The {0} port is in use.": "{0} 端口已被占用",
"The {0} port is reserved by system.": "{0} 端口是系统保留端口",
"\"Core.bin\" is missing. Please check your Antivirus software": "找不到 \"Core.bin\" 文件!请检查你的杀毒软件。",
"{0} won't get developers' support, Please do not report any issues or seek help from developers.": "{0} 将不会得到开发者的支持,请不要报告任何问题或寻求开发人员的帮助。",
"No Support": "不受支持"
}

View File

@@ -64,7 +64,7 @@ namespace Netch.Servers
var server = (ShadowsocksServer)s;
if (!SSGlobal.EncryptMethods.Contains(server.EncryptMethod))
{
Log.Warning("不支持的 SS 加密方式:{Method}", server.EncryptMethod);
Log.Warning("Unsupported SS Encrypt Method: {Method}", server.EncryptMethod);
return false;
}

View File

@@ -145,19 +145,19 @@ namespace Netch.Servers
var server = (ShadowsocksRServer)s;
if (!SSRGlobal.EncryptMethods.Contains(server.EncryptMethod))
{
Log.Error("不支持的 SSR 加密方式:{Method}", server.EncryptMethod);
Log.Error("Unsupported ShadowsocksR Encrypt method: {Method}", server.EncryptMethod);
return false;
}
if (!SSRGlobal.Protocols.Contains(server.Protocol))
{
Log.Error("不支持的 SSR 协议:{Protocol}", server.Protocol);
Log.Error("Unsupported ShadowsocksR Protocol: {Protocol}", server.Protocol);
return false;
}
if (!SSRGlobal.OBFSs.Contains(server.OBFS))
{
Log.Error("不支持的 SSR 混淆:{Obfs}", server.OBFS);
Log.Error("Unsupported ShadowsocksR Obfs: {Obfs}", server.OBFS);
return false;
}

View File

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

View File

@@ -78,7 +78,7 @@ namespace Netch.Utils
var pidHastSet = processes.Select(instance => instance.Id).ToHashSet();
Log.Information("流量统计进程: {Processes}", string.Join(',', processes.Select(v => $"({v.Id}){v.ProcessName}")));
Log.Information("Net traffic processes: {Processes}", string.Join(',', processes.Select(v => $"({v.Id}){v.ProcessName}")));
received = 0;

View File

@@ -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;
@@ -50,12 +51,12 @@ namespace Netch.Utils
if (await LoadCoreAsync(FileFullName))
return;
Log.Information("尝试加载备份配置文件 {FileName}", BackupFileFullName);
Log.Information("Load backup configuration \"{FileName}\"", BackupFileFullName);
await LoadCoreAsync(BackupFileFullName);
}
catch (Exception e)
{
Log.Error(e, "加载配置异常");
Log.Error(e, "Load configuration failed");
Environment.Exit(-1);
}
}
@@ -77,7 +78,7 @@ namespace Netch.Utils
}
catch (Exception e)
{
Log.Error(e, @"从 {FileName} 加载配置异常", filename);
Log.Error(e, "Load configuration file \"{FileName}\" error ", filename);
return false;
}
}
@@ -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>
@@ -122,7 +123,7 @@ namespace Netch.Utils
}
catch (Exception e)
{
Log.Error(e, "保存配置异常");
Log.Error(e, "Save Configuration error");
}
}

View File

@@ -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;
}
}
}

View File

@@ -1,9 +1,9 @@
using System;
using System.IO;
using System.Linq;
using Serilog;
using WindowsFirewallHelper;
using WindowsFirewallHelper.FirewallRules;
using Serilog;
namespace Netch.Utils
{
@@ -18,7 +18,7 @@ namespace Netch.Utils
{
if (!FirewallWAS.IsLocallySupported)
{
Log.Warning("不支持防火墙");
Log.Warning("Windows Firewall Locally Unsupported");
return;
}
@@ -38,7 +38,7 @@ namespace Netch.Utils
}
catch (Exception e)
{
Log.Warning(e, "添加防火墙规则错误");
Log.Warning(e, "Create Netch Firewall rules error");
}
}
@@ -58,7 +58,7 @@ namespace Netch.Utils
}
catch (Exception e)
{
Log.Warning(e, "清除防火墙规则错误");
Log.Warning(e, "Remove Netch Firewall rules error");
}
}

View File

@@ -139,8 +139,8 @@ namespace Netch.Utils
case ModeType.Pcap2Socks:
return (new PcapController(), 0);
default:
Log.Error("未知模式类型");
throw new MessageException("未知模式类型");
Log.Error("Unknown Mode Type \"{Type}\"", (int)type);
throw new MessageException("Unknown Mode Type");
}
}
}

View File

@@ -28,7 +28,7 @@ namespace Netch.Utils
}
catch (Exception e)
{
Log.Error(e, "获取保留端口错误");
Log.Error(e, "Get reserved ports failed");
}
}
@@ -86,7 +86,7 @@ namespace Netch.Utils
foreach (var line in output.SplitRemoveEmptyEntriesAndTrimEntries('\n'))
{
var value = line.Trim().SplitRemoveEmptyEntries(' ');
if (value.Length != 2)
if (value.Length < 2)
continue;
if (!ushort.TryParse(value[0], out var start) || !ushort.TryParse(value[1], out var end))

View File

@@ -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;
@@ -53,13 +54,13 @@ namespace Netch.Utils
}
catch (Exception e)
{
Log.Error(e, "从分享链接导入服务器异常");
Log.Error(e, "Parse servers from share link error");
}
}
}
catch (Exception e)
{
Log.Error(e, "从分享链接导入服务器异常");
Log.Error(e, "Parse servers from share link error");
}
return list;
@@ -84,7 +85,7 @@ namespace Netch.Utils
if (util != null)
list.AddRange(util.ParseUri(text));
else
Log.Warning("无法处理 {Scheme} 协议订阅链接", scheme);
Log.Warning("\"{Scheme}\" scheme share link not supported", scheme);
}
foreach (var node in list.Where(node => !node.Remark.IsNullOrWhiteSpace()))

View File

@@ -8,16 +8,16 @@ using Serilog;
namespace Netch.Utils
{
public static class Subscription
public static class SubscriptionUtil
{
private static readonly object ServerLock = new();
public static async Task UpdateServersAsync(string? proxyServer = default)
{
await Task.WhenAll(Global.Settings.SubscribeLink.Select(item => UpdateServerCoreAsync(item, proxyServer)));
await Task.WhenAll(Global.Settings.Subscription.Select(item => UpdateServerCoreAsync(item, proxyServer)));
}
private static async Task UpdateServerCoreAsync(SubscribeLink item, string? proxyServer)
private static async Task UpdateServerCoreAsync(Subscription item, string? proxyServer)
{
try
{
@@ -53,8 +53,8 @@ namespace Netch.Utils
}
catch (Exception e)
{
Global.MainForm.NotifyTip($"{i18N.TranslateFormat("Update servers error from {0}", item.Remark)}\n{e.Message}", info: false);
Log.Warning(e, "更新服务器失败");
Global.MainForm.NotifyTip($"{i18N.TranslateFormat("Update servers failed from {0}", item.Remark)}\n{e.Message}", info: false);
Log.Warning(e, "Update servers failed");
}
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Management;
@@ -31,25 +32,28 @@ namespace Netch.Utils
public static IEnumerable<string> Processes(bool mask)
{
var hashset = new HashSet<string>();
var sortedSet = new SortedSet<string>();
var windowsFolder = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
var windowsAppsFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "WindowsApps");
var userProfileFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
foreach (var process in Process.GetProcesses())
{
try
{
if (process.Id is 0 or 4)
var path = process.MainModule?.FileName;
if (path == null)
continue;
// ! NT Kernel & System
if (process.MainModule!.FileName!.StartsWith(windowsFolder, StringComparison.OrdinalIgnoreCase))
if (path.StartsWith(windowsFolder, StringComparison.OrdinalIgnoreCase))
continue;
var path = process.MainModule.FileName;
if (path.StartsWith(windowsAppsFolder, StringComparison.OrdinalIgnoreCase))
continue;
if (mask)
path = path.Replace(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "%USERPROFILE%");
hashset.Add(path);
sortedSet.Add(path.Replace(userProfileFolder, "%USERPROFILE%"));
else
sortedSet.Add(path);
}
catch (Exception)
{
@@ -57,7 +61,7 @@ namespace Netch.Utils
}
}
return hashset;
return sortedSet;
}
}
}

View File

@@ -33,7 +33,7 @@ namespace Netch.Utils
}
catch (Exception e)
{
Log.Warning(e, "打开 {Uri} 失败", path);
Log.Warning(e, "Open \"{Uri}\" failed", path);
}
}
@@ -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('/');

View File

@@ -10,7 +10,7 @@ namespace Netch.Utils
public static class WebUtil
{
public const string DefaultUserAgent =
@"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.67";
@"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36 Edg/94.0.992.31";
static WebUtil()
{
@@ -50,7 +50,6 @@ namespace Netch.Utils
/// 异步下载并编码为字符串
/// </summary>
/// <param name="req"></param>
/// <param name="rep"></param>
/// <param name="encoding">编码默认UTF-8</param>
/// <returns></returns>
public static (HttpStatusCode, string) DownloadString(HttpWebRequest req, Encoding? encoding = null)

View File

@@ -1,5 +1,4 @@
using Netch.Properties;
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@@ -7,6 +6,7 @@ using System.Linq;
using System.Text;
using System.Text.Json;
using System.Windows.Forms;
using Netch.Properties;
using Serilog;
namespace Netch.Utils
@@ -42,7 +42,7 @@ namespace Netch.Utils
{
var oldLangCode = LangCode;
LangCode = languages.FirstOrDefault(s => GetLanguage(s).Equals(GetLanguage(LangCode))) ?? "en-US";
Log.Information("找不到语言 {OldLangCode}, 使用 {LangCode}",oldLangCode,LangCode);
Log.Information("Not found language {OldLangCode}, use {LangCode} instead", oldLangCode, LangCode);
}
switch (LangCode)
@@ -62,7 +62,7 @@ namespace Netch.Utils
if (!dictionary.Any())
{
Log.Error("{LangCode} 语言文件错误", LangCode);
Log.Error("Invalid language file \"{LangCode}\"", LangCode);
return;
}

View File

@@ -20,7 +20,7 @@ New-Item -ItemType Directory -Name bin | Out-Null
New-Item -ItemType Directory -Name mode | Out-Null
New-Item -ItemType Directory -Name i18n | Out-Null
Copy-Item -Recurse -Force .\netchdata-master\* .\bin -Exclude @('tap2socks.bin')
Copy-Item -Recurse -Force .\netchdata-master\* .\bin
Copy-Item -Recurse -Force .\netchmode-master\mode\* .\mode
Copy-Item -Recurse -Force .\netchi18n-master\i18n\* .\i18n

View File

@@ -1,5 +1,5 @@
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
Expand-Archive -Force -Path xray-core.zip -DestinationPath xray-core