refactor(netx): use netxlite for AddressResolver (#500)

Part of https://github.com/ooni/probe/issues/1591.
This commit is contained in:
Simone Basso 2021-09-09 20:21:43 +02:00 committed by GitHub
commit 5ab3c3b689
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 66 deletions

View file

@ -1,22 +1,9 @@
package resolver
import (
"context"
"net"
"github.com/ooni/probe-cli/v3/internal/netxlite"
)
// AddressResolver is a resolver that knows how to correctly
// resolve IP addresses to themselves.
type AddressResolver struct {
Resolver
}
// LookupHost implements Resolver.LookupHost
func (r AddressResolver) LookupHost(ctx context.Context, hostname string) ([]string, error) {
if net.ParseIP(hostname) != nil {
return []string{hostname}, nil
}
return r.Resolver.LookupHost(ctx, hostname)
}
var _ Resolver = AddressResolver{}
type AddressResolver = netxlite.AddressResolver