feat: clearly indicate which resolver we're using (#885)

See what we documented at https://github.com/ooni/spec/pull/257

Reference issue: https://github.com/ooni/probe/issues/2238

See also the related ooni/spec PR: https://github.com/ooni/spec/pull/257

See also https://github.com/ooni/probe/issues/2237

While there, bump webconnectivity@v0.5 version because this change
has an impact onto the generated data format.

The drop in coverage is unavoidable because we've written some
tests for `measurex` to ensure we deal with DNS resolvers and transport
names correctly depending on the splitting policy we use.

(However, `measurex` is only used for the `tor` experiment and, per
the step-by-step design document, new experiments should use
`measurexlite` instead, so this is hopefully fine(TM).)

While there, fix a broken integration test that does not run in `-short` mode.
This commit is contained in:
Simone Basso
2022-08-27 15:47:48 +02:00
committed by GitHub
parent c3964e43b3
commit 8a0c062844
19 changed files with 362 additions and 59 deletions
+5
View File
@@ -24,6 +24,11 @@ type dnsOverGetaddrinfoTransport struct {
testableLookupANY func(ctx context.Context, domain string) ([]string, string, error)
}
// NewDNSOverGetaddrinfoTransport creates a new dns-over-getaddrinfo transport.
func NewDNSOverGetaddrinfoTransport() model.DNSTransport {
return &dnsOverGetaddrinfoTransport{}
}
var _ model.DNSTransport = &dnsOverGetaddrinfoTransport{}
func (txp *dnsOverGetaddrinfoTransport) RoundTrip(
+1 -1
View File
@@ -47,7 +47,7 @@
//
// 1. establishing a TCP connection;
//
// 2. performing a domain name resolution with the "system" resolver
// 2. performing a domain name resolution with the "stdlib" resolver
// (i.e., getaddrinfo on Unix) or custom DNS transports (e.g., DoT, DoH);
//
// 3. performing the TLS handshake;
+17
View File
@@ -2,6 +2,23 @@ package netxlite
import "errors"
// Name of the resolver we use when we link with libc and use getaddrinfo directly.
//
// See https://github.com/ooni/spec/pull/257 for more info.
const StdlibResolverGetaddrinfo = "getaddrinfo"
// Name of the resolver we use when we don't link with libc and use net.Resolver.
//
// See https://github.com/ooni/spec/pull/257 for more info.
const StdlibResolverGolangNetResolver = "golang_net_resolver"
// Legacy name of the resolver we use when we're don't know whether we're using
// getaddrinfo, but we're using net.Resolver, and we're splitting the answer
// in two A and AAAA queries. Eventually will become deprecated.
//
// See https://github.com/ooni/spec/pull/257 for more info.
const StdlibResolverSystem = "system"
// ErrGetaddrinfo represents a getaddrinfo failure.
type ErrGetaddrinfo struct {
// Err is the error proper.
+5 -2
View File
@@ -28,10 +28,13 @@ import (
// been used to implement the getaddrinfo resolver.
//
// This is the CGO_ENABLED=1 implementation of this function, which
// always returns the string "system", because in this scenario
// always returns the string [StdlibResolverGetaddrinfo], because in this scenario
// we are actually calling the getaddrinfo libc function.
//
// See https://github.com/ooni/spec/pull/257 for more information on how
// we evolved our naming of the "stdlib" resolver over time.
func getaddrinfoResolverNetwork() string {
return "system"
return StdlibResolverGetaddrinfo
}
// getaddrinfoLookupANY attempts to perform an ANY lookup using getaddrinfo.
+7 -4
View File
@@ -11,13 +11,16 @@ import (
// been used to implement the getaddrinfo resolver.
//
// This is the CGO_ENABLED=0 implementation of this function, which
// always returns the string "go", because in this scenario we are actually
// using whatever resolver is used under the hood by the stdlib.
// always returns the string [StdlibResolverGolangNetResolver], because in this scenario
// we are actually using whatever resolver is used under the hood by the stdlib.
//
// See https://github.com/ooni/probe/issues/2029#issuecomment-1140805266
// for an explanation of why calling this resolver "netgo" is wrong.
// for an explanation of why calling this resolver "netgo" was wrong.
//
// See https://github.com/ooni/spec/pull/257 for additional documentation
// regarding using "golang_net_resolver" instead of "go".
func getaddrinfoResolverNetwork() string {
return "go"
return StdlibResolverGolangNetResolver
}
// getaddrinfoLookupANY attempts to perform an ANY lookup using getaddrinfo.
+3 -3
View File
@@ -20,11 +20,11 @@ import (
// ErrNoDNSTransport is the error returned when you attempt to perform
// a DNS operation that requires a custom DNSTransport (e.g., DNSOverHTTPSTransport)
// but you are using the "system" resolver instead.
// but you are using the "stdlib" resolver instead.
var ErrNoDNSTransport = errors.New("operation requires a DNS transport")
// NewStdlibResolver creates a new Resolver by combining WrapResolver
// with an internal "system" resolver type. The list of optional wrappers
// with an internal "stdlib" resolver type. The list of optional wrappers
// allow to wrap the underlying getaddrinfo transport. Any nil wrapper
// will be silently ignored by the code that performs the wrapping.
func NewStdlibResolver(logger model.DebugLogger, wrappers ...model.DNSTransportWrapper) model.Resolver {
@@ -45,7 +45,7 @@ func NewParallelDNSOverHTTPSResolver(logger model.DebugLogger, URL string) model
// implies, this function returns an unwrapped resolver.
func NewUnwrappedStdlibResolver(wrappers ...model.DNSTransportWrapper) model.Resolver {
return &resolverSystem{
t: WrapDNSTransport(&dnsOverGetaddrinfoTransport{}, wrappers...),
t: WrapDNSTransport(NewDNSOverGetaddrinfoTransport(), wrappers...),
}
}
+6 -6
View File
@@ -347,7 +347,7 @@ func TestResolverLogger(t *testing.T) {
return expected, nil
},
MockNetwork: func() string {
return "system"
return StdlibResolverGetaddrinfo
},
MockAddress: func() string {
return ""
@@ -381,7 +381,7 @@ func TestResolverLogger(t *testing.T) {
return nil, expected
},
MockNetwork: func() string {
return "system"
return StdlibResolverGetaddrinfo
},
MockAddress: func() string {
return ""
@@ -420,7 +420,7 @@ func TestResolverLogger(t *testing.T) {
return expected, nil
},
MockNetwork: func() string {
return "system"
return StdlibResolverGetaddrinfo
},
MockAddress: func() string {
return ""
@@ -454,7 +454,7 @@ func TestResolverLogger(t *testing.T) {
return nil, expected
},
MockNetwork: func() string {
return "system"
return StdlibResolverGetaddrinfo
},
MockAddress: func() string {
return ""
@@ -509,7 +509,7 @@ func TestResolverLogger(t *testing.T) {
return expected, nil
},
MockNetwork: func() string {
return "system"
return StdlibResolverGetaddrinfo
},
MockAddress: func() string {
return ""
@@ -543,7 +543,7 @@ func TestResolverLogger(t *testing.T) {
return nil, expected
},
MockNetwork: func() string {
return "system"
return StdlibResolverGetaddrinfo
},
MockAddress: func() string {
return ""