netxlite: call getaddrinfo and handle platform-specific oddities (#764)

This commit changes our system resolver to call getaddrinfo directly when CGO is enabled. This change allows us to:

1. obtain the CNAME easily

2. obtain the real getaddrinfo retval

3. handle platform specific oddities such as `EAI_NODATA`
returned on Android devices

See https://github.com/ooni/probe/issues/2029 and https://github.com/ooni/probe/issues/2029#issuecomment-1140258729 in particular.

See https://github.com/ooni/probe/issues/2033 for documentation regarding the desire to see `getaddrinfo`'s retval.

See https://github.com/ooni/probe/issues/2118 for possible follow-up changes.
This commit is contained in:
Simone Basso 2022-05-28 15:10:30 +02:00 committed by GitHub
commit cf6dbe48e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 1259 additions and 59 deletions

View file

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT.
// Generated: 2022-05-19 20:30:45.704221 +0200 CEST m=+0.534149543
// Generated: 2022-05-28 13:27:22.034720951 +0200 CEST m=+0.276088980
package netxlite
@ -15,36 +15,37 @@ import (
// is system dependent. You're currently looking at
// the list of errors for windows.
const (
ECONNREFUSED = windows.WSAECONNREFUSED
ECONNRESET = windows.WSAECONNRESET
EHOSTUNREACH = windows.WSAEHOSTUNREACH
ETIMEDOUT = windows.WSAETIMEDOUT
EAFNOSUPPORT = windows.WSAEAFNOSUPPORT
EADDRINUSE = windows.WSAEADDRINUSE
EADDRNOTAVAIL = windows.WSAEADDRNOTAVAIL
EISCONN = windows.WSAEISCONN
EFAULT = windows.WSAEFAULT
EBADF = windows.WSAEBADF
ECONNABORTED = windows.WSAECONNABORTED
EALREADY = windows.WSAEALREADY
EDESTADDRREQ = windows.WSAEDESTADDRREQ
EINTR = windows.WSAEINTR
EINVAL = windows.WSAEINVAL
EMSGSIZE = windows.WSAEMSGSIZE
ENETDOWN = windows.WSAENETDOWN
ENETRESET = windows.WSAENETRESET
ENETUNREACH = windows.WSAENETUNREACH
ENOBUFS = windows.WSAENOBUFS
ENOPROTOOPT = windows.WSAENOPROTOOPT
ENOTSOCK = windows.WSAENOTSOCK
ENOTCONN = windows.WSAENOTCONN
EWOULDBLOCK = windows.WSAEWOULDBLOCK
EACCES = windows.WSAEACCES
EPROTONOSUPPORT = windows.WSAEPROTONOSUPPORT
EPROTOTYPE = windows.WSAEPROTOTYPE
WSANO_DATA = windows.WSANO_DATA
WSANO_RECOVERY = windows.WSANO_RECOVERY
WSATRY_AGAIN = windows.WSATRY_AGAIN
ECONNREFUSED = windows.WSAECONNREFUSED
ECONNRESET = windows.WSAECONNRESET
EHOSTUNREACH = windows.WSAEHOSTUNREACH
ETIMEDOUT = windows.WSAETIMEDOUT
EAFNOSUPPORT = windows.WSAEAFNOSUPPORT
EADDRINUSE = windows.WSAEADDRINUSE
EADDRNOTAVAIL = windows.WSAEADDRNOTAVAIL
EISCONN = windows.WSAEISCONN
EFAULT = windows.WSAEFAULT
EBADF = windows.WSAEBADF
ECONNABORTED = windows.WSAECONNABORTED
EALREADY = windows.WSAEALREADY
EDESTADDRREQ = windows.WSAEDESTADDRREQ
EINTR = windows.WSAEINTR
EINVAL = windows.WSAEINVAL
EMSGSIZE = windows.WSAEMSGSIZE
ENETDOWN = windows.WSAENETDOWN
ENETRESET = windows.WSAENETRESET
ENETUNREACH = windows.WSAENETUNREACH
ENOBUFS = windows.WSAENOBUFS
ENOPROTOOPT = windows.WSAENOPROTOOPT
ENOTSOCK = windows.WSAENOTSOCK
ENOTCONN = windows.WSAENOTCONN
EWOULDBLOCK = windows.WSAEWOULDBLOCK
EACCES = windows.WSAEACCES
EPROTONOSUPPORT = windows.WSAEPROTONOSUPPORT
EPROTOTYPE = windows.WSAEPROTOTYPE
WSANO_DATA = windows.WSANO_DATA
WSANO_RECOVERY = windows.WSANO_RECOVERY
WSATRY_AGAIN = windows.WSATRY_AGAIN
WSAHOST_NOT_FOUND = windows.WSAHOST_NOT_FOUND
)
// classifySyscallError converts a syscall error to the
@ -116,6 +117,8 @@ func classifySyscallError(err error) string {
return FailureDNSNonRecoverableFailure
case windows.WSATRY_AGAIN:
return FailureDNSTemporaryFailure
case windows.WSAHOST_NOT_FOUND:
return FailureDNSNXDOMAINError
}
return ""
}