Fix grpc lite request host

Co-authored-by: armv9 <48624112+arm64v8a@users.noreply.github.com>
This commit is contained in:
世界 2023-04-21 17:43:01 +08:00
parent e1d96cb64e
commit d686172854
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -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",
},