fix(netxlite): resolver _always_ short circuits IP addrs (#458)
We will use this in a moment when we will add support for the dnstransports that currently are in engine/netx. See https://github.com/ooni/probe/issues/1591
This commit is contained in:
parent
7a9499fee3
commit
b52d784f00
2 changed files with 59 additions and 3 deletions
|
|
@ -33,8 +33,10 @@ type ResolverConfig struct {
|
|||
func NewResolver(config *ResolverConfig) Resolver {
|
||||
return &resolverIDNA{
|
||||
Resolver: &resolverLogger{
|
||||
Resolver: &resolverSystem{},
|
||||
Logger: config.Logger,
|
||||
Resolver: &resolverShortCircuitIPAddr{
|
||||
Resolver: &resolverSystem{},
|
||||
},
|
||||
Logger: config.Logger,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -143,3 +145,17 @@ func (r *resolverIDNA) LookupHost(ctx context.Context, hostname string) ([]strin
|
|||
}
|
||||
return r.Resolver.LookupHost(ctx, host)
|
||||
}
|
||||
|
||||
// resolverShortCircuitIPAddr recognizes when the input hostname is an
|
||||
// IP address and returns it immediately to the caller.
|
||||
type resolverShortCircuitIPAddr struct {
|
||||
Resolver
|
||||
}
|
||||
|
||||
// LookupHost implements Resolver.LookupHost.
|
||||
func (r *resolverShortCircuitIPAddr) LookupHost(ctx context.Context, hostname string) ([]string, error) {
|
||||
if net.ParseIP(hostname) != nil {
|
||||
return []string{hostname}, nil
|
||||
}
|
||||
return r.Resolver.LookupHost(ctx, hostname)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue