fix(oohelperd): reduce errors to what the old TH would emit (#543)
Reducing the errors is not done in a perfect way. We have documented the most striking differences inside https://github.com/ooni/probe/issues/1707#issuecomment-942283746 and some attempts to improve the situation further inside https://github.com/ooni/probe/issues/1707#issuecomment-942341255. A better strategy for the future would be to introduce more specific timeout errors, such as dns_timeout_error, etc. More testing may be needed to further validate and compare the old and the new TH, but this requires Jafar improvements to more precisely simulate more complex censorship.
This commit is contained in:
parent
299834174a
commit
4b8cae692b
6 changed files with 315 additions and 8 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
"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"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
// newfailure is a convenience shortcut to save typing
|
||||
|
|
@ -31,5 +32,35 @@ func DNSDo(ctx context.Context, config *DNSConfig) {
|
|||
if addrs == nil {
|
||||
addrs = []string{} // fix: the old test helper did that
|
||||
}
|
||||
config.Out <- CtrlDNSResult{Failure: newfailure(err), Addrs: addrs}
|
||||
failure := dnsMapFailure(newfailure(err))
|
||||
config.Out <- CtrlDNSResult{Failure: failure, Addrs: addrs}
|
||||
}
|
||||
|
||||
// dnsMapFailure attempts to map netxlite failures to the strings
|
||||
// used by the original OONI test helper.
|
||||
//
|
||||
// See https://github.com/ooni/backend/blob/6ec4fda5b18/oonib/testhelpers/http_helpers.py#L430
|
||||
func dnsMapFailure(failure *string) *string {
|
||||
switch failure {
|
||||
case nil:
|
||||
return nil
|
||||
default:
|
||||
switch *failure {
|
||||
case netxlite.FailureDNSNXDOMAINError:
|
||||
// We have a name for this string because dnsanalysis.go is
|
||||
// already checking for this specific error string.
|
||||
s := webconnectivity.DNSNameError
|
||||
return &s
|
||||
case netxlite.FailureDNSNoAnswer,
|
||||
netxlite.FailureDNSNonRecoverableFailure,
|
||||
netxlite.FailureDNSRefusedError,
|
||||
netxlite.FailureDNSServerMisbehaving,
|
||||
netxlite.FailureDNSTemporaryFailure:
|
||||
s := "dns_server_failure"
|
||||
return &s
|
||||
default:
|
||||
s := "unknown_error"
|
||||
return &s
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue