refactor(oohelper): remove unnecessary dep from netx (#498)

There are a bunch of packages where we don't really need to depend
on netx but we can use local definitions that describe what we are
expecting from data structures we receive in input. This diff
addresses one of such cases.

Part of https://github.com/ooni/probe/issues/1591
This commit is contained in:
Simone Basso 2021-09-09 19:40:03 +02:00 committed by GitHub
parent b5826a0c44
commit c54cc73afa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,7 +13,6 @@ import (
"github.com/apex/log" "github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity" "github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader" "github.com/ooni/probe-cli/v3/internal/engine/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/netx"
"github.com/ooni/probe-cli/v3/internal/netxlite/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
"github.com/ooni/probe-cli/v3/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/runtimex"
"github.com/ooni/probe-cli/v3/internal/version" "github.com/ooni/probe-cli/v3/internal/version"
@ -38,13 +37,18 @@ var (
ErrCannotParseJSONReply = errors.New("oohelper: cannot parse JSON reply") ErrCannotParseJSONReply = errors.New("oohelper: cannot parse JSON reply")
) )
// Resolver resolves domain names.
type Resolver interface {
LookupHost(ctx context.Context, hostname string) ([]string, error)
}
// OOClient is a client for the OONI Web Connectivity test helper. // OOClient is a client for the OONI Web Connectivity test helper.
type OOClient struct { type OOClient struct {
// HTTPClient is the HTTP client to use. // HTTPClient is the HTTP client to use.
HTTPClient *http.Client HTTPClient *http.Client
// Resolver is the resolver to user. // Resolver is the resolver to user.
Resolver netx.Resolver Resolver Resolver
} }
// OOConfig contains configuration for the client. // OOConfig contains configuration for the client.