getaddrinfo: fix CGO_ENABLED=0 and record resolver type (#765)
After https://github.com/ooni/probe-cli/pull/764, the build for CGO_ENABLED=0 has been broken for miniooni: https://github.com/ooni/probe-cli/runs/6636995859?check_suite_focus=true Likewise, it's not possible to run tests with CGO_ENABLED=0. To make tests work with `CGO_ENABLED=0`, I needed to sacrifice some unit tests run for the CGO case. It is not fully clear to me what was happening here, but basically `getaddrinfo_cgo_test.go` was compiled with CGO being disabled, even though the ``//go:build cgo` flag was specified. Additionally, @hellais previously raised a valid point in the review of https://github.com/ooni/probe-cli/pull/698: > Another issue we should consider is that, if I understand how > this works correctly, depending on whether or not we have built > with CGO_ENABLED=0 on or not, we are going to be measuring > things in a different way (using our cgo inspired getaddrinfo > implementation or using netgo). This might present issues when > analyzing or interpreting the data. > > Do we perhaps want to add some field to the output data format that > gives us an indication of which DNS resolution code was used to > generate the the metric? This comment is relevant to the current commit because https://github.com/ooni/probe-cli/pull/698 is the previous iteration of https://github.com/ooni/probe-cli/pull/764. So, while fixing the build and test issues, let us also distinguish between the CGO_ENABLED=1 and CGO_ENABLED=0 cases. Before this commit, OONI used "system" to indicate the case where we were using net.DefaultResolver. This behavior dates back to the Measurement Kit days. While it is true that ooni/probe-engine and ooni/probe-cli could have been using netgo in the past when we said "system" as the resolver, it also seems reasonable to continue to use "system" top indicate getaddrinfo. So, the choice here is basically to use "netgo" from now on to indicate the cases in which we were built with CGO_ENABLED=0. This change will need to be documented into ooni/spec along with the introduction of the `android_dns_cache_no_data` error. ## Checklist - [x] I have read the [contribution guidelines](https://github.com/ooni/probe-cli/blob/master/CONTRIBUTING.md) - [x] reference issue for this pull request: https://github.com/ooni/probe/issues/2029 - [x] if you changed anything related how experiments work and you need to reflect these changes in the ooni/spec repository, please link to the related ooni/spec pull request: https://github.com/ooni/spec/pull/242
This commit is contained in:
+27
-5
@@ -193,13 +193,35 @@ type QUICDialer interface {
|
||||
CloseIdleConnections()
|
||||
}
|
||||
|
||||
// Resolver performs domain name resolutions.
|
||||
type Resolver interface {
|
||||
// SimpleResolver is a simplified resolver that only allows to perform
|
||||
// an ordinary lookup operation and to know the resolver's name.
|
||||
type SimpleResolver interface {
|
||||
// LookupHost behaves like net.Resolver.LookupHost.
|
||||
LookupHost(ctx context.Context, hostname string) (addrs []string, err error)
|
||||
|
||||
// Network returns the resolver type (e.g., system, dot, doh).
|
||||
// Network returns the resolver type. It should be one of:
|
||||
//
|
||||
// - netgo: means we're using golang's "netgo" UDP resolver, which
|
||||
// reads /etc/resolv.conf and only works on Unix systems;
|
||||
//
|
||||
// - system: means we're calling getaddrinfo;
|
||||
//
|
||||
// - udp: is a custom DNS-over-UDP resolver;
|
||||
//
|
||||
// - tcp: is a custom DNS-over-TCP resolver;
|
||||
//
|
||||
// - dot: is a custom DNS-over-TLS resolver;
|
||||
//
|
||||
// - doh: is a custom DNS-over-HTTPS resolver;
|
||||
//
|
||||
// - doh3: is a custom DNS-over-HTTP3 resolver.
|
||||
Network() string
|
||||
}
|
||||
|
||||
// Resolver performs domain name resolutions.
|
||||
type Resolver interface {
|
||||
// A Resolver is also a SimpleResolver.
|
||||
SimpleResolver
|
||||
|
||||
// Address returns the resolver address (e.g., 8.8.8.8:53).
|
||||
Address() string
|
||||
@@ -283,8 +305,8 @@ type UnderlyingNetworkLibrary interface {
|
||||
// ListenUDP creates a new model.UDPLikeConn conn.
|
||||
ListenUDP(network string, laddr *net.UDPAddr) (UDPLikeConn, error)
|
||||
|
||||
// LookupHost lookups a domain using the stdlib resolver.
|
||||
LookupHost(ctx context.Context, domain string) ([]string, error)
|
||||
// DefaultResolver returns the default resolver.
|
||||
DefaultResolver() SimpleResolver
|
||||
|
||||
// NewSimpleDialer returns a new SimpleDialer.
|
||||
NewSimpleDialer(timeout time.Duration) SimpleDialer
|
||||
|
||||
Reference in New Issue
Block a user