diff --git a/internal/cmd/oohelperd/internal/webconnectivity/dns.go b/internal/cmd/oohelperd/internal/webconnectivity/dns.go index 5808111..221774a 100644 --- a/internal/cmd/oohelperd/internal/webconnectivity/dns.go +++ b/internal/cmd/oohelperd/internal/webconnectivity/dns.go @@ -28,5 +28,8 @@ type DNSConfig struct { func DNSDo(ctx context.Context, config *DNSConfig) { defer config.Wg.Done() addrs, err := config.Resolver.LookupHost(ctx, config.Domain) + if addrs == nil { + addrs = []string{} // fix: the old test helper did that + } config.Out <- CtrlDNSResult{Failure: newfailure(err), Addrs: addrs} } diff --git a/internal/cmd/oohelperd/internal/webconnectivity/http.go b/internal/cmd/oohelperd/internal/webconnectivity/http.go index 673c6e2..5fd2bd5 100644 --- a/internal/cmd/oohelperd/internal/webconnectivity/http.go +++ b/internal/cmd/oohelperd/internal/webconnectivity/http.go @@ -30,7 +30,11 @@ func HTTPDo(ctx context.Context, config *HTTPConfig) { defer config.Wg.Done() req, err := http.NewRequestWithContext(ctx, "GET", config.URL, nil) if err != nil { - config.Out <- CtrlHTTPResponse{Failure: newfailure(err)} + config.Out <- CtrlHTTPResponse{ // fix: emit -1 like the old test helper does + BodyLength: -1, + Failure: newfailure(err), + StatusCode: -1, + } return } // The original test helper failed with extra headers while here @@ -45,7 +49,11 @@ func HTTPDo(ctx context.Context, config *HTTPConfig) { } resp, err := config.Client.Do(req) if err != nil { - config.Out <- CtrlHTTPResponse{Failure: newfailure(err)} + config.Out <- CtrlHTTPResponse{ // fix: emit -1 like old test helper does + BodyLength: -1, + Failure: newfailure(err), + StatusCode: -1, + } return } defer resp.Body.Close() diff --git a/internal/cmd/oohelperd/oohelperd.go b/internal/cmd/oohelperd/oohelperd.go index 189b007..e582962 100644 --- a/internal/cmd/oohelperd/oohelperd.go +++ b/internal/cmd/oohelperd/oohelperd.go @@ -12,6 +12,7 @@ import ( "github.com/ooni/probe-cli/v3/internal/cmd/oohelperd/internal/webconnectivity" "github.com/ooni/probe-cli/v3/internal/cmd/oohelperd/internal/websteps" "github.com/ooni/probe-cli/v3/internal/engine/netx" + "github.com/ooni/probe-cli/v3/internal/runtimex" ) const maxAcceptableBody = 1 << 24 @@ -31,7 +32,10 @@ func init() { dialer = netx.NewDialer(netx.Config{Logger: log.Log}) txp := netx.NewHTTPTransport(netx.Config{Logger: log.Log}) httpx = &http.Client{Transport: txp} - resolver = netx.NewResolver(netx.Config{Logger: log.Log}) + // fix: use 8.8.8.8:53/udp so we pin to a specific resolver. + var err error + resolver, err = netx.NewDNSClient(netx.Config{Logger: log.Log}, "udp://8.8.8.8:53") + runtimex.PanicOnError(err, "NewDNSClient failed") } func shutdown(srv *http.Server) {