fix(oohelperd): use throw-away HTTPClient, Dialer, Resolver (#833)
This diff modifies the implementation of oohelperd in the master branch to always use throw-away HTTPClient, Dialer, and Resolver. The rationale of this change is to ensure we're not hitting limits of the HTTPClient regarding the max number of connections per host. This issue is described at https://github.com/ooni/probe/issues/2182. While there, it feels more correct to use throw-away Dialer and Resolver. We have a different patch for the release/3.15 branch because of netx-related refactorings: https://github.com/ooni/probe-cli/pull/832.
This commit is contained in:
parent
59410edba9
commit
a4d17085f5
9 changed files with 87 additions and 60 deletions
|
|
@ -19,16 +19,18 @@ type CtrlDNSResult = webconnectivity.ControlDNSResult
|
|||
|
||||
// DNSConfig configures the DNS check.
|
||||
type DNSConfig struct {
|
||||
Domain string
|
||||
Out chan CtrlDNSResult
|
||||
Resolver model.Resolver
|
||||
Wg *sync.WaitGroup
|
||||
Domain string
|
||||
NewResolver func() model.Resolver
|
||||
Out chan CtrlDNSResult
|
||||
Wg *sync.WaitGroup
|
||||
}
|
||||
|
||||
// DNSDo performs the DNS check.
|
||||
func DNSDo(ctx context.Context, config *DNSConfig) {
|
||||
defer config.Wg.Done()
|
||||
addrs, err := config.Resolver.LookupHost(ctx, config.Domain)
|
||||
reso := config.NewResolver()
|
||||
defer reso.CloseIdleConnections()
|
||||
addrs, err := reso.LookupHost(ctx, config.Domain)
|
||||
if addrs == nil {
|
||||
addrs = []string{} // fix: the old test helper did that
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue