refactor(netx): dialer does not use legacy/netx anymore (#370)

Part of https://github.com/ooni/probe-engine/issues/897
This commit is contained in:
Simone Basso 2021-06-09 00:29:40 +02:00 committed by GitHub
commit ee35b10a98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 41 deletions

View file

@ -6,10 +6,14 @@ import (
"net"
"strings"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/dialid"
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
)
// Resolver is the interface we expect from a resolver
type Resolver interface {
LookupHost(ctx context.Context, hostname string) (addrs []string, err error)
}
// DNSDialer is a dialer that uses the configured Resolver to resolver a
// domain name to IP addresses, and the configured Dialer to connect.
type DNSDialer struct {
@ -23,7 +27,6 @@ func (d DNSDialer) DialContext(ctx context.Context, network, address string) (ne
if err != nil {
return nil, err
}
ctx = dialid.WithDialID(ctx) // important to create before lookupHost
var addrs []string
addrs, err = d.LookupHost(ctx, onlyhost)
if err != nil {