refactor(netxlite): add more functions to resolver (#455)
We would like to refactor the code so that a DoH resolver owns the connections of its underlying HTTP client. To do that, we need first to incorporate CloseIdleConnections into the Resolver model. Then, we need to add the same function to all netxlite types that wrap a Resolver type. At the same time, we want the rest of the code for now to continue with the simpler definition of a Resolver, now called ResolverLegacy. We will eventually propagate this change to the rest of the tree and simplify the way in which we manage Resolvers. To make this possible, we introduce a new factory function that adapts a ResolverLegacy to become a Resolver. See https://github.com/ooni/probe/issues/1591.
This commit is contained in:
parent
2e0118d1a6
commit
a3654f60b7
22 changed files with 278 additions and 118 deletions
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
type DNSConfig struct {
|
||||
Domain string
|
||||
Resolver netxlite.Resolver
|
||||
Resolver netxlite.ResolverLegacy
|
||||
}
|
||||
|
||||
// DNSDo performs the DNS check.
|
||||
|
|
@ -21,7 +21,9 @@ func DNSDo(ctx context.Context, config DNSConfig) ([]string, error) {
|
|||
childResolver, err := netx.NewDNSClient(netx.Config{Logger: log.Log}, "doh://google")
|
||||
runtimex.PanicOnError(err, "NewDNSClient failed")
|
||||
resolver = childResolver
|
||||
resolver = &netxlite.ResolverIDNA{Resolver: resolver}
|
||||
resolver = &netxlite.ResolverIDNA{
|
||||
Resolver: netxlite.NewResolverLegacyAdapter(resolver),
|
||||
}
|
||||
}
|
||||
return resolver.LookupHost(ctx, config.Domain)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue