From b82e857edd041798bd303f1bbd6309dcabe81acc Mon Sep 17 00:00:00 2001 From: autumn Date: Tue, 29 Jun 2021 18:43:15 +0800 Subject: [PATCH] update grpc settings --- .../Models/Projects/XraySettings.cs | 1 + ProxySuper.Core/Services/XrayConfigBuilder.cs | 13 +----------- ProxySuper.WPF/ProxySuper.WPF.csproj | 3 --- .../Templates/xray/caddy/grpc.caddyfile | 10 --------- .../xray/server/05_inbounds/VLESS_gRPC.json | 21 +++++++++++++++---- ProxySuper.WPF/Views/XrayConfigView.xaml | 4 ++-- 6 files changed, 21 insertions(+), 31 deletions(-) delete mode 100644 ProxySuper.WPF/Templates/xray/caddy/grpc.caddyfile diff --git a/ProxySuper.Core/Models/Projects/XraySettings.cs b/ProxySuper.Core/Models/Projects/XraySettings.cs index f554109..3aa5ed0 100644 --- a/ProxySuper.Core/Models/Projects/XraySettings.cs +++ b/ProxySuper.Core/Models/Projects/XraySettings.cs @@ -47,6 +47,7 @@ namespace ProxySuper.Core.Models.Projects VLESS_KCP_Port, VMESS_KCP_Port, ShadowSocksPort, + VLESS_gRPC_Port, }; } } diff --git a/ProxySuper.Core/Services/XrayConfigBuilder.cs b/ProxySuper.Core/Services/XrayConfigBuilder.cs index e2e0144..1f4759d 100644 --- a/ProxySuper.Core/Services/XrayConfigBuilder.cs +++ b/ProxySuper.Core/Services/XrayConfigBuilder.cs @@ -94,18 +94,6 @@ namespace ProxySuper.Core.Services caddyStr = caddyStr.Replace("##reverse_proxy##", ""); } - if (parameters.Types.Contains(XrayType.VLESS_gRPC)) - { - var grpcCaddyfile = File.ReadAllText(Path.Combine(CaddyFileDir, "grpc.caddyfile")); - grpcCaddyfile = grpcCaddyfile.Replace("##domain##", parameters.Domain); - grpcCaddyfile = grpcCaddyfile.Replace("##port##", parameters.VLESS_gRPC_Port.ToString()); - grpcCaddyfile = grpcCaddyfile.Replace("##local_port##", VLESS_gRPC_Port.ToString()); - grpcCaddyfile = grpcCaddyfile.Replace("##path##", parameters.VLESS_gRPC_ServiceName); - - caddyStr += "\n"; - caddyStr += grpcCaddyfile; - } - return caddyStr; } @@ -142,6 +130,7 @@ namespace ProxySuper.Core.Services gRPCInBound.port = VLESS_gRPC_Port; gRPCInBound.settings.clients[0].id = parameters.UUID; gRPCInBound.streamSettings.grpcSettings.serviceName = parameters.VLESS_gRPC_ServiceName; + gRPCInBound.streamSettings.tlsSettings.serverName = parameters.Domain; xrayConfig.inbounds.Add(JToken.FromObject(gRPCInBound)); } diff --git a/ProxySuper.WPF/ProxySuper.WPF.csproj b/ProxySuper.WPF/ProxySuper.WPF.csproj index bc3599d..274b1e9 100644 --- a/ProxySuper.WPF/ProxySuper.WPF.csproj +++ b/ProxySuper.WPF/ProxySuper.WPF.csproj @@ -303,9 +303,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest diff --git a/ProxySuper.WPF/Templates/xray/caddy/grpc.caddyfile b/ProxySuper.WPF/Templates/xray/caddy/grpc.caddyfile deleted file mode 100644 index 16f10cb..0000000 --- a/ProxySuper.WPF/Templates/xray/caddy/grpc.caddyfile +++ /dev/null @@ -1,10 +0,0 @@ -##domain##:##port## { - @grpc { - protocol grpc - path ##path## - } - - reverse_proxy @grpc h2c://127.0.0.1:##local_port## - root * /var/www - file_server -} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_gRPC.json b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_gRPC.json index 0a8525c..bab4d21 100644 --- a/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_gRPC.json +++ b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_gRPC.json @@ -1,6 +1,6 @@ { - "port": 2003, - "listen": "127.0.0.1", + "port": 2002, + "listen": "0.0.0.0", "protocol": "vless", "settings": { "clients": [ @@ -11,9 +11,22 @@ "decryption": "none" }, "streamSettings": { - "network": "grpc", + "network": "gun", + "security": "tls", + "tlsSettings": { + "serverName": "domain", + "alpn": [ + "h2" + ], + "certificates": [ + { + "certificateFile": "/usr/local/etc/xray/ssl/xray_ssl.crt", + "keyFile": "/usr/local/etc/xray/ssl/xray_ssl.key" + } + ] + }, "grpcSettings": { - "serviceName": "" + "serviceName": "service_name" } } } diff --git a/ProxySuper.WPF/Views/XrayConfigView.xaml b/ProxySuper.WPF/Views/XrayConfigView.xaml index 477b730..b594416 100644 --- a/ProxySuper.WPF/Views/XrayConfigView.xaml +++ b/ProxySuper.WPF/Views/XrayConfigView.xaml @@ -51,12 +51,12 @@ - +