From 212aaf8a8fcb33b3c50645c49e5b928f20767a64 Mon Sep 17 00:00:00 2001 From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com> Date: Sat, 20 Feb 2021 16:06:00 +0800 Subject: [PATCH] Update ACL to "data" --- Netch/Forms/MainForm.cs | 2 +- Netch/Global.cs | 9 ++++++--- Netch/Servers/Shadowsocks/SSController.cs | 11 +++++++---- Netch/Servers/ShadowsocksR/SSRController.cs | 4 +++- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Netch/Forms/MainForm.cs b/Netch/Forms/MainForm.cs index 570fe018..9ed6e714 100644 --- a/Netch/Forms/MainForm.cs +++ b/Netch/Forms/MainForm.cs @@ -445,7 +445,7 @@ namespace Netch.Forms if (useProxy) req.Proxy = new WebProxy($"http://127.0.0.1:{Global.Settings.HTTPLocalPort}"); - await WebUtil.DownloadFileAsync(req, Path.Combine(Global.NetchDir, "bin\\default.acl")); + await WebUtil.DownloadFileAsync(req, Path.Combine(Global.NetchDir, Global.UserACL)); NotifyTip(i18N.Translate("ACL updated successfully")); } catch (Exception e) diff --git a/Netch/Global.cs b/Netch/Global.cs index 9d317c50..794774d9 100644 --- a/Netch/Global.cs +++ b/Netch/Global.cs @@ -1,6 +1,3 @@ -using Netch.Controllers; -using Netch.Forms; -using Netch.Models; using System; using System.Collections.Generic; using System.Linq; @@ -10,6 +7,9 @@ using System.Net.Sockets; using System.Threading; using System.Windows.Forms; using WindowsJobAPI; +using Netch.Controllers; +using Netch.Forms; +using Netch.Models; namespace Netch { @@ -39,6 +39,9 @@ namespace Netch private static bool? _supportFakeDns; } + public const string UserACL = "data\\user.acl"; + public const string BuiltinACL = "bin\\default.acl"; + /// /// 出口适配器 /// diff --git a/Netch/Servers/Shadowsocks/SSController.cs b/Netch/Servers/Shadowsocks/SSController.cs index 87a659b6..47745570 100644 --- a/Netch/Servers/Shadowsocks/SSController.cs +++ b/Netch/Servers/Shadowsocks/SSController.cs @@ -1,3 +1,4 @@ +using System.IO; using System.Runtime.InteropServices; using System.Text; using Netch.Controllers; @@ -58,12 +59,14 @@ namespace Netch.Servers.Shadowsocks $"-l {this.Socks5LocalPort()} " + $"-m {server.EncryptMethod} " + $"-k \"{server.Password}\" " + - "-u "); + "-u"); if (!string.IsNullOrWhiteSpace(server.Plugin) && !string.IsNullOrWhiteSpace(server.PluginOption)) - argument.Append($"--plugin {server.Plugin} " + - $"--plugin-opts \"{server.PluginOption}\""); + argument.Append($" --plugin {server.Plugin}" + + $" --plugin-opts \"{server.PluginOption}\""); if (mode.BypassChina) - argument.Append(" --acl default.acl"); + { + argument.Append($" --acl {Path.GetFullPath(File.Exists(Global.UserACL) ? Global.UserACL : Global.BuiltinACL)}"); + } #endregion diff --git a/Netch/Servers/ShadowsocksR/SSRController.cs b/Netch/Servers/ShadowsocksR/SSRController.cs index 73138748..bd316a46 100644 --- a/Netch/Servers/ShadowsocksR/SSRController.cs +++ b/Netch/Servers/ShadowsocksR/SSRController.cs @@ -1,3 +1,4 @@ +using System.IO; using System.Text; using Netch.Controllers; using Netch.Models; @@ -34,7 +35,8 @@ namespace Netch.Servers.ShadowsocksR } argument.Append($" -b {this.LocalAddress()} -l {this.Socks5LocalPort()} -u"); - if (mode.BypassChina) argument.Append(" --acl default.acl"); + if (mode.BypassChina) + argument.Append($" --acl {Path.GetFullPath(File.Exists(Global.UserACL) ? Global.UserACL : Global.BuiltinACL)}"); #endregion