From 46d60babbca43e03baa72f89f9dc3c68f91d7b11 Mon Sep 17 00:00:00 2001 From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com> Date: Tue, 31 Aug 2021 11:48:49 +0800 Subject: [PATCH] Refactor: Update Netch.Servers naming --- Netch/Controllers/MainController.cs | 5 ++-- Netch/Controllers/NFController.cs | 5 ++-- Netch/Controllers/PcapController.cs | 2 +- Netch/Controllers/TUNController.cs | 4 ++-- Netch/Forms/AboutForm.cs | 1 - Netch/Interfaces/IServerController.cs | 2 +- Netch/Models/GitHubRelease/VersionUtil.cs | 4 +--- Netch/Models/Server.cs | 1 - ...Controller.cs => ShadowsocksController.cs} | 12 +++++----- .../Shadowsocks/{Form => }/ShadowsocksForm.cs | 6 ++--- .../{Shadowsocks.cs => ShadowsocksServer.cs} | 4 ++-- .../{SSUtil.cs => ShadowsocksUtil.cs} | 24 +++++++++---------- .../SSD/Main.cs => ShareModels/SSDJObject.cs} | 6 ++--- .../SSDServerJObject.cs} | 4 ++-- .../ShadowsocksConfig.cs | 6 ++++- ...ontroller.cs => ShadowsocksRController.cs} | 13 +++++----- .../{Form => }/ShadowsocksRForm.cs | 6 ++--- ...{ShadowsocksR.cs => ShadowsocksRServer.cs} | 4 ++-- .../{SSRUtil.cs => ShadowsocksRUtil.cs} | 20 +++++++--------- .../{S5Controller.cs => Socks5Controller.cs} | 6 ++--- Netch/Servers/Socks5/{Form => }/Socks5Form.cs | 4 ++-- .../{Socks5Bridge.cs => Socks5LocalServer.cs} | 6 +++-- .../Socks5/{Socks5.cs => Socks5Server.cs} | 8 +++---- .../Socks5/{S5Util.cs => Socks5Util.cs} | 12 +++++----- .../Trojan/{Models => }/TrojanConfig.cs | 2 +- Netch/Servers/Trojan/TrojanController.cs | 7 +++--- Netch/Servers/Trojan/{Form => }/TrojanForm.cs | 6 ++--- .../Trojan/{Trojan.cs => TrojanServer.cs} | 2 +- Netch/Servers/Trojan/TrojanUtil.cs | 9 ++++--- .../V2rayNJObject.cs} | 7 ++---- .../Servers/V2ray/{Models => }/V2rayConfig.cs | 2 +- .../V2ray/{Utils => }/V2rayConfigUtils.cs | 12 ++++------ Netch/Servers/V2ray/V2rayController.cs | 5 ++-- Netch/Servers/V2ray/V2rayUtils.cs | 8 +++---- .../VLESS/{VLESSForm => }/VLESSForm.cs | 6 ++--- .../VLESS/{VLESS.cs => VLESSServer.cs} | 2 +- Netch/Servers/VLESS/VLESSUtil.cs | 7 +++--- Netch/Servers/VMess/{Form => }/VMessForm.cs | 6 ++--- .../VMess/{VMess.cs => VMessServer.cs} | 2 +- Netch/Servers/VMess/VMessUtil.cs | 14 +++++------ Netch/Utils/Bandwidth.cs | 1 - Netch/Utils/ShareLink.cs | 5 ++-- 42 files changed, 125 insertions(+), 143 deletions(-) rename Netch/Servers/Shadowsocks/{SSController.cs => ShadowsocksController.cs} (75%) rename Netch/Servers/Shadowsocks/{Form => }/ShadowsocksForm.cs (83%) rename Netch/Servers/Shadowsocks/{Shadowsocks.cs => ShadowsocksServer.cs} (95%) rename Netch/Servers/Shadowsocks/{SSUtil.cs => ShadowsocksUtil.cs} (90%) rename Netch/Servers/Shadowsocks/{Models/SSD/Main.cs => ShareModels/SSDJObject.cs} (87%) rename Netch/Servers/Shadowsocks/{Models/SSD/SSDServer.cs => ShareModels/SSDServerJObject.cs} (91%) rename Netch/Servers/Shadowsocks/{Models => ShareModels}/ShadowsocksConfig.cs (68%) rename Netch/Servers/ShadowsocksR/{SSRController.cs => ShadowsocksRController.cs} (75%) rename Netch/Servers/ShadowsocksR/{Form => }/ShadowsocksRForm.cs (86%) rename Netch/Servers/ShadowsocksR/{ShadowsocksR.cs => ShadowsocksRServer.cs} (96%) rename Netch/Servers/ShadowsocksR/{SSRUtil.cs => ShadowsocksRUtil.cs} (92%) rename Netch/Servers/Socks5/{S5Controller.cs => Socks5Controller.cs} (65%) rename Netch/Servers/Socks5/{Form => }/Socks5Form.cs (80%) rename Netch/Servers/Socks5/{Socks5Bridge.cs => Socks5LocalServer.cs} (66%) rename Netch/Servers/Socks5/{Socks5.cs => Socks5Server.cs} (76%) rename Netch/Servers/Socks5/{S5Util.cs => Socks5Util.cs} (87%) rename Netch/Servers/Trojan/{Models => }/TrojanConfig.cs (98%) rename Netch/Servers/Trojan/{Form => }/TrojanForm.cs (75%) rename Netch/Servers/Trojan/{Trojan.cs => TrojanServer.cs} (92%) rename Netch/Servers/V2ray/{Models/V2rayNSharing.cs => ShareModels/V2rayNJObject.cs} (91%) rename Netch/Servers/V2ray/{Models => }/V2rayConfig.cs (98%) rename Netch/Servers/V2ray/{Utils => }/V2rayConfigUtils.cs (96%) rename Netch/Servers/VLESS/{VLESSForm => }/VLESSForm.cs (94%) rename Netch/Servers/VLESS/{VLESS.cs => VLESSServer.cs} (96%) rename Netch/Servers/VMess/{Form => }/VMessForm.cs (93%) rename Netch/Servers/VMess/{VMess.cs => VMessServer.cs} (99%) diff --git a/Netch/Controllers/MainController.cs b/Netch/Controllers/MainController.cs index 6d1d974b..8ad6a8fc 100644 --- a/Netch/Controllers/MainController.cs +++ b/Netch/Controllers/MainController.cs @@ -6,7 +6,6 @@ using Netch.Enums; using Netch.Interfaces; using Netch.Models; using Netch.Servers; -using Netch.Servers.Shadowsocks; using Netch.Utils; using Serilog; using Serilog.Events; @@ -56,8 +55,8 @@ namespace Netch.Controllers switch (server) { - case Socks5 socks5 when !socks5.Auth() || socks5.Auth() && ModeFeatures.HasFlag(ModeFeature.SupportSocks5Auth): - case Shadowsocks shadowsocks when !shadowsocks.HasPlugin() && ModeFeatures.HasFlag(ModeFeature.SupportShadowsocks) && + case Socks5Server socks5 when !socks5.Auth() || socks5.Auth() && ModeFeatures.HasFlag(ModeFeature.SupportSocks5Auth): + case ShadowsocksServer shadowsocks when !shadowsocks.HasPlugin() && ModeFeatures.HasFlag(ModeFeature.SupportShadowsocks) && Global.Settings.Redirector.RedirectorSS: break; default: diff --git a/Netch/Controllers/NFController.cs b/Netch/Controllers/NFController.cs index 00f54457..3c6f4ed6 100644 --- a/Netch/Controllers/NFController.cs +++ b/Netch/Controllers/NFController.cs @@ -9,7 +9,6 @@ using Netch.Interfaces; using Netch.Interops; using Netch.Models; using Netch.Servers; -using Netch.Servers.Shadowsocks; using Netch.Utils; using Serilog; using static Netch.Interops.Redirector; @@ -115,7 +114,7 @@ namespace Netch.Controllers var offset = portType == PortType.UDP ? UdpNameListOffset : 0; - if (server is Socks5 socks5) + if (server is Socks5Server socks5) { Dial(NameList.TYPE_TCPTYPE + offset, "Socks5"); Dial(NameList.TYPE_TCPHOST + offset, $"{await socks5.AutoResolveHostnameAsync()}:{socks5.Port}"); @@ -123,7 +122,7 @@ namespace Netch.Controllers Dial(NameList.TYPE_TCPPASS + offset, socks5.Password ?? string.Empty); Dial(NameList.TYPE_TCPMETH + offset, string.Empty); } - else if (server is Shadowsocks shadowsocks && !shadowsocks.HasPlugin() && _rdrConfig.RedirectorSS) + else if (server is ShadowsocksServer shadowsocks && !shadowsocks.HasPlugin() && _rdrConfig.RedirectorSS) { Dial(NameList.TYPE_TCPTYPE + offset, "Shadowsocks"); Dial(NameList.TYPE_TCPHOST + offset, $"{await shadowsocks.AutoResolveHostnameAsync()}:{shadowsocks.Port}"); diff --git a/Netch/Controllers/PcapController.cs b/Netch/Controllers/PcapController.cs index 55081590..4bf42220 100644 --- a/Netch/Controllers/PcapController.cs +++ b/Netch/Controllers/PcapController.cs @@ -39,7 +39,7 @@ namespace Netch.Controllers var outboundNetworkInterface = NetworkInterfaceUtils.GetBest(); var argument = new StringBuilder($@"-i \Device\NPF_{outboundNetworkInterface.Id}"); - if (_server is Socks5 socks5 && !socks5.Auth()) + if (_server is Socks5Server socks5 && !socks5.Auth()) argument.Append($" --destination {await socks5.AutoResolveHostnameAsync()}:{socks5.Port}"); else Trace.Assert(false); diff --git a/Netch/Controllers/TUNController.cs b/Netch/Controllers/TUNController.cs index 7b91ec04..e3ba1c8f 100644 --- a/Netch/Controllers/TUNController.cs +++ b/Netch/Controllers/TUNController.cs @@ -35,7 +35,7 @@ namespace Netch.Controllers _mode = mode; _tunConfig = Global.Settings.TUNTAP; - if (server is Socks5Bridge socks5Bridge) + if (server is Socks5LocalServer socks5Bridge) _serverRemoteAddress = await DnsUtils.LookupAsync(socks5Bridge.RemoteHostname); if (_serverRemoteAddress != null && IPAddress.IsLoopback(_serverRemoteAddress)) @@ -56,7 +56,7 @@ namespace Netch.Controllers Dial(NameList.TYPE_UDPREST, ""); Dial(NameList.TYPE_UDPTYPE, "Socks5"); - if (server is Socks5 socks5) + if (server is Socks5Server socks5) { Dial(NameList.TYPE_TCPHOST, $"{await socks5.AutoResolveHostnameAsync()}:{socks5.Port}"); diff --git a/Netch/Forms/AboutForm.cs b/Netch/Forms/AboutForm.cs index 96431cae..42b481d6 100644 --- a/Netch/Forms/AboutForm.cs +++ b/Netch/Forms/AboutForm.cs @@ -1,7 +1,6 @@ using Netch.Properties; using Netch.Utils; using System; -using System.Diagnostics; using System.Windows.Forms; namespace Netch.Forms diff --git a/Netch/Interfaces/IServerController.cs b/Netch/Interfaces/IServerController.cs index d955292f..33a582b3 100644 --- a/Netch/Interfaces/IServerController.cs +++ b/Netch/Interfaces/IServerController.cs @@ -10,7 +10,7 @@ namespace Netch.Interfaces public string? LocalAddress { get; set; } - public Task StartAsync(Server s); + public Task StartAsync(Server s); } public static class ServerControllerExtension diff --git a/Netch/Models/GitHubRelease/VersionUtil.cs b/Netch/Models/GitHubRelease/VersionUtil.cs index 451a46c3..4ed5b71e 100644 --- a/Netch/Models/GitHubRelease/VersionUtil.cs +++ b/Netch/Models/GitHubRelease/VersionUtil.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; namespace Netch.Models.GitHubRelease { diff --git a/Netch/Models/Server.cs b/Netch/Models/Server.cs index 2d83536a..386d5e13 100644 --- a/Netch/Models/Server.cs +++ b/Netch/Models/Server.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Net.Sockets; using System.Text.Json.Serialization; using System.Threading.Tasks; diff --git a/Netch/Servers/Shadowsocks/SSController.cs b/Netch/Servers/Shadowsocks/ShadowsocksController.cs similarity index 75% rename from Netch/Servers/Shadowsocks/SSController.cs rename to Netch/Servers/Shadowsocks/ShadowsocksController.cs index 12edf926..a33279e7 100644 --- a/Netch/Servers/Shadowsocks/SSController.cs +++ b/Netch/Servers/Shadowsocks/ShadowsocksController.cs @@ -5,11 +5,11 @@ using Netch.Controllers; using Netch.Interfaces; using Netch.Models; -namespace Netch.Servers.Shadowsocks +namespace Netch.Servers { - public class SSController : Guard, IServerController + public class ShadowsocksController : Guard, IServerController { - public SSController() : base("Shadowsocks.exe") + public ShadowsocksController() : base("Shadowsocks.exe") { } @@ -23,9 +23,9 @@ namespace Netch.Servers.Shadowsocks public string? LocalAddress { get; set; } - public async Task StartAsync(Server s) + public async Task StartAsync(Server s) { - var server = (Shadowsocks)s; + var server = (ShadowsocksServer)s; var arguments = new object?[] { @@ -41,7 +41,7 @@ namespace Netch.Servers.Shadowsocks }; await StartGuardAsync(Arguments.Format(arguments)); - return new Socks5Bridge(IPAddress.Loopback.ToString(), this.Socks5LocalPort(), server.Hostname); + return new Socks5LocalServer(IPAddress.Loopback.ToString(), this.Socks5LocalPort(), server.Hostname); } } } \ No newline at end of file diff --git a/Netch/Servers/Shadowsocks/Form/ShadowsocksForm.cs b/Netch/Servers/Shadowsocks/ShadowsocksForm.cs similarity index 83% rename from Netch/Servers/Shadowsocks/Form/ShadowsocksForm.cs rename to Netch/Servers/Shadowsocks/ShadowsocksForm.cs index efad731d..e1b69135 100644 --- a/Netch/Servers/Shadowsocks/Form/ShadowsocksForm.cs +++ b/Netch/Servers/Shadowsocks/ShadowsocksForm.cs @@ -1,13 +1,13 @@ using Netch.Forms; using Netch.Utils; -namespace Netch.Servers.Shadowsocks.Form +namespace Netch.Servers { public class ShadowsocksForm : ServerForm { - public ShadowsocksForm(Shadowsocks? server = default) + public ShadowsocksForm(ShadowsocksServer? server = default) { - server ??= new Shadowsocks(); + server ??= new ShadowsocksServer(); Server = server; CreateTextBox("Password", "Password", s => !s.IsNullOrWhiteSpace(), s => server.Password = s, server.Password); CreateComboBox("EncryptMethod", "Encrypt Method", SSGlobal.EncryptMethods, s => server.EncryptMethod = s, server.EncryptMethod); diff --git a/Netch/Servers/Shadowsocks/Shadowsocks.cs b/Netch/Servers/Shadowsocks/ShadowsocksServer.cs similarity index 95% rename from Netch/Servers/Shadowsocks/Shadowsocks.cs rename to Netch/Servers/Shadowsocks/ShadowsocksServer.cs index c22801cd..1d8ed8f2 100644 --- a/Netch/Servers/Shadowsocks/Shadowsocks.cs +++ b/Netch/Servers/Shadowsocks/ShadowsocksServer.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using Netch.Models; -namespace Netch.Servers.Shadowsocks +namespace Netch.Servers { - public class Shadowsocks : Server + public class ShadowsocksServer : Server { public override string Type { get; } = "SS"; public override string MaskedData() diff --git a/Netch/Servers/Shadowsocks/SSUtil.cs b/Netch/Servers/Shadowsocks/ShadowsocksUtil.cs similarity index 90% rename from Netch/Servers/Shadowsocks/SSUtil.cs rename to Netch/Servers/Shadowsocks/ShadowsocksUtil.cs index 1fab9d0d..3bb21506 100644 --- a/Netch/Servers/Shadowsocks/SSUtil.cs +++ b/Netch/Servers/Shadowsocks/ShadowsocksUtil.cs @@ -6,14 +6,12 @@ using System.Text.RegularExpressions; using System.Web; using Netch.Interfaces; using Netch.Models; -using Netch.Servers.Shadowsocks.Form; -using Netch.Servers.Shadowsocks.Models.SSD; using Netch.Utils; using Serilog; -namespace Netch.Servers.Shadowsocks +namespace Netch.Servers { - public class SSUtil : IServerUtil + public class ShadowsocksUtil : IServerUtil { public ushort Priority { get; } = 1; @@ -25,11 +23,11 @@ namespace Netch.Servers.Shadowsocks public string[] UriScheme { get; } = { "ss", "ssd" }; - public Type ServerType { get; } = typeof(Shadowsocks); + public Type ServerType { get; } = typeof(ShadowsocksServer); public void Edit(Server s) { - new ShadowsocksForm((Shadowsocks)s).ShowDialog(); + new ShadowsocksForm((ShadowsocksServer)s).ShowDialog(); } public void Create() @@ -39,7 +37,7 @@ namespace Netch.Servers.Shadowsocks public string GetShareLink(Server s) { - var server = (Shadowsocks)s; + var server = (ShadowsocksServer)s; // ss://method:password@server:port#Remark return "ss://" + ShareLink.URLSafeBase64Encode($"{server.EncryptMethod}:{server.Password}@{server.Hostname}:{server.Port}") + "#" + HttpUtility.UrlEncode(server.Remark); @@ -47,7 +45,7 @@ namespace Netch.Servers.Shadowsocks public IServerController GetController() { - return new SSController(); + return new ShadowsocksController(); } public IEnumerable ParseUri(string text) @@ -63,7 +61,7 @@ namespace Netch.Servers.Shadowsocks public bool CheckServer(Server s) { - var server = (Shadowsocks)s; + var server = (ShadowsocksServer)s; if (!SSGlobal.EncryptMethods.Contains(server.EncryptMethod)) { Log.Warning("不支持的 SS 加密方式:{Method}", server.EncryptMethod); @@ -75,9 +73,9 @@ namespace Netch.Servers.Shadowsocks public IEnumerable ParseSsdUri(string s) { - var json = JsonSerializer.Deserialize
(ShareLink.URLSafeBase64Decode(s.Substring(6)))!; + var json = JsonSerializer.Deserialize(ShareLink.URLSafeBase64Decode(s.Substring(6)))!; - return json.servers.Select(server => new Shadowsocks + return json.servers.Select(server => new ShadowsocksServer { Remark = server.remarks, Hostname = server.server, @@ -92,9 +90,9 @@ namespace Netch.Servers.Shadowsocks .Where(CheckServer); } - public Shadowsocks ParseSsUri(string text) + public ShadowsocksServer ParseSsUri(string text) { - var data = new Shadowsocks(); + var data = new ShadowsocksServer(); text = text.Replace("/?", "?"); if (text.Contains("#")) diff --git a/Netch/Servers/Shadowsocks/Models/SSD/Main.cs b/Netch/Servers/Shadowsocks/ShareModels/SSDJObject.cs similarity index 87% rename from Netch/Servers/Shadowsocks/Models/SSD/Main.cs rename to Netch/Servers/Shadowsocks/ShareModels/SSDJObject.cs index ff36fd0d..69adeb65 100644 --- a/Netch/Servers/Shadowsocks/Models/SSD/Main.cs +++ b/Netch/Servers/Shadowsocks/ShareModels/SSDJObject.cs @@ -1,9 +1,9 @@ #nullable disable using System.Collections.Generic; -namespace Netch.Servers.Shadowsocks.Models.SSD +namespace Netch.Servers { - public class Main + public class SSDJObject { /// /// 机场名 @@ -38,6 +38,6 @@ namespace Netch.Servers.Shadowsocks.Models.SSD /// /// 服务器数组 /// - public List servers; + public List servers; } } \ No newline at end of file diff --git a/Netch/Servers/Shadowsocks/Models/SSD/SSDServer.cs b/Netch/Servers/Shadowsocks/ShareModels/SSDServerJObject.cs similarity index 91% rename from Netch/Servers/Shadowsocks/Models/SSD/SSDServer.cs rename to Netch/Servers/Shadowsocks/ShareModels/SSDServerJObject.cs index 316bfe67..5807e379 100644 --- a/Netch/Servers/Shadowsocks/Models/SSD/SSDServer.cs +++ b/Netch/Servers/Shadowsocks/ShareModels/SSDServerJObject.cs @@ -1,7 +1,7 @@ #nullable disable -namespace Netch.Servers.Shadowsocks.Models.SSD +namespace Netch.Servers { - public class SSDServer + public class SSDServerJObject { /// /// 加密方式 diff --git a/Netch/Servers/Shadowsocks/Models/ShadowsocksConfig.cs b/Netch/Servers/Shadowsocks/ShareModels/ShadowsocksConfig.cs similarity index 68% rename from Netch/Servers/Shadowsocks/Models/ShadowsocksConfig.cs rename to Netch/Servers/Shadowsocks/ShareModels/ShadowsocksConfig.cs index e8b5d172..6cc3179f 100644 --- a/Netch/Servers/Shadowsocks/Models/ShadowsocksConfig.cs +++ b/Netch/Servers/Shadowsocks/ShareModels/ShadowsocksConfig.cs @@ -1,6 +1,10 @@ #nullable disable -namespace Netch.Servers.Shadowsocks.Models +namespace Netch.Servers { + /// + /// Import Shadowsocks Server from Json Configuration + /// + /// public class ShadowsocksConfig { public string server { get; set; } diff --git a/Netch/Servers/ShadowsocksR/SSRController.cs b/Netch/Servers/ShadowsocksR/ShadowsocksRController.cs similarity index 75% rename from Netch/Servers/ShadowsocksR/SSRController.cs rename to Netch/Servers/ShadowsocksR/ShadowsocksRController.cs index 4989d189..f4e91876 100644 --- a/Netch/Servers/ShadowsocksR/SSRController.cs +++ b/Netch/Servers/ShadowsocksR/ShadowsocksRController.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Net; using System.Threading.Tasks; @@ -6,11 +5,11 @@ using Netch.Controllers; using Netch.Interfaces; using Netch.Models; -namespace Netch.Servers.ShadowsocksR +namespace Netch.Servers { - public class SSRController : Guard, IServerController + public class ShadowsocksRController : Guard, IServerController { - public SSRController() : base("ShadowsocksR.exe") + public ShadowsocksRController() : base("ShadowsocksR.exe") { } @@ -24,9 +23,9 @@ namespace Netch.Servers.ShadowsocksR public string? LocalAddress { get; set; } - public async Task StartAsync(Server s) + public async Task StartAsync(Server s) { - var server = (ShadowsocksR)s; + var server = (ShadowsocksRServer)s; var arguments = new object?[] { @@ -45,7 +44,7 @@ namespace Netch.Servers.ShadowsocksR }; await StartGuardAsync(Arguments.Format(arguments)); - return new Socks5Bridge(IPAddress.Loopback.ToString(), this.Socks5LocalPort(), server.Hostname); + return new Socks5LocalServer(IPAddress.Loopback.ToString(), this.Socks5LocalPort(), server.Hostname); } } } \ No newline at end of file diff --git a/Netch/Servers/ShadowsocksR/Form/ShadowsocksRForm.cs b/Netch/Servers/ShadowsocksR/ShadowsocksRForm.cs similarity index 86% rename from Netch/Servers/ShadowsocksR/Form/ShadowsocksRForm.cs rename to Netch/Servers/ShadowsocksR/ShadowsocksRForm.cs index fe0313df..3352a391 100644 --- a/Netch/Servers/ShadowsocksR/Form/ShadowsocksRForm.cs +++ b/Netch/Servers/ShadowsocksR/ShadowsocksRForm.cs @@ -1,13 +1,13 @@ using Netch.Forms; using Netch.Utils; -namespace Netch.Servers.ShadowsocksR.Form +namespace Netch.Servers { public class ShadowsocksRForm : ServerForm { - public ShadowsocksRForm(ShadowsocksR? server = default) + public ShadowsocksRForm(ShadowsocksRServer? server = default) { - server ??= new ShadowsocksR(); + server ??= new ShadowsocksRServer(); Server = server; CreateTextBox("Password", "Password", s => !s.IsNullOrWhiteSpace(), s => server.Password = s, server.Password); CreateComboBox("EncryptMethod", "Encrypt Method", SSRGlobal.EncryptMethods, s => server.EncryptMethod = s, server.EncryptMethod); diff --git a/Netch/Servers/ShadowsocksR/ShadowsocksR.cs b/Netch/Servers/ShadowsocksR/ShadowsocksRServer.cs similarity index 96% rename from Netch/Servers/ShadowsocksR/ShadowsocksR.cs rename to Netch/Servers/ShadowsocksR/ShadowsocksRServer.cs index 7a2963ff..aa480c14 100644 --- a/Netch/Servers/ShadowsocksR/ShadowsocksR.cs +++ b/Netch/Servers/ShadowsocksR/ShadowsocksRServer.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using Netch.Models; -namespace Netch.Servers.ShadowsocksR +namespace Netch.Servers { - public class ShadowsocksR : Server + public class ShadowsocksRServer : Server { public override string Type { get; } = "SSR"; public override string MaskedData() diff --git a/Netch/Servers/ShadowsocksR/SSRUtil.cs b/Netch/Servers/ShadowsocksR/ShadowsocksRUtil.cs similarity index 92% rename from Netch/Servers/ShadowsocksR/SSRUtil.cs rename to Netch/Servers/ShadowsocksR/ShadowsocksRUtil.cs index 677887a9..346c7b60 100644 --- a/Netch/Servers/ShadowsocksR/SSRUtil.cs +++ b/Netch/Servers/ShadowsocksR/ShadowsocksRUtil.cs @@ -3,14 +3,12 @@ using System.Collections.Generic; using System.Text.RegularExpressions; using Netch.Interfaces; using Netch.Models; -using Netch.Servers.Shadowsocks; -using Netch.Servers.ShadowsocksR.Form; using Netch.Utils; using Serilog; -namespace Netch.Servers.ShadowsocksR +namespace Netch.Servers { - public class SSRUtil : IServerUtil + public class ShadowsocksRUtil : IServerUtil { public ushort Priority { get; } = 1; @@ -22,11 +20,11 @@ namespace Netch.Servers.ShadowsocksR public string[] UriScheme { get; } = { "ssr" }; - public Type ServerType { get; } = typeof(ShadowsocksR); + public Type ServerType { get; } = typeof(ShadowsocksRServer); public void Edit(Server s) { - new ShadowsocksRForm((ShadowsocksR)s).ShowDialog(); + new ShadowsocksRForm((ShadowsocksRServer)s).ShowDialog(); } public void Create() @@ -36,7 +34,7 @@ namespace Netch.Servers.ShadowsocksR public string GetShareLink(Server s) { - var server = (ShadowsocksR)s; + var server = (ShadowsocksRServer)s; // https://github.com/shadowsocksr-backup/shadowsocks-rss/wiki/SSR-QRcode-scheme // ssr://base64(host:port:protocol:method:obfs:base64pass/?obfsparam=base64param&protoparam=base64param&remarks=base64remarks&group=base64group&udpport=0&uot=0) @@ -50,7 +48,7 @@ namespace Netch.Servers.ShadowsocksR public IServerController GetController() { - return new SSRController(); + return new ShadowsocksRController(); } /// @@ -113,7 +111,7 @@ namespace Netch.Servers.ShadowsocksR if (SSGlobal.EncryptMethods.Contains(method) && protocol == "origin" && obfs == "plain") return new[] { - new Shadowsocks.Shadowsocks + new ShadowsocksServer { Hostname = serverAddr, Port = serverPort, @@ -126,7 +124,7 @@ namespace Netch.Servers.ShadowsocksR return new[] { - new ShadowsocksR + new ShadowsocksRServer { Hostname = serverAddr, Port = serverPort, @@ -144,7 +142,7 @@ namespace Netch.Servers.ShadowsocksR public bool CheckServer(Server s) { - var server = (ShadowsocksR)s; + var server = (ShadowsocksRServer)s; if (!SSRGlobal.EncryptMethods.Contains(server.EncryptMethod)) { Log.Error("不支持的 SSR 加密方式:{Method}", server.EncryptMethod); diff --git a/Netch/Servers/Socks5/S5Controller.cs b/Netch/Servers/Socks5/Socks5Controller.cs similarity index 65% rename from Netch/Servers/Socks5/S5Controller.cs rename to Netch/Servers/Socks5/Socks5Controller.cs index cb31900d..bc5bc637 100644 --- a/Netch/Servers/Socks5/S5Controller.cs +++ b/Netch/Servers/Socks5/Socks5Controller.cs @@ -4,13 +4,13 @@ using Netch.Models; namespace Netch.Servers { - public class S5Controller : V2rayController + public class Socks5Controller : V2rayController { public override string Name { get; } = "Socks5"; - public override async Task StartAsync(Server s) + public override async Task StartAsync(Server s) { - var server = (Socks5)s; + var server = (Socks5Server)s; if (!server.Auth()) throw new ArgumentException(); diff --git a/Netch/Servers/Socks5/Form/Socks5Form.cs b/Netch/Servers/Socks5/Socks5Form.cs similarity index 80% rename from Netch/Servers/Socks5/Form/Socks5Form.cs rename to Netch/Servers/Socks5/Socks5Form.cs index fc5ac6b6..d8ff241e 100644 --- a/Netch/Servers/Socks5/Form/Socks5Form.cs +++ b/Netch/Servers/Socks5/Socks5Form.cs @@ -4,9 +4,9 @@ namespace Netch.Servers { public class Socks5Form : ServerForm { - public Socks5Form(Socks5? server = default) + public Socks5Form(Socks5Server? server = default) { - server ??= new Socks5(); + server ??= new Socks5Server(); Server = server; CreateTextBox("Username", "Username", s => true, s => server.Username = s, server.Username); CreateTextBox("Password", "Password", s => true, s => server.Password = s, server.Password); diff --git a/Netch/Servers/Socks5/Socks5Bridge.cs b/Netch/Servers/Socks5/Socks5LocalServer.cs similarity index 66% rename from Netch/Servers/Socks5/Socks5Bridge.cs rename to Netch/Servers/Socks5/Socks5LocalServer.cs index 48ff838e..2fccb714 100644 --- a/Netch/Servers/Socks5/Socks5Bridge.cs +++ b/Netch/Servers/Socks5/Socks5LocalServer.cs @@ -5,10 +5,12 @@ /// Encrypted proxy client's local socks5 server /// ( property is used for saving remote address/hostname for special use) /// - public class Socks5Bridge : Socks5 + public class Socks5LocalServer : Socks5Server { - public Socks5Bridge(string hostname, ushort port, string remoteHostname) : base(hostname, port) + public Socks5LocalServer(string hostname, ushort port, string remoteHostname) { + Hostname = hostname; + Port = port; RemoteHostname = remoteHostname; } diff --git a/Netch/Servers/Socks5/Socks5.cs b/Netch/Servers/Socks5/Socks5Server.cs similarity index 76% rename from Netch/Servers/Socks5/Socks5.cs rename to Netch/Servers/Socks5/Socks5Server.cs index 5f11712c..49197f9f 100644 --- a/Netch/Servers/Socks5/Socks5.cs +++ b/Netch/Servers/Socks5/Socks5Server.cs @@ -2,7 +2,7 @@ namespace Netch.Servers { - public class Socks5 : Server + public class Socks5Server : Server { /// /// 密码 @@ -21,17 +21,17 @@ namespace Netch.Servers return $"Auth: {Auth()}"; } - public Socks5() + public Socks5Server() { } - public Socks5(string hostname, ushort port) + public Socks5Server(string hostname, ushort port) { Hostname = hostname; Port = port; } - public Socks5(string hostname, ushort port, string username, string password) : this(hostname, port) + public Socks5Server(string hostname, ushort port, string username, string password) : this(hostname, port) { Username = username; Password = password; diff --git a/Netch/Servers/Socks5/S5Util.cs b/Netch/Servers/Socks5/Socks5Util.cs similarity index 87% rename from Netch/Servers/Socks5/S5Util.cs rename to Netch/Servers/Socks5/Socks5Util.cs index c3668d44..4e708a82 100644 --- a/Netch/Servers/Socks5/S5Util.cs +++ b/Netch/Servers/Socks5/Socks5Util.cs @@ -6,7 +6,7 @@ using Netch.Models; namespace Netch.Servers { - public class S5Util : IServerUtil + public class Socks5Util : IServerUtil { public ushort Priority { get; } = 0; @@ -18,11 +18,11 @@ namespace Netch.Servers public string[] UriScheme { get; } = { }; - public Type ServerType { get; } = typeof(Socks5); + public Type ServerType { get; } = typeof(Socks5Server); public void Edit(Server s) { - new Socks5Form((Socks5)s).ShowDialog(); + new Socks5Form((Socks5Server)s).ShowDialog(); } public void Create() @@ -32,7 +32,7 @@ namespace Netch.Servers public string GetShareLink(Server s) { - var server = (Socks5)s; + var server = (Socks5Server)s; // https://t.me/socks?server=1.1.1.1&port=443 return $"https://t.me/socks?server={server.Hostname}&port={server.Port}" + $"{(!string.IsNullOrWhiteSpace(server.Username) ? $"&user={server.Username}" : "")}" + @@ -41,7 +41,7 @@ namespace Netch.Servers public IServerController GetController() { - return new S5Controller(); + return new Socks5Controller(); } public IEnumerable ParseUri(string text) @@ -55,7 +55,7 @@ namespace Netch.Servers if (!dict.ContainsKey("server") || !dict.ContainsKey("port")) throw new FormatException(); - var data = new Socks5 + var data = new Socks5Server { Hostname = dict["server"], Port = ushort.Parse(dict["port"]) diff --git a/Netch/Servers/Trojan/Models/TrojanConfig.cs b/Netch/Servers/Trojan/TrojanConfig.cs similarity index 98% rename from Netch/Servers/Trojan/Models/TrojanConfig.cs rename to Netch/Servers/Trojan/TrojanConfig.cs index 13e7a377..056506b5 100644 --- a/Netch/Servers/Trojan/Models/TrojanConfig.cs +++ b/Netch/Servers/Trojan/TrojanConfig.cs @@ -1,7 +1,7 @@ #nullable disable using System.Collections.Generic; -namespace Netch.Servers.Models +namespace Netch.Servers { public class TrojanConfig { diff --git a/Netch/Servers/Trojan/TrojanController.cs b/Netch/Servers/Trojan/TrojanController.cs index 585cdd47..5f328a86 100644 --- a/Netch/Servers/Trojan/TrojanController.cs +++ b/Netch/Servers/Trojan/TrojanController.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Netch.Controllers; using Netch.Interfaces; using Netch.Models; -using Netch.Servers.Models; using Netch.Utils; namespace Netch.Servers @@ -27,9 +26,9 @@ namespace Netch.Servers public string? LocalAddress { get; set; } - public async Task StartAsync(Server s) + public async Task StartAsync(Server s) { - var server = (Trojan)s; + var server = (TrojanServer)s; var trojanConfig = new TrojanConfig { local_addr = this.LocalAddress(), @@ -52,7 +51,7 @@ namespace Netch.Servers } await StartGuardAsync("-c ..\\data\\last.json"); - return new Socks5Bridge(IPAddress.Loopback.ToString(), this.Socks5LocalPort(), server.Hostname); + return new Socks5LocalServer(IPAddress.Loopback.ToString(), this.Socks5LocalPort(), server.Hostname); } } } \ No newline at end of file diff --git a/Netch/Servers/Trojan/Form/TrojanForm.cs b/Netch/Servers/Trojan/TrojanForm.cs similarity index 75% rename from Netch/Servers/Trojan/Form/TrojanForm.cs rename to Netch/Servers/Trojan/TrojanForm.cs index c5a1a7b8..057463b4 100644 --- a/Netch/Servers/Trojan/Form/TrojanForm.cs +++ b/Netch/Servers/Trojan/TrojanForm.cs @@ -1,12 +1,12 @@ using Netch.Forms; -namespace Netch.Servers.Form +namespace Netch.Servers { public class TrojanForm : ServerForm { - public TrojanForm(Trojan? server = default) + public TrojanForm(TrojanServer? server = default) { - server ??= new Trojan(); + server ??= new TrojanServer(); Server = server; CreateTextBox("Password", "Password", s => true, s => server.Password = s, server.Password); CreateTextBox("Host", "Host", s => true, s => server.Host = s, server.Host); diff --git a/Netch/Servers/Trojan/Trojan.cs b/Netch/Servers/Trojan/TrojanServer.cs similarity index 92% rename from Netch/Servers/Trojan/Trojan.cs rename to Netch/Servers/Trojan/TrojanServer.cs index ce943199..bf7beee6 100644 --- a/Netch/Servers/Trojan/Trojan.cs +++ b/Netch/Servers/Trojan/TrojanServer.cs @@ -2,7 +2,7 @@ using Netch.Models; namespace Netch.Servers { - public class Trojan : Server + public class TrojanServer : Server { public override string Type { get; } = "Trojan"; public override string MaskedData() diff --git a/Netch/Servers/Trojan/TrojanUtil.cs b/Netch/Servers/Trojan/TrojanUtil.cs index 5c69a894..3ba46e2a 100644 --- a/Netch/Servers/Trojan/TrojanUtil.cs +++ b/Netch/Servers/Trojan/TrojanUtil.cs @@ -4,7 +4,6 @@ using System.Text.RegularExpressions; using System.Web; using Netch.Interfaces; using Netch.Models; -using Netch.Servers.Form; namespace Netch.Servers { @@ -20,11 +19,11 @@ namespace Netch.Servers public string[] UriScheme { get; } = { "trojan" }; - public Type ServerType { get; } = typeof(Trojan); + public Type ServerType { get; } = typeof(TrojanServer); public void Edit(Server s) { - new TrojanForm((Trojan)s).ShowDialog(); + new TrojanForm((TrojanServer)s).ShowDialog(); } public void Create() @@ -34,7 +33,7 @@ namespace Netch.Servers public string GetShareLink(Server s) { - var server = (Trojan)s; + var server = (TrojanServer)s; return $"trojan://{HttpUtility.UrlEncode(server.Password)}@{server.Hostname}:{server.Port}#{server.Remark}"; } @@ -45,7 +44,7 @@ namespace Netch.Servers public IEnumerable ParseUri(string text) { - var data = new Trojan(); + var data = new TrojanServer(); text = text.Replace("/?", "?"); if (text.Contains("#")) diff --git a/Netch/Servers/V2ray/Models/V2rayNSharing.cs b/Netch/Servers/V2ray/ShareModels/V2rayNJObject.cs similarity index 91% rename from Netch/Servers/V2ray/Models/V2rayNSharing.cs rename to Netch/Servers/V2ray/ShareModels/V2rayNJObject.cs index 069c6d8d..14020dc1 100644 --- a/Netch/Servers/V2ray/Models/V2rayNSharing.cs +++ b/Netch/Servers/V2ray/ShareModels/V2rayNJObject.cs @@ -1,9 +1,6 @@ -namespace Netch.Servers.Models +namespace Netch.Servers { - /// - /// 使用 v2rayN 定义的 VMess 链接格式 - /// - public class V2rayNSharing + public class V2rayNJObject { /// /// 链接版本 diff --git a/Netch/Servers/V2ray/Models/V2rayConfig.cs b/Netch/Servers/V2ray/V2rayConfig.cs similarity index 98% rename from Netch/Servers/V2ray/Models/V2rayConfig.cs rename to Netch/Servers/V2ray/V2rayConfig.cs index a6091a68..fa277fa2 100644 --- a/Netch/Servers/V2ray/Models/V2rayConfig.cs +++ b/Netch/Servers/V2ray/V2rayConfig.cs @@ -1,7 +1,7 @@ #nullable disable // ReSharper disable InconsistentNaming -namespace Netch.Servers.V2ray.Models +namespace Netch.Servers { public struct V2rayConfig { diff --git a/Netch/Servers/V2ray/Utils/V2rayConfigUtils.cs b/Netch/Servers/V2ray/V2rayConfigUtils.cs similarity index 96% rename from Netch/Servers/V2ray/Utils/V2rayConfigUtils.cs rename to Netch/Servers/V2ray/V2rayConfigUtils.cs index f328e39d..c26221ca 100644 --- a/Netch/Servers/V2ray/Utils/V2rayConfigUtils.cs +++ b/Netch/Servers/V2ray/V2rayConfigUtils.cs @@ -1,12 +1,10 @@ using System.Threading.Tasks; using Netch.Models; -using Netch.Servers.V2ray.Models; using Netch.Utils; -using V2rayConfig = Netch.Servers.V2ray.Models.V2rayConfig; #pragma warning disable VSTHRD200 -namespace Netch.Servers.Utils +namespace Netch.Servers { public static class V2rayConfigUtils { @@ -44,7 +42,7 @@ namespace Netch.Servers.Utils switch (server) { - case Socks5 socks5: + case Socks5Server socks5: { outbound.protocol = "socks"; outbound.settings.servers = new object[] @@ -71,7 +69,7 @@ namespace Netch.Servers.Utils outbound.mux.concurrency = -1; break; } - case VLESS vless: + case VLESSServer vless: { outbound.protocol = "vless"; outbound.settings.vnext = new[] @@ -107,7 +105,7 @@ namespace Netch.Servers.Utils break; } - case VMess vmess: + case VMessServer vmess: { outbound.protocol = "vmess"; outbound.settings.vnext = new[] @@ -139,7 +137,7 @@ namespace Netch.Servers.Utils return outbound; } - private static StreamSettings boundStreamSettings(VMess server) + private static StreamSettings boundStreamSettings(VMessServer server) { // https://xtls.github.io/config/transports diff --git a/Netch/Servers/V2ray/V2rayController.cs b/Netch/Servers/V2ray/V2rayController.cs index 62e5a230..79c106ea 100644 --- a/Netch/Servers/V2ray/V2rayController.cs +++ b/Netch/Servers/V2ray/V2rayController.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Netch.Controllers; using Netch.Interfaces; using Netch.Models; -using Netch.Servers.Utils; namespace Netch.Servers { @@ -28,7 +27,7 @@ namespace Netch.Servers public string? LocalAddress { get; set; } - public virtual async Task StartAsync(Server s) + public virtual async Task StartAsync(Server s) { await using (var fileStream = new FileStream(Constants.TempConfig, FileMode.Create, FileAccess.Write, FileShare.Read)) { @@ -36,7 +35,7 @@ namespace Netch.Servers } await StartGuardAsync("-config ..\\data\\last.json"); - return new Socks5Bridge(IPAddress.Loopback.ToString(), this.Socks5LocalPort(), s.Hostname); + return new Socks5LocalServer(IPAddress.Loopback.ToString(), this.Socks5LocalPort(), s.Hostname); } } } \ No newline at end of file diff --git a/Netch/Servers/V2ray/V2rayUtils.cs b/Netch/Servers/V2ray/V2rayUtils.cs index e98691cb..f11b90ed 100644 --- a/Netch/Servers/V2ray/V2rayUtils.cs +++ b/Netch/Servers/V2ray/V2rayUtils.cs @@ -13,7 +13,7 @@ namespace Netch.Servers public static IEnumerable ParseVUri(string text) { var scheme = ShareLink.GetUriScheme(text).ToLower(); - var server = scheme switch { "vmess" => new VMess(), "vless" => new VLESS(), _ => throw new ArgumentOutOfRangeException() }; + var server = scheme switch { "vmess" => new VMessServer(), "vless" => new VLESSServer(), _ => throw new ArgumentOutOfRangeException() }; if (text.Contains("#")) { server.Remark = Uri.UnescapeDataString(text.Split('#')[1]); @@ -58,7 +58,7 @@ namespace Netch.Servers { server.ServerName = parameter.Get("sni") ?? ""; if (server.TLSSecureType == "xtls") - ((VLESS)server).Flow = parameter.Get("flow") ?? ""; + ((VLESSServer)server).Flow = parameter.Get("flow") ?? ""; } } @@ -77,7 +77,7 @@ namespace Netch.Servers public static string GetVShareLink(Server s, string scheme = "vmess") { // https://github.com/XTLS/Xray-core/issues/91 - var server = (VMess)s; + var server = (VMessServer)s; var parameter = new Dictionary(); // protocol-specific fields parameter.Add("type", server.TransferProtocol); @@ -138,7 +138,7 @@ namespace Netch.Servers if (server.TLSSecureType == "xtls") { - var flow = ((VLESS)server).Flow; + var flow = ((VLESSServer)server).Flow; if (!flow.IsNullOrWhiteSpace()) parameter.Add("flow", flow!.Replace("-udp443", "")); } diff --git a/Netch/Servers/VLESS/VLESSForm/VLESSForm.cs b/Netch/Servers/VLESS/VLESSForm.cs similarity index 94% rename from Netch/Servers/VLESS/VLESSForm/VLESSForm.cs rename to Netch/Servers/VLESS/VLESSForm.cs index 5768f013..83ac5db2 100644 --- a/Netch/Servers/VLESS/VLESSForm/VLESSForm.cs +++ b/Netch/Servers/VLESS/VLESSForm.cs @@ -1,13 +1,13 @@ using System.Collections.Generic; using Netch.Forms; -namespace Netch.Servers.VLESSForm +namespace Netch.Servers { internal class VLESSForm : ServerForm { - public VLESSForm(VLESS? server = default) + public VLESSForm(VLESSServer? server = default) { - server ??= new VLESS(); + server ??= new VLESSServer(); Server = server; CreateTextBox("Sni", "ServerName(Sni)", s => true, s => server.ServerName = s, server.ServerName); CreateTextBox("UUID", "UUID", s => true, s => server.UserID = s, server.UserID); diff --git a/Netch/Servers/VLESS/VLESS.cs b/Netch/Servers/VLESS/VLESSServer.cs similarity index 96% rename from Netch/Servers/VLESS/VLESS.cs rename to Netch/Servers/VLESS/VLESSServer.cs index c2d526ca..9e4d1217 100644 --- a/Netch/Servers/VLESS/VLESS.cs +++ b/Netch/Servers/VLESS/VLESSServer.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; namespace Netch.Servers { - public class VLESS : VMess + public class VLESSServer : VMessServer { public override string Type { get; } = "VLESS"; diff --git a/Netch/Servers/VLESS/VLESSUtil.cs b/Netch/Servers/VLESS/VLESSUtil.cs index 4c559d82..dbe245ce 100644 --- a/Netch/Servers/VLESS/VLESSUtil.cs +++ b/Netch/Servers/VLESS/VLESSUtil.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using Netch.Interfaces; using Netch.Models; -using Netch.Servers; namespace Netch.Servers { @@ -18,16 +17,16 @@ namespace Netch.Servers public string[] UriScheme { get; } = { "vless" }; - public Type ServerType { get; } = typeof(VLESS); + public Type ServerType { get; } = typeof(VLESSServer); public void Edit(Server s) { - new VLESSForm.VLESSForm((VLESS)s).ShowDialog(); + new VLESSForm((VLESSServer)s).ShowDialog(); } public void Create() { - new VLESSForm.VLESSForm().ShowDialog(); + new VLESSForm().ShowDialog(); } public string GetShareLink(Server s) diff --git a/Netch/Servers/VMess/Form/VMessForm.cs b/Netch/Servers/VMess/VMessForm.cs similarity index 93% rename from Netch/Servers/VMess/Form/VMessForm.cs rename to Netch/Servers/VMess/VMessForm.cs index 45a5277d..e11d90bb 100644 --- a/Netch/Servers/VMess/Form/VMessForm.cs +++ b/Netch/Servers/VMess/VMessForm.cs @@ -1,13 +1,13 @@ using System.Collections.Generic; using Netch.Forms; -namespace Netch.Servers.Form +namespace Netch.Servers { public class VMessForm : ServerForm { - public VMessForm(VMess? server = default) + public VMessForm(VMessServer? server = default) { - server ??= new VMess(); + server ??= new VMessServer(); Server = server; CreateTextBox("Sni", "ServerName(Sni)", s => true, s => server.ServerName = s, server.ServerName); CreateTextBox("UserId", "User ID", s => true, s => server.UserID = s, server.UserID); diff --git a/Netch/Servers/VMess/VMess.cs b/Netch/Servers/VMess/VMessServer.cs similarity index 99% rename from Netch/Servers/VMess/VMess.cs rename to Netch/Servers/VMess/VMessServer.cs index acea7548..11f060a9 100644 --- a/Netch/Servers/VMess/VMess.cs +++ b/Netch/Servers/VMess/VMessServer.cs @@ -3,7 +3,7 @@ using Netch.Models; namespace Netch.Servers { - public class VMess : Server + public class VMessServer : Server { private string _tlsSecureType = VMessGlobal.TLSSecure[0]; diff --git a/Netch/Servers/VMess/VMessUtil.cs b/Netch/Servers/VMess/VMessUtil.cs index 075426de..9738b64c 100644 --- a/Netch/Servers/VMess/VMessUtil.cs +++ b/Netch/Servers/VMess/VMessUtil.cs @@ -5,8 +5,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Netch.Interfaces; using Netch.Models; -using Netch.Servers.Form; -using Netch.Servers.Models; using Netch.Utils; namespace Netch.Servers @@ -23,11 +21,11 @@ namespace Netch.Servers public string[] UriScheme { get; } = { "vmess" }; - public Type ServerType { get; } = typeof(VMess); + public Type ServerType { get; } = typeof(VMessServer); public void Edit(Server s) { - new VMessForm((VMess)s).ShowDialog(); + new VMessForm((VMessServer)s).ShowDialog(); } public void Create() @@ -39,9 +37,9 @@ namespace Netch.Servers { if (Global.Settings.V2RayConfig.V2rayNShareLink) { - var server = (VMess)s; + var server = (VMessServer)s; - var vmessJson = JsonSerializer.Serialize(new V2rayNSharing + var vmessJson = JsonSerializer.Serialize(new V2rayNJObject { v = 2, ps = server.Remark, @@ -75,7 +73,7 @@ namespace Netch.Servers public IEnumerable ParseUri(string text) { - var data = new VMess(); + var data = new VMessServer(); string s; try @@ -87,7 +85,7 @@ namespace Netch.Servers return V2rayUtils.ParseVUri(text); } - V2rayNSharing vmess = JsonSerializer.Deserialize(s, + V2rayNJObject vmess = JsonSerializer.Deserialize(s, new JsonSerializerOptions { NumberHandling = JsonNumberHandling.WriteAsString | JsonNumberHandling.AllowReadingFromString })!; data.Remark = vmess.ps; diff --git a/Netch/Utils/Bandwidth.cs b/Netch/Utils/Bandwidth.cs index 943c88a7..9598340b 100644 --- a/Netch/Utils/Bandwidth.cs +++ b/Netch/Utils/Bandwidth.cs @@ -8,7 +8,6 @@ using Microsoft.Diagnostics.Tracing.Session; using Microsoft.VisualStudio.Threading; using Netch.Controllers; using Netch.Enums; -using Netch.Models; using Serilog; namespace Netch.Utils diff --git a/Netch/Utils/ShareLink.cs b/Netch/Utils/ShareLink.cs index cd7ef589..bb43aaaf 100644 --- a/Netch/Utils/ShareLink.cs +++ b/Netch/Utils/ShareLink.cs @@ -5,8 +5,7 @@ using System.Linq; using System.Text; using System.Text.Json; using Netch.Models; -using Netch.Servers.Shadowsocks; -using Netch.Servers.Shadowsocks.Models; +using Netch.Servers; using Serilog; namespace Netch.Utils @@ -33,7 +32,7 @@ namespace Netch.Utils try { - list.AddRange(JsonSerializer.Deserialize>(text)!.Select(server => new Shadowsocks + list.AddRange(JsonSerializer.Deserialize>(text)!.Select(server => new ShadowsocksServer { Hostname = server.server, Port = server.server_port,