9967803c31
On Windows, GetAddrInfoW is a syscall and the Go resolver does not attempt to map errors beyond WSA_HOST_NOT_FOUND, which becomes "no such host", which we map to "dns_nxdomain_error". See https://github.com/golang/go/blob/go1.17.1/src/net/lookup_windows.go#L16. To map more GetAddrInfoW errors, thus, we need to enhance our error classifier to have system specific errors. Then, we need to filter for the WSA errors that are most likely to pop up and map them to OONI failures. Those are three: - WSANO_DATA which we have from our own UDP resolver as well and which we can map to `dns_no_answer` - WSANO_RECOVERY which we don't have but existed for MK so we will use `dns_non_recoverable_failure`, which was an MK error - WSATRY_AGAIN which likewise we map to the error that MK used to emit, so `dns_temporary_failure` This diff should address https://github.com/ooni/probe/issues/1467.
111 lines
2.9 KiB
Go
111 lines
2.9 KiB
Go
// Code generated by go generate; DO NOT EDIT.
|
|
// Generated: 2021-09-29 10:33:56.529823 +0200 CEST m=+0.464489585
|
|
|
|
package netxlite
|
|
|
|
import (
|
|
"errors"
|
|
"syscall"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
// This enumeration provides a canonical name for
|
|
// every system-call error we support on this systems.
|
|
const (
|
|
ECONNREFUSED = unix.ECONNREFUSED
|
|
ECONNRESET = unix.ECONNRESET
|
|
EHOSTUNREACH = unix.EHOSTUNREACH
|
|
ETIMEDOUT = unix.ETIMEDOUT
|
|
EAFNOSUPPORT = unix.EAFNOSUPPORT
|
|
EADDRINUSE = unix.EADDRINUSE
|
|
EADDRNOTAVAIL = unix.EADDRNOTAVAIL
|
|
EISCONN = unix.EISCONN
|
|
EFAULT = unix.EFAULT
|
|
EBADF = unix.EBADF
|
|
ECONNABORTED = unix.ECONNABORTED
|
|
EALREADY = unix.EALREADY
|
|
EDESTADDRREQ = unix.EDESTADDRREQ
|
|
EINTR = unix.EINTR
|
|
EINVAL = unix.EINVAL
|
|
EMSGSIZE = unix.EMSGSIZE
|
|
ENETDOWN = unix.ENETDOWN
|
|
ENETRESET = unix.ENETRESET
|
|
ENETUNREACH = unix.ENETUNREACH
|
|
ENOBUFS = unix.ENOBUFS
|
|
ENOPROTOOPT = unix.ENOPROTOOPT
|
|
ENOTSOCK = unix.ENOTSOCK
|
|
ENOTCONN = unix.ENOTCONN
|
|
EWOULDBLOCK = unix.EWOULDBLOCK
|
|
EACCES = unix.EACCES
|
|
EPROTONOSUPPORT = unix.EPROTONOSUPPORT
|
|
EPROTOTYPE = unix.EPROTOTYPE
|
|
)
|
|
|
|
// classifySyscallError converts a syscall error to the
|
|
// proper OONI error. Returns the OONI error string
|
|
// on success, an empty string otherwise.
|
|
func classifySyscallError(err error) string {
|
|
var errno syscall.Errno
|
|
if !errors.As(err, &errno) {
|
|
return ""
|
|
}
|
|
switch errno {
|
|
case unix.ECONNREFUSED:
|
|
return FailureConnectionRefused
|
|
case unix.ECONNRESET:
|
|
return FailureConnectionReset
|
|
case unix.EHOSTUNREACH:
|
|
return FailureHostUnreachable
|
|
case unix.ETIMEDOUT:
|
|
return FailureTimedOut
|
|
case unix.EAFNOSUPPORT:
|
|
return FailureAddressFamilyNotSupported
|
|
case unix.EADDRINUSE:
|
|
return FailureAddressInUse
|
|
case unix.EADDRNOTAVAIL:
|
|
return FailureAddressNotAvailable
|
|
case unix.EISCONN:
|
|
return FailureAlreadyConnected
|
|
case unix.EFAULT:
|
|
return FailureBadAddress
|
|
case unix.EBADF:
|
|
return FailureBadFileDescriptor
|
|
case unix.ECONNABORTED:
|
|
return FailureConnectionAborted
|
|
case unix.EALREADY:
|
|
return FailureConnectionAlreadyInProgress
|
|
case unix.EDESTADDRREQ:
|
|
return FailureDestinationAddressRequired
|
|
case unix.EINTR:
|
|
return FailureInterrupted
|
|
case unix.EINVAL:
|
|
return FailureInvalidArgument
|
|
case unix.EMSGSIZE:
|
|
return FailureMessageSize
|
|
case unix.ENETDOWN:
|
|
return FailureNetworkDown
|
|
case unix.ENETRESET:
|
|
return FailureNetworkReset
|
|
case unix.ENETUNREACH:
|
|
return FailureNetworkUnreachable
|
|
case unix.ENOBUFS:
|
|
return FailureNoBufferSpace
|
|
case unix.ENOPROTOOPT:
|
|
return FailureNoProtocolOption
|
|
case unix.ENOTSOCK:
|
|
return FailureNotASocket
|
|
case unix.ENOTCONN:
|
|
return FailureNotConnected
|
|
case unix.EWOULDBLOCK:
|
|
return FailureOperationWouldBlock
|
|
case unix.EACCES:
|
|
return FailurePermissionDenied
|
|
case unix.EPROTONOSUPPORT:
|
|
return FailureProtocolNotSupported
|
|
case unix.EPROTOTYPE:
|
|
return FailureWrongProtocolType
|
|
}
|
|
return ""
|
|
}
|