diff --git a/http.go b/http.go index 8c59ad8..bcf86de 100644 --- a/http.go +++ b/http.go @@ -52,6 +52,7 @@ func (c *httpConnector) ConnectContext(ctx context.Context, conn net.Conn, netwo ua = DefaultUserAgent } + origAddress := address if opts.Host != "" { address = opts.Host } @@ -70,6 +71,10 @@ func (c *httpConnector) ConnectContext(ctx context.Context, conn net.Conn, netwo req.Header.Set("User-Agent", ua) req.Header.Set("Proxy-Connection", "keep-alive") + if origAddress != address { + req.Header.Set("Target", origAddress) + } + user := opts.User if user == nil { user = c.User @@ -163,6 +168,10 @@ func (h *httpHandler) handleRequest(conn net.Conn, req *http.Request) { } host := req.Host + actualTarget := req.Header.Get("Target") + if actualTarget != "" { + host = actualTarget + } if _, port, _ := net.SplitHostPort(host); port == "" { host = net.JoinHostPort(host, "80") } @@ -180,6 +189,7 @@ func (h *httpHandler) handleRequest(conn net.Conn, req *http.Request) { } req.Header.Del("Gost-Target") + req.Header.Del("Target") resp := &http.Response{ ProtoMajor: 1,