From 66b719139420ac554f6ca8154bcaa3722160bb8a Mon Sep 17 00:00:00 2001 From: next-autumn Date: Wed, 17 Mar 2021 19:36:35 +0800 Subject: [PATCH] add new protocol --- .../Models/Developers/ConfigBuilder.cs | 38 +++++++++++-- ProxySU_Core/Models/XraySettings.cs | 56 +++++++++++++++++-- ProxySU_Core/ProxySU_Core.csproj | 12 ++++ .../server/05_inbounds/Trojan_TCP_TLS.json | 4 +- .../server/05_inbounds/Trojan_WS_TLS.json | 4 +- .../server/05_inbounds/VLESS_HTTP2_TLS.json | 19 +++++++ .../server/05_inbounds/VLESS_TCP_XTLS.json | 8 +-- .../xray/server/05_inbounds/VLESS_WS_TLS.json | 4 +- .../xray/server/05_inbounds/VLESS_mKCP.json | 24 ++++++++ .../server/05_inbounds/VMESS_HTTP2_TLS.json | 18 ++++++ .../server/05_inbounds/VMESS_TCP_TLS.json | 4 +- .../xray/server/05_inbounds/VMESS_WS_TLS.json | 4 +- .../xray/server/05_inbounds/VMESS_mKCP.json | 24 ++++++++ 13 files changed, 188 insertions(+), 31 deletions(-) create mode 100644 ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_HTTP2_TLS.json create mode 100644 ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_mKCP.json create mode 100644 ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_HTTP2_TLS.json create mode 100644 ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_mKCP.json diff --git a/ProxySU_Core/Models/Developers/ConfigBuilder.cs b/ProxySU_Core/Models/Developers/ConfigBuilder.cs index c7e8723..78bb2d8 100644 --- a/ProxySU_Core/Models/Developers/ConfigBuilder.cs +++ b/ProxySU_Core/Models/Developers/ConfigBuilder.cs @@ -27,9 +27,16 @@ namespace ProxySU_Core.Models.Developers public const int VLESS_TCP_Port = 1110; public const int VLESS_WS_Port = 1111; + public const int VLESS_H2_Port = 1112; + public const int VLESS_mKCP_Port = 1113; + public const int VMESS_TCP_Port = 2110; public const int VMESS_WS_Port = 2111; + public const int VMESS_H2_Port = 2112; + public const int VMESS_mKCP_Port = 2113; + public const int Trojan_TCP_Port = 3110; + public const int Trojan_WS_Port = 3111; public static dynamic LoadXrayConfig() @@ -92,8 +99,7 @@ namespace ProxySU_Core.Models.Developers baseBound.port = parameters.Port; baseBound.settings.fallbacks.Add(JToken.FromObject(new { - dest = 80, - xver = 1, + dest = 80 })); xrayConfig.inbounds.Add(baseBound); baseBound.settings.clients[0].id = parameters.UUID; @@ -107,12 +113,30 @@ namespace ProxySU_Core.Models.Developers baseBound.settings.fallbacks.Add(JToken.FromObject(new { dest = VLESS_WS_Port, - path = parameters.VLESS_WS_Path, - xver = 1, + path = parameters.VLESS_WS_Path })); 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 + })); + xrayConfig.inbounds.Add(JToken.FromObject(h2Inbound)); + } + + if (parameters.Types.Contains(XrayType.VLESS_mKCP_Speed)) + { + var kcpInbound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VLESS_mKCP")); + } + if (parameters.Types.Contains(XrayType.VMESS_TCP_TLS)) { var mtcpBound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VMESS_TCP_TLS.json")); @@ -143,6 +167,10 @@ namespace ProxySU_Core.Models.Developers xrayConfig.inbounds.Add(JToken.FromObject(mwsBound)); } + if (parameters.Types.Contains(XrayType.VMESS_H2_TLS)) { } + + if (parameters.Types.Contains(XrayType.VMESS_mKCP_Speed)) { } + if (parameters.Types.Contains(XrayType.Trojan_TCP_TLS)) { var trojanTcpBound = LoadJsonObj(Path.Combine(ServerInboundsDir, "Trojan_TCP_TLS.json")); @@ -156,6 +184,8 @@ namespace ProxySU_Core.Models.Developers xrayConfig.inbounds.Add(JToken.FromObject(trojanTcpBound)); } + if (parameters.Types.Contains(XrayType.Trojan_WS_TLS)) { } + return JsonConvert.SerializeObject( xrayConfig, Formatting.Indented, diff --git a/ProxySU_Core/Models/XraySettings.cs b/ProxySU_Core/Models/XraySettings.cs index 36b914f..56dbda9 100644 --- a/ProxySU_Core/Models/XraySettings.cs +++ b/ProxySU_Core/Models/XraySettings.cs @@ -46,6 +46,16 @@ namespace ProxySU_Core.Models /// public string VLESS_TCP_Path { get; set; } + /// + /// vless http2 path + /// + public string VLESS_H2_Path { get; set; } + + /// + /// vless mKcp seed + /// + public string VLESS_mKCP_Seed { get; set; } + /// /// vmess ws路径 /// @@ -56,11 +66,26 @@ namespace ProxySU_Core.Models /// public string VMESS_TCP_Path { get; set; } + /// + /// vmess http2 path + /// + public string VMESS_HTTP2_Path { get; set; } + + /// + /// vmess mKcp seed + /// + public string VMESS_mKCP_Seed { get; set; } + /// /// trojan密码 /// public string TrojanPassword { get; set; } + /// + /// trojan ws path + /// + public string Trojan_WS_Path { get; set; } + /// /// 域名 /// @@ -87,11 +112,20 @@ namespace ProxySU_Core.Models return VLESS_TCP_Path; case XrayType.VLESS_WS_TLS: return VLESS_WS_Path; + case XrayType.VLESS_H2_TLS: + return VLESS_H2_Path; + case XrayType.VMESS_TCP_TLS: return VMESS_TCP_Path; case XrayType.VMESS_WS_TLS: return VMESS_WS_Path; + case XrayType.Trojan_WS_TLS: + return Trojan_WS_Path; + + // no path + case XrayType.VLESS_mKCP_Speed: case XrayType.Trojan_TCP_TLS: + case XrayType.VMESS_mKCP_Speed: return string.Empty; default: return string.Empty; @@ -103,13 +137,23 @@ namespace ProxySU_Core.Models public enum XrayType { - VLESS_TCP_TLS, - VLESS_TCP_XTLS, - VLESS_WS_TLS, + // 入口 + VLESS_TCP_XTLS = 100, - VMESS_TCP_TLS, - VMESS_WS_TLS, + // vless 101开头 + VLESS_TCP_TLS = 101, + VLESS_WS_TLS = 102, + VLESS_H2_TLS = 103, + VLESS_mKCP_Speed = 104, - Trojan_TCP_TLS, + // vmess 201开头 + VMESS_TCP_TLS = 201, + VMESS_WS_TLS = 202, + VMESS_H2_TLS = 203, + VMESS_mKCP_Speed = 204, + + // trojan 301开头 + Trojan_TCP_TLS = 301, + Trojan_WS_TLS = 302, } } diff --git a/ProxySU_Core/ProxySU_Core.csproj b/ProxySU_Core/ProxySU_Core.csproj index c7f9b9e..8de2020 100644 --- a/ProxySU_Core/ProxySU_Core.csproj +++ b/ProxySU_Core/ProxySU_Core.csproj @@ -244,12 +244,24 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_TCP_TLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_TCP_TLS.json index 0aca4d2..5f17571 100644 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_TCP_TLS.json +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_TCP_TLS.json @@ -5,9 +5,7 @@ "settings": { "clients": [ { - "password": "", - "level": 0, - "email": "love@example.com" + "password": "" } ], "fallbacks": [ diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_WS_TLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_WS_TLS.json index 229a245..51d725c 100644 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_WS_TLS.json +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_WS_TLS.json @@ -5,9 +5,7 @@ "settings": { "clients": [ { - "password": "", - "level": 0, - "email": "love@example.com" + "password": "" } ], "fallbacks": [ diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_HTTP2_TLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_HTTP2_TLS.json new file mode 100644 index 0000000..a99e848 --- /dev/null +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_HTTP2_TLS.json @@ -0,0 +1,19 @@ +{ + "port": 1234, + "listen": "127.0.0.1", + "protocol": "vmess", + "settings": { + "decryption": "none", + "clients": [ + { + "id": "" + } + ] + }, + "streamSettings": { + "network": "h2", + "httpSettings": { + "path": "" + } + } +} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json index 07a491a..d8cddd9 100644 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json @@ -5,9 +5,7 @@ "clients": [ { "id": "", - "flow": "xtls-rprx-direct", - "level": 0, - "email": "love@example.com" + "flow": "xtls-rprx-direct" } ], "decryption": "none", @@ -17,9 +15,7 @@ "network": "tcp", "security": "xtls", "xtlsSettings": { - "alpn": [ - "http/1.1" - ], + "alpn": [ "h2", "http/1.1" ], "certificates": [ { "certificateFile": "/usr/local/etc/xray/ssl/xray_ssl.crt", diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_WS_TLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_WS_TLS.json index 1b7d25c..0abf2e8 100644 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_WS_TLS.json +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_WS_TLS.json @@ -5,9 +5,7 @@ "settings": { "clients": [ { - "id": "", - "level": 0, - "email": "love@example.com" + "id": "" } ], "decryption": "none" diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_mKCP.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_mKCP.json new file mode 100644 index 0000000..77b6aba --- /dev/null +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_mKCP.json @@ -0,0 +1,24 @@ +{ + "port": 3456, + "listen": "127.0.0.1", + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "" + } + ] + }, + "streamSettings": { + "network": "mkcp", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, + "header": { + "type": "none" + }, + "seed": null + } + } +} diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_HTTP2_TLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_HTTP2_TLS.json new file mode 100644 index 0000000..9957e76 --- /dev/null +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_HTTP2_TLS.json @@ -0,0 +1,18 @@ +{ + "port": 1234, + "listen": "127.0.0.1", + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "" + } + ] + }, + "streamSettings": { + "network": "h2", + "httpSettings": { + "path": "" + } + } +} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_TCP_TLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_TCP_TLS.json index 2c569a8..b14181e 100644 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_TCP_TLS.json +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_TCP_TLS.json @@ -5,9 +5,7 @@ "settings": { "clients": [ { - "id": "", - "level": 0, - "email": "love@example.com" + "id": "" } ] }, diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_WS_TLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_WS_TLS.json index bbf6dbb..2e863a4 100644 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_WS_TLS.json +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_WS_TLS.json @@ -5,9 +5,7 @@ "settings": { "clients": [ { - "id": "", - "level": 0, - "email": "love@example.com" + "id": "" } ] }, diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_mKCP.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_mKCP.json new file mode 100644 index 0000000..63bcf27 --- /dev/null +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_mKCP.json @@ -0,0 +1,24 @@ +{ + "port": 3456, + "listen": "127.0.0.1", + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "" + } + ] + }, + "streamSettings": { + "network": "mkcp", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, + "header": { + "type": "none" + }, + "seed": null + } + } +}