cleanup: use NewHTTPTransportWithResolver more often (#808)

We can simplify code in a bunch of places using a useful factory.

Part of https://github.com/ooni/probe/issues/2121.
This commit is contained in:
Simone Basso
2022-06-08 15:13:01 +02:00
committed by GitHub
parent f1b8071c65
commit beba543b98
3 changed files with 3 additions and 12 deletions
+1 -4
View File
@@ -86,10 +86,7 @@ func (c ipLookupClient) doWithCustomFunc(
// Implementation note: we MUST use an HTTP client that we're
// sure IS NOT using any proxy. To this end, we construct a
// client ourself that we know is not proxied.
dialer := netxlite.NewDialerWithResolver(c.Logger, c.Resolver)
handshaker := netxlite.NewTLSHandshakerStdlib(c.Logger)
tlsDialer := netxlite.NewTLSDialer(dialer, handshaker)
txp := netxlite.NewHTTPTransport(c.Logger, dialer, tlsDialer)
txp := netxlite.NewHTTPTransportWithResolver(c.Logger, c.Resolver)
clnt := &http.Client{Transport: txp}
defer clnt.CloseIdleConnections()
ip, err := fn(ctx, clnt, c.Logger, c.UserAgent)