Skip to content

Commit

Permalink
chore(martian): move shouldTerminateTLS() to proxy_connect.go
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatczuk committed Sep 12, 2024
1 parent 73a96c2 commit a74f6d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 0 additions & 12 deletions internal/martian/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"net"
"net/http"
"net/url"
"strconv"
"sync"
"time"

Expand Down Expand Up @@ -319,17 +318,6 @@ func (p *Proxy) shouldMITM(req *http.Request) bool {
return true
}

const terminateTLSHeader = "X-Martian-Terminate-Tls"

func shouldTerminateTLS(req *http.Request) bool {
h := req.Header.Get(terminateTLSHeader)
if h == "" {
return false
}
b, _ := strconv.ParseBool(h)
return b
}

func (p *Proxy) fixRequestScheme(req *http.Request) {
if req.URL.Scheme == "" {
if proto := req.Header.Get("X-Forwarded-Proto"); proto != "" {
Expand Down
12 changes: 12 additions & 0 deletions internal/martian/proxy_connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"net"
"net/http"
"net/url"
"strconv"

"github.com/saucelabs/forwarder/dialvia"
"github.com/saucelabs/forwarder/internal/martian/log"
Expand Down Expand Up @@ -182,3 +183,14 @@ func newConnectResponse(req *http.Request) *http.Response {
Request: req,
}
}

const terminateTLSHeader = "X-Martian-Terminate-Tls"

func shouldTerminateTLS(req *http.Request) bool {
h := req.Header.Get(terminateTLSHeader)
if h == "" {
return false
}
b, _ := strconv.ParseBool(h)
return b
}

0 comments on commit a74f6d8

Please sign in to comment.