Skip to content

Commit

Permalink
clearer naming
Browse files Browse the repository at this point in the history
  • Loading branch information
myleshorton committed Dec 10, 2024
1 parent 72225de commit ff6c4b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions front.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type Front interface {

setLastSucceeded(time.Time)

postCheck(net.Conn, string) bool
verifyWithPost(net.Conn, string) bool

getProviderID() string

Expand Down Expand Up @@ -121,8 +121,8 @@ func (m *front) dial(rootCAs *x509.CertPool, clientHelloID tls.ClientHelloID) (n
return dialer.Dial("tcp", addr)
}

// postCheck does a post with invalid data to verify domain-fronting works
func (m *front) postCheck(conn net.Conn, testURL string) bool {
// verifyWithPost does a post with invalid data to verify domain-fronting works
func (m *front) verifyWithPost(conn net.Conn, testURL string) bool {
client := &http.Client{
Transport: frontedHTTPTransport(conn, true),
}
Expand Down
14 changes: 7 additions & 7 deletions fronted.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func Vet(m *Masquerade, pool *x509.CertPool, testURL string) bool {
return false
}
defer conn.Close()
return masq.postCheck(conn, testURL)
return masq.verifyWithPost(conn, testURL)
}

// findWorkingFronts finds working domain fronts by testing them using a worker pool. Speed
Expand Down Expand Up @@ -286,7 +286,7 @@ func (f *fronted) frontAt(i int) Front {
}

func (f *fronted) vetFront(m Front) bool {
conn, masqueradeGood, err := f.dialFront(m)
conn, markWithResult, err := f.dialFront(m)
if err != nil {
log.Debugf("unexpected error vetting masquerades: %v", err)
return false
Expand All @@ -303,7 +303,7 @@ func (f *fronted) vetFront(m Front) bool {
m.getProviderID(), f.providers)
return false
}
if !masqueradeGood(m.postCheck(conn, provider.TestURL)) {
if !markWithResult(m.verifyWithPost(conn, provider.TestURL)) {
log.Debugf("Unsuccessful vetting with POST request, discarding masquerade")
return false
}
Expand Down Expand Up @@ -450,7 +450,7 @@ func (f *fronted) dialFront(m Front) (net.Conn, func(bool) bool, error) {
// we expect.
start := time.Now()
conn, retriable, err := f.doDial(m)
masqueradeGood := func(good bool) bool {
markWithResult := func(good bool) bool {
if good {
m.markSucceeded()
} else {
Expand All @@ -461,12 +461,12 @@ func (f *fronted) dialFront(m Front) (net.Conn, func(bool) bool, error) {
}
if err == nil {
log.Debugf("Returning connection for masquerade %v in %v", m.getIpAddress(), time.Since(start))
return conn, masqueradeGood, err
return conn, markWithResult, err
} else if !retriable {
log.Debugf("Dropping masquerade: non retryable error: %v", err)
masqueradeGood(false)
markWithResult(false)
}
return conn, masqueradeGood, err
return conn, markWithResult, err
}

func (f *fronted) doDial(m Front) (net.Conn, bool, error) {
Expand Down
4 changes: 2 additions & 2 deletions fronted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -963,8 +963,8 @@ func (m *mockFront) isSucceeding() bool {
return m.lastSucceededTime.After(time.Time{})
}

// postCheck implements MasqueradeInterface.
func (m *mockFront) postCheck(net.Conn, string) bool {
// verifyWithPost implements MasqueradeInterface.
func (m *mockFront) verifyWithPost(net.Conn, string) bool {
return m.passesCheck
}

Expand Down

0 comments on commit ff6c4b4

Please sign in to comment.