diff --git a/Netch/Controllers/MainController.cs b/Netch/Controllers/MainController.cs index b8e64c28..fbaf6cb1 100644 --- a/Netch/Controllers/MainController.cs +++ b/Netch/Controllers/MainController.cs @@ -57,7 +57,7 @@ public static class MainController // Start Server Controller to get a local socks5 server Log.Debug("Server Information: {Data}", $"{server.Type} {server.MaskedData()}"); - ServerController = ServerHelper.GetUtilByTypeName(server.Type).GetController(); + ServerController = V2rayController(); Global.MainForm.StatusText(i18N.TranslateFormat("Starting {0}", ServerController.Name)); TryReleaseTcpPort(ServerController.Socks5LocalPort(), "Socks5"); diff --git a/Netch/Servers/Shadowsocks/ShadowsocksServer.cs b/Netch/Servers/Shadowsocks/ShadowsocksServer.cs index ff4c9979..17d72e70 100644 --- a/Netch/Servers/Shadowsocks/ShadowsocksServer.cs +++ b/Netch/Servers/Shadowsocks/ShadowsocksServer.cs @@ -13,7 +13,7 @@ public class ShadowsocksServer : Server /// /// 加密方式 /// - public string EncryptMethod { get; set; } = SSGlobal.EncryptMethods[0]; + public string EncryptMethod { get; set; } = SSGlobal.EncryptMethods[4]; /// /// 密码 @@ -43,24 +43,44 @@ public static class SSGlobal /// public static readonly List EncryptMethods = new() { - "rc4-md5", - "aes-128-gcm", - "aes-192-gcm", - "aes-256-gcm", - "aes-128-cfb", - "aes-192-cfb", - "aes-256-cfb", - "aes-128-ctr", - "aes-192-ctr", - "aes-256-ctr", - "camellia-128-cfb", - "camellia-192-cfb", - "camellia-256-cfb", - "bf-cfb", - "chacha20-ietf-poly1305", - "xchacha20-ietf-poly1305", - "salsa20", - "chacha20", - "chacha20-ietf" + 'none', + '2022-blake3-aes-128-gcm', + '2022-blake3-aes-256-gcm', + '2022-blake3-chacha20-poly1305', + 'aes-128-gcm', + 'aes-192-gcm', + 'aes-256-gcm', + 'chacha20-ietf-poly1305', + 'xchacha20-ietf-poly1305', + 'rc4', + 'rc4-md5', + 'aes-128-ctr', + 'aes-192-ctr', + 'aes-256-ctr', + 'aes-128-cfb', + 'aes-192-cfb', + 'aes-256-cfb', + 'aes-128-cfb8', + 'aes-192-cfb8', + 'aes-256-cfb8', + 'aes-128-ofb', + 'aes-192-ofb', + 'aes-256-ofb', + 'bf-cfb', + 'cast5-cfb', + 'des-cfb', + 'idea-cfb', + 'rc2-cfb', + 'seed-cfb', + 'camellia-128-cfb', + 'camellia-192-cfb', + 'camellia-256-cfb', + 'camellia-128-cfb8', + 'camellia-192-cfb8', + 'camellia-256-cfb8', + 'salsa20', + 'chacha20', + 'chacha20-ietf', + 'xchacha20' }; } \ No newline at end of file diff --git a/Netch/Servers/ShadowsocksR/ShadowsocksRServer.cs b/Netch/Servers/ShadowsocksR/ShadowsocksRServer.cs index ba31f117..d1bd23bd 100644 --- a/Netch/Servers/ShadowsocksR/ShadowsocksRServer.cs +++ b/Netch/Servers/ShadowsocksR/ShadowsocksRServer.cs @@ -18,7 +18,7 @@ public class ShadowsocksRServer : Server /// /// 加密方式 /// - public string EncryptMethod { get; set; } = SSRGlobal.EncryptMethods[0]; + public string EncryptMethod { get; set; } = SSRGlobal.EncryptMethods[4]; /// /// 协议 @@ -49,11 +49,11 @@ public class SSRGlobal public static readonly List Protocols = new() { "origin", - "verify_deflate", "auth_sha1_v4", "auth_aes128_md5", "auth_aes128_sha1", - "auth_chain_a" + "auth_chain_a", + "auth_chain_b" }; /// @@ -64,36 +64,14 @@ public class SSRGlobal "plain", "http_simple", "http_post", - "tls1.2_ticket_auth" + "tls_simple", + "tls1.2_ticket_auth", + "tls1.2_ticket_fastauth", + "random_head" }; /// /// SS/SSR 加密方式 /// - public static readonly List EncryptMethods = new() - { - "none", - "table", - "rc4", - "rc4-md5", - "rc4-md5-6", - "aes-128-cfb", - "aes-192-cfb", - "aes-256-cfb", - "aes-128-ctr", - "aes-192-ctr", - "aes-256-ctr", - "bf-cfb", - "camellia-128-cfb", - "camellia-192-cfb", - "camellia-256-cfb", - "cast5-cfb", - "des-cfb", - "idea-cfb", - "rc2-cfb", - "seed-cfb", - "salsa20", - "chacha20", - "chacha20-ietf" - }; + public static readonly List EncryptMethods = SSGlobal.EncryptMethods; } \ No newline at end of file diff --git a/Netch/Servers/V2ray/V2rayConfig.cs b/Netch/Servers/V2ray/V2rayConfig.cs index a4350b9e..28fd1eec 100644 --- a/Netch/Servers/V2ray/V2rayConfig.cs +++ b/Netch/Servers/V2ray/V2rayConfig.cs @@ -29,9 +29,9 @@ public class Outbound public OutboundConfiguration settings { get; set; } - public StreamSettings streamSettings { get; set; } + public StreamSettings? streamSettings { get; set; } - public Mux mux { get; set; } + public Mux? mux { get; set; } } public class OutboundConfiguration @@ -41,6 +41,12 @@ public class OutboundConfiguration public object[] servers { get; set; } public string packetEncoding { get; set; } + + public string plugin { get; set; } + + public string pluginOpts { get; set; } + + public string[] pluginArgs { get; set; } } public class VnextItem @@ -52,6 +58,17 @@ public class VnextItem public User[] users { get; set; } } +public class ShadowsocksServerItem +{ + public string address { get; set; } + + public ushort port { get; set; } + + public string method { get; set; } + + public string password { get; set; } + } + public class Mux { public bool enabled { get; set; } diff --git a/Netch/Servers/V2ray/V2rayConfigUtils.cs b/Netch/Servers/V2ray/V2rayConfigUtils.cs index c223cff4..ac7db5f5 100644 --- a/Netch/Servers/V2ray/V2rayConfigUtils.cs +++ b/Netch/Servers/V2ray/V2rayConfigUtils.cs @@ -138,6 +138,62 @@ public static class V2rayConfigUtils outbound.mux.concurrency = vmess.UseMux ?? Global.Settings.V2RayConfig.UseMux ? 8 : -1; break; } + case ShadowsocksServer ss: + outbound.protocol = "shadowsocks"; + outbound.settings = new OutboundConfiguration + { + servers = new[] + { + new ShadowsocksServerItem + { + address = await server.AutoResolveHostnameAsync(), + port = server.Port, + method = ss.EncryptMethod, + password = ss.Password, + } + }, + plugin = ss.Plugin ?? "", + pluginOpts = ss.PluginOption ?? "" + } + break; + case ShadowsocksRServer ssr: + outbound.protocol = "shadowsocks"; + outbound.settings = new OutboundConfiguration + { + servers = new[] + { + new ShadowsocksServerItem + { + address = await server.AutoResolveHostnameAsync(), + port = server.Port, + method = ssr.EncryptMethod, + password = ssr.Password, + } + }, + plugin = "shadowsocksr", + pluginArgs = new string[] + { + "--obfs=" + ssr.OBFS, + "--obfs-param=" + ssr.OBFSParam ?? "", + "--protocol=" + ssr.Protocol, + "--protocol-param=" + ssr.ProtocolParam ?? "" + } + } + break; + case TrojanServer trojan: + outbound.protocol = "trojan_sing"; + outbound.settings.servers = new[] + { + new ShadowsocksServerItem // I'm not serious + { + address = await server.AutoResolveHostnameAsync(), + port = server.Port, + method = "", + password = trojan.Password + } + } + break; + } return outbound;