From bcccb80ece6a3a3b962cbaa6f3778b513b65ed43 Mon Sep 17 00:00:00 2001 From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com> Date: Tue, 15 Dec 2020 17:31:21 +0800 Subject: [PATCH] feat: Redirector Shadowsocks (no plugin) support --- Netch/Controllers/NFController.cs | 16 ++++++++++++---- Netch/Servers/Shadowsocks/SSController.cs | 4 ++++ binaries | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Netch/Controllers/NFController.cs b/Netch/Controllers/NFController.cs index 11eddb7a..7eb843ea 100644 --- a/Netch/Controllers/NFController.cs +++ b/Netch/Controllers/NFController.cs @@ -6,6 +6,7 @@ using System.Runtime.InteropServices; using System.ServiceProcess; using System.Threading.Tasks; using Netch.Models; +using Netch.Servers.Shadowsocks; using Netch.Servers.Socks5; using Netch.Utils; using nfapinet; @@ -187,22 +188,29 @@ namespace Netch.Controllers var offset = portType == PortType.UDP ? UdpNameListOffset : 0; - aio_dial((int) NameList.TYPE_TCPTYPE + offset, "Socks5"); - if (controller.Server is Socks5 socks5) { + aio_dial((int) NameList.TYPE_TCPTYPE + offset, "Socks5"); aio_dial((int) NameList.TYPE_TCPHOST + offset, $"{socks5.AutoResolveHostname()}:{socks5.Port}"); aio_dial((int) NameList.TYPE_TCPUSER + offset, socks5.Username ?? string.Empty); aio_dial((int) NameList.TYPE_TCPPASS + offset, socks5.Password ?? string.Empty); + aio_dial((int) NameList.TYPE_TCPMETH + offset, string.Empty); + } + else if (controller.Server is Shadowsocks shadowsocks) + { + aio_dial((int) NameList.TYPE_TCPTYPE + offset, "Shadowsocks"); + aio_dial((int) NameList.TYPE_TCPHOST + offset, $"{shadowsocks.AutoResolveHostname()}:{shadowsocks.Port}"); + aio_dial((int) NameList.TYPE_TCPMETH + offset, shadowsocks.EncryptMethod ?? string.Empty); + aio_dial((int) NameList.TYPE_TCPPASS + offset, shadowsocks.Password ?? string.Empty); } else { + aio_dial((int) NameList.TYPE_TCPTYPE + offset, "Socks5"); aio_dial((int) NameList.TYPE_TCPHOST + offset, $"127.0.0.1:{controller.Socks5LocalPort()}"); aio_dial((int) NameList.TYPE_TCPUSER + offset, string.Empty); aio_dial((int) NameList.TYPE_TCPPASS + offset, string.Empty); + aio_dial((int) NameList.TYPE_TCPMETH + offset, string.Empty); } - - aio_dial((int) NameList.TYPE_TCPMETH + offset, string.Empty); } private void SetName(Mode mode) diff --git a/Netch/Servers/Shadowsocks/SSController.cs b/Netch/Servers/Shadowsocks/SSController.cs index cc72f0f4..eb0fc5a8 100644 --- a/Netch/Servers/Shadowsocks/SSController.cs +++ b/Netch/Servers/Shadowsocks/SSController.cs @@ -21,6 +21,10 @@ namespace Netch.Servers.Shadowsocks { Server = s; var server = (Shadowsocks) s; + + if (mode.Type == 0 && !server.HasPlugin()) + return true; + DllFlag = Global.Settings.BootShadowsocksFromDLL && mode.Type is 0 or 1 or 2 && !server.HasPlugin(); //从DLL启动Shaowsocks diff --git a/binaries b/binaries index 20eae10b..19dbcf1e 160000 --- a/binaries +++ b/binaries @@ -1 +1 @@ -Subproject commit 20eae10b430250f2333b9f1e711a5874f030eee2 +Subproject commit 19dbcf1e6d4bccb4527e21becda9d56053cb4298