diff --git a/internal/engine/geolocate/geolocate.go b/internal/engine/geolocate/geolocate.go index d21af5aa8f..537023ba56 100644 --- a/internal/engine/geolocate/geolocate.go +++ b/internal/engine/geolocate/geolocate.go @@ -5,8 +5,8 @@ import ( "context" "fmt" - "github.com/ooni/probe-cli/v3/internal/engine/netx" "github.com/ooni/probe-cli/v3/internal/model" + "github.com/ooni/probe-cli/v3/internal/netxlite" "github.com/ooni/probe-cli/v3/internal/version" ) @@ -114,8 +114,7 @@ func NewTask(config Config) *Task { config.UserAgent = fmt.Sprintf("ooniprobe-engine/%s", version.Version) } if config.Resolver == nil { - config.Resolver = netx.NewResolver( - netx.Config{Logger: config.Logger}) + config.Resolver = netxlite.NewResolverStdlib(config.Logger) } return &Task{ countryLookupper: mmdbLookupper{}, diff --git a/internal/engine/geolocate/iplookup.go b/internal/engine/geolocate/iplookup.go index 7a5cd10093..155e8e0147 100644 --- a/internal/engine/geolocate/iplookup.go +++ b/internal/engine/geolocate/iplookup.go @@ -9,9 +9,9 @@ import ( "net/http" "time" - "github.com/ooni/probe-cli/v3/internal/engine/netx" "github.com/ooni/probe-cli/v3/internal/model" "github.com/ooni/probe-cli/v3/internal/multierror" + "github.com/ooni/probe-cli/v3/internal/netxlite" ) var ( @@ -86,10 +86,11 @@ 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. - clnt := &http.Client{Transport: netx.NewHTTPTransport(netx.Config{ - Logger: c.Logger, - FullResolver: c.Resolver, - })} + dialer := netxlite.NewDialerWithResolver(c.Logger, c.Resolver) + handshaker := netxlite.NewTLSHandshakerStdlib(c.Logger) + tlsDialer := netxlite.NewTLSDialer(dialer, handshaker) + txp := netxlite.NewHTTPTransport(c.Logger, dialer, tlsDialer) + clnt := &http.Client{Transport: txp} defer clnt.CloseIdleConnections() ip, err := fn(ctx, clnt, c.Logger, c.UserAgent) if err != nil { diff --git a/internal/engine/geolocate/iplookup_test.go b/internal/engine/geolocate/iplookup_test.go index b26ba9e4e6..0cba122419 100644 --- a/internal/engine/geolocate/iplookup_test.go +++ b/internal/engine/geolocate/iplookup_test.go @@ -7,11 +7,14 @@ import ( "testing" "github.com/apex/log" + "github.com/ooni/probe-cli/v3/internal/model" + "github.com/ooni/probe-cli/v3/internal/netxlite" ) func TestIPLookupGood(t *testing.T) { ip, err := (ipLookupClient{ Logger: log.Log, + Resolver: netxlite.NewResolverStdlib(model.DiscardLogger), UserAgent: "ooniprobe-engine/0.1.0", }).LookupProbeIP(context.Background()) if err != nil { @@ -27,6 +30,7 @@ func TestIPLookupAllFailed(t *testing.T) { cancel() // immediately cancel to cause Do() to fail ip, err := (ipLookupClient{ Logger: log.Log, + Resolver: netxlite.NewResolverStdlib(model.DiscardLogger), UserAgent: "ooniprobe-engine/0.1.0", }).LookupProbeIP(ctx) if !errors.Is(err, context.Canceled) { @@ -41,6 +45,7 @@ func TestIPLookupInvalidIP(t *testing.T) { ctx := context.Background() ip, err := (ipLookupClient{ Logger: log.Log, + Resolver: netxlite.NewResolverStdlib(model.DiscardLogger), UserAgent: "ooniprobe-engine/0.1.0", }).doWithCustomFunc(ctx, invalidIPLookup) if !errors.Is(err, ErrInvalidIPAddress) {