refactor: split errorsx in good and legacy (#477)

The legacy part for now is internal/errorsx. It will stay there until
I figure out whether it also needs some extra bug fixing.

The good part is now in internal/netxlite/errorsx and contains all the
logic for mapping errors. We need to further improve upon this logic
by writing more thorough integration tests for QUIC.

We also need to copy the various dialer, conn, etc adapters that set
errors. We will put them inside netxlite and we will generate errors in
a way that is less crazy with respect to the major operation. (The
idea is to always wrap, given that now we measure in an incremental way
and we don't measure every operation together.)

Part of https://github.com/ooni/probe/issues/1591
This commit is contained in:
Simone Basso 2021-09-07 17:09:30 +02:00 committed by GitHub
commit 83440cf110
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
70 changed files with 684 additions and 576 deletions

View file

@ -2,7 +2,8 @@ package errorsx
import (
"context"
"errors"
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
)
// Resolver is a DNS resolver. The *net.Resolver used by Go implements
@ -23,22 +24,13 @@ var _ Resolver = &ErrorWrapperResolver{}
func (r *ErrorWrapperResolver) LookupHost(ctx context.Context, hostname string) ([]string, error) {
addrs, err := r.Resolver.LookupHost(ctx, hostname)
err = SafeErrWrapperBuilder{
Classifier: ClassifyResolverError,
Classifier: errorsx.ClassifyResolverError,
Error: err,
Operation: ResolveOperation,
Operation: errorsx.ResolveOperation,
}.MaybeBuild()
return addrs, err
}
// ClassifyResolverError maps an error occurred during a domain name
// resolution to the corresponding OONI failure string.
func ClassifyResolverError(err error) string {
if errors.Is(err, ErrDNSBogon) {
return FailureDNSBogonError // not in MK
}
return ClassifyGenericError(err)
}
type resolverNetworker interface {
Network() string
}