commit 0ce83d41aae57636d92b7b0cf34e9723a3fb4e9e Author: David Fifield david@bamsoftware.com Date: Wed Feb 6 16:18:04 2019 -0700
Factor out selfSignedTLSListen. --- meek-client/proxy_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/meek-client/proxy_test.go b/meek-client/proxy_test.go index 555e620..b44c9a2 100644 --- a/meek-client/proxy_test.go +++ b/meek-client/proxy_test.go @@ -176,9 +176,9 @@ func TestProxyHTTPProxyAuthorization(t *testing.T) { } }
-func requestResultingFromDialHTTPS(t *testing.T, makeProxy func(addr net.Addr) (*httpProxy, error), network, addr string) (*http.Request, error) { - // Create a TLS listener using a temporary self-signed certificate. - // https://golang.org/src/crypto/tls/generate_cert.go +// Create a TLS listener using a temporary self-signed certificate. +// https://golang.org/src/crypto/tls/generate_cert.go +func selfSignedTLSListen(network, addr string) (net.Listener, error) { priv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) if err != nil { return nil, err @@ -212,7 +212,11 @@ func requestResultingFromDialHTTPS(t *testing.T, makeProxy func(addr net.Addr) ( }, }
- ln, err := tls.Listen("tcp", "127.0.0.1:0", &config) + return tls.Listen(network, addr, &config) +} + +func requestResultingFromDialHTTPS(t *testing.T, makeProxy func(addr net.Addr) (*httpProxy, error), network, addr string) (*http.Request, error) { + ln, err := selfSignedTLSListen("tcp", "127.0.0.1:0") if err != nil { return nil, err }
tor-commits@lists.torproject.org