diff --git a/go.mod b/go.mod index 9d827cf1..bf6ae2e7 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/rs/xid v1.2.1 github.com/sirupsen/logrus v1.9.0 github.com/stretchr/testify v1.8.0 - github.com/stripe/goproxy v0.0.0-20231113215313-dbbdf2f6d709 + github.com/stripe/goproxy v0.0.0-20231206175114-560c3ba6a2a1 golang.org/x/net v0.17.0 gopkg.in/urfave/cli.v1 v1.20.0 gopkg.in/yaml.v2 v2.4.0 diff --git a/go.sum b/go.sum index 9b9026be..cbc844ae 100644 --- a/go.sum +++ b/go.sum @@ -220,6 +220,8 @@ github.com/stripe/goproxy v0.0.0-20230801191332-fabc3ecb7251 h1:wR1exp7OglR0ctk8 github.com/stripe/goproxy v0.0.0-20230801191332-fabc3ecb7251/go.mod h1:hF2CVgH4++5ijZiy9grGVP8Fsi4u+SMOtbnIKYbMUjY= github.com/stripe/goproxy v0.0.0-20231113215313-dbbdf2f6d709 h1:b0AttHAJ5f9rIK2frq9Q4WEeeBNQccr1j+cjQCmOl6s= github.com/stripe/goproxy v0.0.0-20231113215313-dbbdf2f6d709/go.mod h1:hF2CVgH4++5ijZiy9grGVP8Fsi4u+SMOtbnIKYbMUjY= +github.com/stripe/goproxy v0.0.0-20231206175114-560c3ba6a2a1 h1:kA8wVCrTI7UE2Z8oj24W75/J+IUA/fFn8vYYXs/sJeE= +github.com/stripe/goproxy v0.0.0-20231206175114-560c3ba6a2a1/go.mod h1:hF2CVgH4++5ijZiy9grGVP8Fsi4u+SMOtbnIKYbMUjY= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/vendor/github.com/stripe/goproxy/https.go b/vendor/github.com/stripe/goproxy/https.go index 3908e580..332618b1 100644 --- a/vendor/github.com/stripe/goproxy/https.go +++ b/vendor/github.com/stripe/goproxy/https.go @@ -33,11 +33,12 @@ const ( ) var ( - OkConnect = &ConnectAction{Action: ConnectAccept, TLSConfig: TLSConfigFromCA(&GoproxyCa)} - MitmConnect = &ConnectAction{Action: ConnectMitm, TLSConfig: TLSConfigFromCA(&GoproxyCa)} - HTTPMitmConnect = &ConnectAction{Action: ConnectHTTPMitm, TLSConfig: TLSConfigFromCA(&GoproxyCa)} - RejectConnect = &ConnectAction{Action: ConnectReject, TLSConfig: TLSConfigFromCA(&GoproxyCa)} - httpsRegexp = regexp.MustCompile(`^https:\/\/`) + OkConnect = &ConnectAction{Action: ConnectAccept, TLSConfig: TLSConfigFromCA(&GoproxyCa)} + MitmConnect = &ConnectAction{Action: ConnectMitm, TLSConfig: TLSConfigFromCA(&GoproxyCa)} + HTTPMitmConnect = &ConnectAction{Action: ConnectHTTPMitm, TLSConfig: TLSConfigFromCA(&GoproxyCa)} + RejectConnect = &ConnectAction{Action: ConnectReject, TLSConfig: TLSConfigFromCA(&GoproxyCa)} + httpsRegexp = regexp.MustCompile(`^https:\/\/`) + PerRequestHTTPSProxyHeaderKey = "X-Upstream-Https-Proxy" ) type ConnectAction struct { @@ -84,8 +85,8 @@ func (proxy *ProxyHttpServer) connectDialContext(ctx *ProxyCtx, network, addr st } func (proxy *ProxyHttpServer) handleHttps(w http.ResponseWriter, r *http.Request) { - ctx := &ProxyCtx{Req: r, Session: atomic.AddInt64(&proxy.sess, 1), proxy: proxy} + ctx := &ProxyCtx{Req: r, Session: atomic.AddInt64(&proxy.sess, 1), proxy: proxy} hij, ok := w.(http.Hijacker) if !ok { panic("httpserver does not support hijacking") @@ -118,7 +119,12 @@ func (proxy *ProxyHttpServer) handleHttps(w http.ResponseWriter, r *http.Request host += ":80" } - httpsProxy, err := httpsProxyAddr(r.URL, proxy.HttpsProxyAddr) + var httpsProxyURL string = proxy.HttpsProxyAddr + if r.Header.Get(PerRequestHTTPSProxyHeaderKey) != "" { + httpsProxyURL = r.Header.Get(PerRequestHTTPSProxyHeaderKey) + } + + httpsProxy, err := httpsProxyAddr(r.URL, httpsProxyURL) if err != nil { ctx.Warnf("Error configuring HTTPS proxy err=%q url=%q", err, r.URL.String()) } @@ -565,7 +571,7 @@ func (proxy *ProxyHttpServer) connectDialProxyWithContext(ctx *ProxyCtx, proxyHo return c, nil } -// httpsProxyAddr function uses the address in httpsProxy parameter. +// httpsProxyAddr function uses the address in httpsProxy parameter. // When the httpProxyAddr parameter is empty, uses the HTTPS_PROXY, https_proxy from environment variables. // httpsProxyAddr function allows goproxy to respect no_proxy env vars // https://github.com/stripe/goproxy/pull/5 diff --git a/vendor/modules.txt b/vendor/modules.txt index 496fab7d..88268885 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -69,7 +69,7 @@ github.com/sirupsen/logrus/hooks/test ## explicit; go 1.13 github.com/stretchr/testify/assert github.com/stretchr/testify/require -# github.com/stripe/goproxy v0.0.0-20231113215313-dbbdf2f6d709 +# github.com/stripe/goproxy v0.0.0-20231206175114-560c3ba6a2a1 ## explicit; go 1.13 github.com/stripe/goproxy # golang.org/x/mod v0.8.0