2502a237fb
This diff refactors netx and netxlite to ensure we're not using netxlite legacy names inside of netx. To this end, we're cheating a bit. We're exposing a new factory to get an unwrapped stdlib resolver rather than defining a legacy name to export the private name of the same factory. This is actually a fine place to stop, for now, the next and netxlite refactoring at https://github.com/ooni/probe/issues/2121.
26 lines
734 B
Go
26 lines
734 B
Go
package netx
|
|
|
|
//
|
|
// Resolver from Config.
|
|
//
|
|
|
|
import (
|
|
"github.com/ooni/probe-cli/v3/internal/model"
|
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
|
)
|
|
|
|
// NewResolver creates a new resolver from the specified config.
|
|
func NewResolver(config Config) model.Resolver {
|
|
if config.BaseResolver == nil {
|
|
config.BaseResolver = netxlite.NewUnwrappedStdlibResolver()
|
|
}
|
|
r := netxlite.WrapResolver(
|
|
model.ValidLoggerOrDefault(config.Logger),
|
|
config.BaseResolver,
|
|
)
|
|
r = netxlite.MaybeWrapWithCachingResolver(config.CacheResolutions, r)
|
|
r = netxlite.MaybeWrapWithStaticDNSCache(config.DNSCache, r)
|
|
r = netxlite.MaybeWrapWithBogonResolver(config.BogonIsError, r)
|
|
return config.Saver.WrapResolver(r) // WAI when config.Saver==nil
|
|
}
|