refactor: fully move IDNAResolver to netxlite (#433)
We started doing this in https://github.com/ooni/probe-cli/pull/432. This work is part of https://github.com/ooni/probe/issues/1733.
This commit is contained in:
parent
c31591f298
commit
bef5b87a8a
9 changed files with 84 additions and 120 deletions
|
|
@ -1,34 +1,11 @@
|
|||
package resolver
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"golang.org/x/net/idna"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
// IDNAResolver is to support resolving Internationalized Domain Names.
|
||||
// See RFC3492 for more information.
|
||||
type IDNAResolver struct {
|
||||
Resolver
|
||||
}
|
||||
type IDNAResolver = netxlite.ResolverIDNA
|
||||
|
||||
// LookupHost implements Resolver.LookupHost
|
||||
func (r IDNAResolver) LookupHost(ctx context.Context, hostname string) ([]string, error) {
|
||||
host, err := idna.ToASCII(hostname)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return r.Resolver.LookupHost(ctx, host)
|
||||
}
|
||||
|
||||
// Network implements Resolver.Network.
|
||||
func (r IDNAResolver) Network() string {
|
||||
return "idna"
|
||||
}
|
||||
|
||||
// Address implements Resolver.Address.
|
||||
func (r IDNAResolver) Address() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
var _ Resolver = IDNAResolver{}
|
||||
var _ Resolver = &IDNAResolver{}
|
||||
|
|
|
|||
Loading…
Reference in a new issue