Browse Source

Fix grpc lite request host

Co-authored-by: armv9 <[email protected]>
世界 2 years ago
parent
commit
d686172854
1 changed files with 7 additions and 1 deletions
  1. 7 1
      transport/v2raygrpclite/client.go

+ 7 - 1
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",
 		},