From d6861728545104a48e29cc2b5f8b6663411dcd8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Fri, 21 Apr 2023 17:43:01 +0800 Subject: [PATCH] Fix grpc lite request host Co-authored-by: armv9 <48624112+arm64v8a@users.noreply.github.com> --- transport/v2raygrpclite/client.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/transport/v2raygrpclite/client.go b/transport/v2raygrpclite/client.go index a6120c89..acf83abc 100644 --- a/transport/v2raygrpclite/client.go +++ b/transport/v2raygrpclite/client.go @@ -36,6 +36,12 @@ type Client struct { } func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, options option.V2RayGRPCOptions, tlsConfig tls.Config) adapter.V2RayClientTransport { + var host string + if tlsConfig != nil && tlsConfig.ServerName() != "" { + host = M.ParseSocksaddrHostPort(tlsConfig.ServerName(), serverAddr.Port).String() + } else { + host = serverAddr.String() + } client := &Client{ ctx: ctx, dialer: dialer, @@ -48,7 +54,7 @@ func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, opt }, url: &url.URL{ Scheme: "https", - Host: serverAddr.String(), + Host: host, Path: "/" + options.ServiceName + "/Tun", RawPath: "/" + url.PathEscape(options.ServiceName) + "/Tun", },