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:
parent
c3964e43b3
commit
8a0c062844
19 changed files with 362 additions and 59 deletions
|
|
@ -10,6 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
// ResolverSaver is a resolver that saves events.
|
||||
|
|
@ -42,7 +43,7 @@ func (r *ResolverSaver) LookupHost(ctx context.Context, hostname string) ([]stri
|
|||
r.Saver.Write(&EventResolveStart{&EventValue{
|
||||
Address: r.Resolver.Address(),
|
||||
Hostname: hostname,
|
||||
Proto: r.Resolver.Network(),
|
||||
Proto: r.Network(),
|
||||
Time: start,
|
||||
}})
|
||||
addrs, err := r.Resolver.LookupHost(ctx, hostname)
|
||||
|
|
@ -53,14 +54,29 @@ func (r *ResolverSaver) LookupHost(ctx context.Context, hostname string) ([]stri
|
|||
Duration: stop.Sub(start),
|
||||
Err: NewFailureStr(err),
|
||||
Hostname: hostname,
|
||||
Proto: r.Resolver.Network(),
|
||||
Proto: r.Network(),
|
||||
Time: stop,
|
||||
}})
|
||||
return addrs, err
|
||||
}
|
||||
|
||||
// ResolverNetworkAdaptNames makes sure we map the [netxlite.StdlibResolverGolangNetResolver] and
|
||||
// [netxlite.StdlibResolverGetaddrinfo] resolver names to [netxlite.StdlibResolverSystem]. You MUST
|
||||
// call this function when your resolver splits the "stdlib" resolver results into two fake AAAA
|
||||
// and A queries rather than faking a single ANY query.
|
||||
//
|
||||
// See https://github.com/ooni/spec/pull/257 for more information.
|
||||
func ResolverNetworkAdaptNames(input string) string {
|
||||
switch input {
|
||||
case netxlite.StdlibResolverGetaddrinfo, netxlite.StdlibResolverGolangNetResolver:
|
||||
return netxlite.StdlibResolverSystem
|
||||
default:
|
||||
return input
|
||||
}
|
||||
}
|
||||
|
||||
func (r *ResolverSaver) Network() string {
|
||||
return r.Resolver.Network()
|
||||
return ResolverNetworkAdaptNames(r.Resolver.Network())
|
||||
}
|
||||
|
||||
func (r *ResolverSaver) Address() string {
|
||||
|
|
@ -112,7 +128,7 @@ func (txp *DNSTransportSaver) RoundTrip(
|
|||
txp.Saver.Write(&EventDNSRoundTripStart{&EventValue{
|
||||
Address: txp.DNSTransport.Address(),
|
||||
DNSQuery: dnsMaybeQueryBytes(query),
|
||||
Proto: txp.DNSTransport.Network(),
|
||||
Proto: txp.Network(),
|
||||
Time: start,
|
||||
}})
|
||||
response, err := txp.DNSTransport.RoundTrip(ctx, query)
|
||||
|
|
@ -123,14 +139,14 @@ func (txp *DNSTransportSaver) RoundTrip(
|
|||
DNSResponse: dnsMaybeResponseBytes(response),
|
||||
Duration: stop.Sub(start),
|
||||
Err: NewFailureStr(err),
|
||||
Proto: txp.DNSTransport.Network(),
|
||||
Proto: txp.Network(),
|
||||
Time: stop,
|
||||
}})
|
||||
return response, err
|
||||
}
|
||||
|
||||
func (txp *DNSTransportSaver) Network() string {
|
||||
return txp.DNSTransport.Network()
|
||||
return ResolverNetworkAdaptNames(txp.DNSTransport.Network())
|
||||
}
|
||||
|
||||
func (txp *DNSTransportSaver) Address() string {
|
||||
|
|
|
|||
Loading…
Reference in a new issue