From 6b8c7dcd725bb6cd72b1d963a17182b9dae536bb Mon Sep 17 00:00:00 2001 From: Patrick Spieker Date: Tue, 2 Jul 2024 15:42:41 -0700 Subject: [PATCH] Removed debug --- go.mod | 2 +- go.sum | 2 ++ pkg/smokescreen/smokescreen.go | 19 ------------------- vendor/github.com/stripe/goproxy/https.go | 13 +++++++++++-- vendor/modules.txt | 2 +- 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/go.mod b/go.mod index 30e7b922..dab332ee 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-20231206175114-560c3ba6a2a1 + github.com/stripe/goproxy v0.0.0-20240702223215-529f11a6f861 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 1ccbe84f..c19a9ba5 100644 --- a/go.sum +++ b/go.sum @@ -218,6 +218,8 @@ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PK github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= 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/stripe/goproxy v0.0.0-20240702223215-529f11a6f861 h1:dlR0X8/38L9ip1ydDazfTRyPe0iW6cepmIcaygH2r5Q= +github.com/stripe/goproxy v0.0.0-20240702223215-529f11a6f861/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/pkg/smokescreen/smokescreen.go b/pkg/smokescreen/smokescreen.go index c9ccf000..c04b23a6 100644 --- a/pkg/smokescreen/smokescreen.go +++ b/pkg/smokescreen/smokescreen.go @@ -348,10 +348,6 @@ func rejectResponse(pctx *goproxy.ProxyCtx, err error) *http.Response { var msg, status string var code int - fmt.Println("**********") - fmt.Println(pctx.Resp) - fmt.Println(err) - fmt.Println("**********") if e, ok := err.(net.Error); ok { // net.Dial timeout if e.Timeout() { @@ -524,8 +520,6 @@ func BuildProxy(config *Config) *goproxy.ProxyHttpServer { pctx.Resp = rejectResponse(pctx, err) return goproxy.RejectConnect, "" } - fmt.Println("-----MADE IT HERE--------------") - return goproxy.OkConnect, destination }) @@ -553,9 +547,6 @@ func BuildProxy(config *Config) *goproxy.ProxyHttpServer { sctx.cfg.AcceptResponseHandler(sctx, resp) } } - fmt.Println("-----------------------------") - fmt.Println(pctx.Error) - fmt.Println("-----------------------------") if resp == nil && pctx.Error != nil { return rejectResponse(pctx, pctx.Error) @@ -951,13 +942,6 @@ func checkACLsForRequest(config *Config, req *http.Request, destination hostport if connectProxyHost != "" { connectProxyUrl, err := url.Parse(connectProxyHost) - config.Log.WithFields(logrus.Fields{ - "headers": req.Header, - "upstream_proxy_name": req.Header.Get("X-Upstream-Https-Proxy"), - "destination_host": destination.Host, - "proxy_host": connectProxyUrl.Hostname(), - }).Info("Info about the headers and destination host.") - if err != nil { config.Log.WithFields(logrus.Fields{ "error": err, @@ -974,9 +958,6 @@ func checkACLsForRequest(config *Config, req *http.Request, destination hostport connectProxyHost = connectProxyUrl.Hostname() } - // TODO: add proxy auth params fi if the decision is to allow the request - // this will likely mean modifying the config struct - ACLDecision, err := config.EgressACL.Decide(role, destination.Host, connectProxyHost) decision.project = ACLDecision.Project decision.reason = ACLDecision.Reason diff --git a/vendor/github.com/stripe/goproxy/https.go b/vendor/github.com/stripe/goproxy/https.go index 332618b1..3a100234 100644 --- a/vendor/github.com/stripe/goproxy/https.go +++ b/vendor/github.com/stripe/goproxy/https.go @@ -5,6 +5,7 @@ import ( "bytes" "context" "crypto/tls" + "encoding/base64" "errors" "fmt" "io" @@ -133,7 +134,7 @@ func (proxy *ProxyHttpServer) handleHttps(w http.ResponseWriter, r *http.Request if httpsProxy == "" { targetSiteCon, err = proxy.connectDialContext(ctx, "tcp", host) } else { - targetSiteCon, err = proxy.connectDialProxyWithContext(ctx, httpsProxy, host) + targetSiteCon, err = proxy.connectDialProxyWithContext(ctx, httpsProxyURL, host) } if err != nil { httpError(proxyClient, ctx, err) @@ -543,11 +544,19 @@ func (proxy *ProxyHttpServer) connectDialProxyWithContext(ctx *ProxyCtx, proxyHo c = tls.Client(c, proxy.Tr.TLSClientConfig) } + hdr := make(http.Header) + + // Add proxy authentication header if needed + auth := proxyURL.User.String() + if auth != "" { + hdr.Add("Proxy-Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(auth))) + } + connectReq := &http.Request{ Method: "CONNECT", URL: &url.URL{Opaque: host}, Host: host, - Header: make(http.Header), + Header: hdr, } connectReq.Write(c) // Read response. diff --git a/vendor/modules.txt b/vendor/modules.txt index ff70febd..4c22727e 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-20231206175114-560c3ba6a2a1 +# github.com/stripe/goproxy v0.0.0-20240702223215-529f11a6f861 ## explicit; go 1.13 github.com/stripe/goproxy # golang.org/x/mod v0.8.0