fix: inner http use host of address

This commit is contained in:
Skyxim 2023-03-29 20:50:46 +08:00
parent 7c80c88feb
commit db7623968d
2 changed files with 3 additions and 1 deletions

View File

@ -42,6 +42,8 @@ func NewInner(conn net.Conn, dst string, host string) *context.ConnContext {
if host == "" { if host == "" {
if ip, err := netip.ParseAddr(h); err == nil { if ip, err := netip.ParseAddr(h); err == nil {
metadata.DstIP = ip metadata.DstIP = ip
} else {
metadata.Host = h
} }
} }
} }

View File

@ -53,7 +53,7 @@ func HttpRequest(ctx context.Context, url, method string, header map[string][]st
TLSHandshakeTimeout: 10 * time.Second, TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second, ExpectContinueTimeout: 1 * time.Second,
DialContext: func(ctx context.Context, network, address string) (net.Conn, error) { DialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
conn := inner.HandleTcp(address, urlRes.Hostname()) conn := inner.HandleTcp(address, "")
return conn, nil return conn, nil
}, },
TLSClientConfig: tls.GetDefaultTLSConfig(), TLSClientConfig: tls.GetDefaultTLSConfig(),