refactor(netx): use netxlite for AddressResolver (#500)
Part of https://github.com/ooni/probe/issues/1591.
This commit is contained in:
parent
254a5511e9
commit
5ab3c3b689
5 changed files with 48 additions and 66 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue