From ff6c4b44022c501c31de52f20c92951516bba957 Mon Sep 17 00:00:00 2001 From: Adam Fisk Date: Tue, 10 Dec 2024 12:01:54 -0700 Subject: [PATCH] clearer naming --- front.go | 6 +++--- fronted.go | 14 +++++++------- fronted_test.go | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/front.go b/front.go index 4e50404..57b36bc 100644 --- a/front.go +++ b/front.go @@ -70,7 +70,7 @@ type Front interface { setLastSucceeded(time.Time) - postCheck(net.Conn, string) bool + verifyWithPost(net.Conn, string) bool getProviderID() string @@ -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), } diff --git a/fronted.go b/fronted.go index 2082fd7..da6c00d 100644 --- a/fronted.go +++ b/fronted.go @@ -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 @@ -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 @@ -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 } @@ -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 { @@ -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) { diff --git a/fronted_test.go b/fronted_test.go index 2ac5fb0..63fc810 100644 --- a/fronted_test.go +++ b/fronted_test.go @@ -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 }