refactor(oohelperd): better distinguish different helpers (#434)

Part of https://github.com/ooni/probe/issues/1733
This commit is contained in:
Simone Basso 2021-08-17 11:23:53 +02:00 committed by GitHub
commit ce854e8ae1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 48 additions and 45 deletions

View file

@ -0,0 +1,32 @@
package webconnectivity
import (
"context"
"sync"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
"github.com/ooni/probe-cli/v3/internal/engine/netx"
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
)
// newfailure is a convenience shortcut to save typing
var newfailure = archival.NewFailure
// CtrlDNSResult is the result of the DNS check performed by
// the Web Connectivity test helper.
type CtrlDNSResult = webconnectivity.ControlDNSResult
// DNSConfig configures the DNS check.
type DNSConfig struct {
Domain string
Out chan CtrlDNSResult
Resolver netx.Resolver
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)
config.Out <- CtrlDNSResult{Failure: newfailure(err), Addrs: addrs}
}