From 6d1d45e945edf2e25e1673371cd5a8365ddd79b1 Mon Sep 17 00:00:00 2001 From: next-autumn Date: Sat, 27 Mar 2021 11:47:02 +0800 Subject: [PATCH] submit kcp ss. --- .../Models/Developers/ConfigBuilder.cs | 54 ++++++---- ProxySU_Core/Models/ShareLink.cs | 25 ++++- ProxySU_Core/ProxySU_Core.csproj | 4 +- .../server/05_inbounds/Shadowsocks-AEAD.json | 2 +- .../xray/server/05_inbounds/VLESS_KCP.json | 1 - .../xray/server/05_inbounds/VMESS_KCP.json | 1 - .../ViewModels/XraySettingsViewModel.cs | 5 +- ProxySU_Core/Views/ClientInfoWindow.xaml | 101 ++++++++++++++++-- 8 files changed, 156 insertions(+), 37 deletions(-) diff --git a/ProxySU_Core/Models/Developers/ConfigBuilder.cs b/ProxySU_Core/Models/Developers/ConfigBuilder.cs index 1f7bcee..fdd6425 100644 --- a/ProxySU_Core/Models/Developers/ConfigBuilder.cs +++ b/ProxySU_Core/Models/Developers/ConfigBuilder.cs @@ -38,6 +38,8 @@ namespace ProxySU_Core.Models.Developers public const int Trojan_TCP_Port = 3110; public const int Trojan_WS_Port = 3111; + public const int ShadowSocksPort = 4110; + public static dynamic LoadXrayConfig() { @@ -95,7 +97,7 @@ namespace ProxySU_Core.Models.Developers public static string BuildXrayConfig(XraySettings parameters) { var xrayConfig = LoadXrayConfig(); - var baseBound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VLESS_TCP_XTLS.json")); + var baseBound = GetBound("VLESS_TCP_XTLS.json"); baseBound.port = parameters.Port; baseBound.settings.fallbacks.Add(JToken.FromObject(new { @@ -106,7 +108,7 @@ namespace ProxySU_Core.Models.Developers if (parameters.Types.Contains(XrayType.VLESS_WS)) { - var wsInbound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VLESS_WS_TLS.json")); + var wsInbound = GetBound("VLESS_WS.json"); wsInbound.port = VLESS_WS_Port; wsInbound.settings.clients[0].id = parameters.UUID; wsInbound.streamSettings.wsSettings.path = parameters.VLESS_WS_Path; @@ -119,26 +121,9 @@ namespace ProxySU_Core.Models.Developers xrayConfig.inbounds.Add(JToken.FromObject(wsInbound)); } - //if (parameters.Types.Contains(XrayType.VLESS_H2_TLS)) - //{ - // var h2Inbound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VLESS_HTTP2_TLS.json")); - // h2Inbound.port = VLESS_H2_Port; - // h2Inbound.settings.clients[0].id = parameters.UUID; - // h2Inbound.streamSettings.httpSettings.path = parameters.VLESS_H2_Path; - // baseBound.settings.fallbacks.Add(JToken.FromObject(new - // { - // dest = VLESS_H2_Port, - // path = parameters.VLESS_H2_Path, - // xver = 1, - // })); - // xrayConfig.inbounds.Add(JToken.FromObject(h2Inbound)); - //} - - - if (parameters.Types.Contains(XrayType.VMESS_TCP)) { - var mtcpBound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VMESS_TCP_TLS.json")); + var mtcpBound = GetBound("VMESS_TCP.json"); mtcpBound.port = VMESS_TCP_Port; mtcpBound.settings.clients[0].id = parameters.UUID; mtcpBound.streamSettings.tcpSettings.header.request.path = parameters.VMESS_TCP_Path; @@ -153,7 +138,7 @@ namespace ProxySU_Core.Models.Developers if (parameters.Types.Contains(XrayType.VMESS_WS)) { - var mwsBound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VMESS_WS_TLS.json")); + var mwsBound = GetBound("VMESS_WS.json"); mwsBound.port = VMESS_WS_Port; mwsBound.settings.clients[0].id = parameters.UUID; mwsBound.streamSettings.wsSettings.path = parameters.VMESS_WS_Path; @@ -168,7 +153,7 @@ namespace ProxySU_Core.Models.Developers if (parameters.Types.Contains(XrayType.Trojan_TCP)) { - var trojanTcpBound = LoadJsonObj(Path.Combine(ServerInboundsDir, "Trojan_TCP_TLS.json")); + var trojanTcpBound = GetBound("Trojan_TCP.json"); trojanTcpBound.port = Trojan_TCP_Port; trojanTcpBound.settings.clients[0].password = parameters.TrojanPassword; baseBound.settings.fallbacks[0] = JToken.FromObject(new @@ -179,7 +164,25 @@ namespace ProxySU_Core.Models.Developers xrayConfig.inbounds.Add(JToken.FromObject(trojanTcpBound)); } - if (parameters.Types.Contains(XrayType.Trojan_WS)) { } + if (parameters.Types.Contains(XrayType.VMESS_KCP)) + { + var kcpBound = GetBound("VMESS_KCP.json"); + kcpBound.port = VMESS_mKCP_Port; + kcpBound.settings.clients[0].id = parameters.UUID; + kcpBound.streamSettings.kcpSettings.header.type = parameters.VMESS_KCP_Type; + kcpBound.streamSettings.kcpSettings.seed = parameters.VMESS_KCP_Seed; + xrayConfig.inbounds.Add(JToken.FromObject(kcpBound)); + } + + + if (parameters.Types.Contains(XrayType.ShadowsocksAEAD)) + { + var ssBound = GetBound("Shadowsocks-AEAD.json"); + ssBound.port = ShadowSocksPort; + ssBound.settings.clients[0].password = parameters.ShadowsocksPassword; + ssBound.settings.clients[0].method = parameters.ShadowsocksMethod; + xrayConfig.inbounds.Add(JToken.FromObject(ssBound)); + } return JsonConvert.SerializeObject( xrayConfig, @@ -190,6 +193,11 @@ namespace ProxySU_Core.Models.Developers }); } + private static dynamic GetBound(string name) + { + return LoadJsonObj(Path.Combine(ServerInboundsDir, name)); + } + private static dynamic LoadJsonObj(string path) { if (File.Exists(path)) diff --git a/ProxySU_Core/Models/ShareLink.cs b/ProxySU_Core/Models/ShareLink.cs index 9283682..13a33be 100644 --- a/ProxySU_Core/Models/ShareLink.cs +++ b/ProxySU_Core/Models/ShareLink.cs @@ -1,5 +1,6 @@ using Newtonsoft.Json; using ProxySU_Core.Common; +using ProxySU_Core.Models.Developers; using System; using System.Collections.Generic; using System.Linq; @@ -13,6 +14,7 @@ namespace ProxySU_Core.Models { public static string Build(XrayType xrayType, XraySettings settings) { + switch (xrayType) { case XrayType.VLESS_TCP: @@ -22,12 +24,25 @@ namespace ProxySU_Core.Models return BuildVlessShareLink(xrayType, settings); case XrayType.VMESS_TCP: case XrayType.VMESS_WS: + case XrayType.VMESS_KCP: return BuildVmessShareLink(xrayType, settings); + case XrayType.ShadowsocksAEAD: + return BuildShadowSocksShareLink(settings); default: return string.Empty; } } + private static string BuildShadowSocksShareLink(XraySettings settings) + { + var _method = settings.ShadowsocksMethod; + var _password = settings.ShadowsocksPassword; + var _server = settings.Domain; + var _port = ConfigBuilder.ShadowSocksPort; + + var base64URL = Base64.Encode($"{_method}:{_password}@{_server}:{_port}"); + return "ss://" + base64URL; + } private static string BuildVmessShareLink(XrayType xrayType, XraySettings settings) { @@ -46,7 +61,6 @@ namespace ProxySU_Core.Models ps = "", }; - switch (xrayType) { case XrayType.VMESS_TCP: @@ -61,6 +75,14 @@ namespace ProxySU_Core.Models vmess.type = "none"; vmess.path = settings.VMESS_WS_Path; break; + case XrayType.VMESS_KCP: + vmess.ps = "vmess-mKCP"; + vmess.port = ConfigBuilder.VMESS_mKCP_Port.ToString(); + vmess.net = "kcp"; + vmess.type = settings.VMESS_KCP_Type; + vmess.path = settings.VMESS_KCP_Seed; + vmess.tls = ""; + break; default: return string.Empty; } @@ -120,6 +142,7 @@ namespace ProxySU_Core.Models break; case XrayType.Trojan_TCP: _protocol = "trojan"; + _uuid = settings.TrojanPassword; _descriptiveText = "trojan-tcp"; break; default: diff --git a/ProxySU_Core/ProxySU_Core.csproj b/ProxySU_Core/ProxySU_Core.csproj index 45af54e..b9a1d8e 100644 --- a/ProxySU_Core/ProxySU_Core.csproj +++ b/ProxySU_Core/ProxySU_Core.csproj @@ -243,7 +243,9 @@ PreserveNewest - + + PreserveNewest + PreserveNewest diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/Shadowsocks-AEAD.json b/ProxySU_Core/Templates/xray/server/05_inbounds/Shadowsocks-AEAD.json index 5b18d5c..e7179e5 100644 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/Shadowsocks-AEAD.json +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/Shadowsocks-AEAD.json @@ -4,7 +4,7 @@ "settings": { "clients": [ { - "password": "example_user_1", + "password": "", "method": "aes-128-gcm" } ], diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_KCP.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_KCP.json index 77b6aba..8421a45 100644 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_KCP.json +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_KCP.json @@ -1,6 +1,5 @@ { "port": 3456, - "listen": "127.0.0.1", "protocol": "vless", "settings": { "clients": [ diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_KCP.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_KCP.json index 63bcf27..0c3ea2b 100644 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_KCP.json +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_KCP.json @@ -1,6 +1,5 @@ { "port": 3456, - "listen": "127.0.0.1", "protocol": "vmess", "settings": { "clients": [ diff --git a/ProxySU_Core/ViewModels/XraySettingsViewModel.cs b/ProxySU_Core/ViewModels/XraySettingsViewModel.cs index 8525b34..eacf8ec 100644 --- a/ProxySU_Core/ViewModels/XraySettingsViewModel.cs +++ b/ProxySU_Core/ViewModels/XraySettingsViewModel.cs @@ -45,7 +45,6 @@ namespace ProxySU_Core.ViewModels set => settings.MaskDomain = value; } - public string TrojanPassword { get => settings.TrojanPassword; @@ -165,11 +164,11 @@ namespace ProxySU_Core.ViewModels get => settings.VMESS_WS_Path; set => settings.VMESS_WS_Path = value; } - public string VMESS_WS_TLS_ShareLink + public string VMESS_WS_ShareLink { get => ShareLink.Build(XrayType.VMESS_WS, settings); } - + // vmess kcp public string VMESS_KCP_Seed { diff --git a/ProxySU_Core/Views/ClientInfoWindow.xaml b/ProxySU_Core/Views/ClientInfoWindow.xaml index 251b01f..18ba595 100644 --- a/ProxySU_Core/Views/ClientInfoWindow.xaml +++ b/ProxySU_Core/Views/ClientInfoWindow.xaml @@ -5,8 +5,11 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls" xmlns:local="clr-namespace:ProxySU_Core.Views" + xmlns:dev="clr-namespace:ProxySU_Core.Models.Developers" mc:Ignorable="d" - Title="查看配置" Height="450" Width="800"> + Title="查看配置" Height="500" Width="800"> + +