ooni-probe-cli/internal/netxlite/errno_windows.go
Simone Basso 0d65438ea1
[forwardport] fix(netxlite): remove android-specific errno (#586) (#587)
This commit forward ports 74947dbbd12266c12a38fad51a70fc78a21720fd from
the `release/3.11` branch to `master`. Here's the original commit message:

- - -

Android is also Linux. The Android build fails because both
errno_linux.go and errno_android.go are compiled.

There's no difference between the files except into a comment
that mentions "linux" or "android".

Therefore, it's safe to remove the android-specific file
and just keep and use the linux-specific one.

Part of https://github.com/ooni/probe/issues/1863, where we're
forward porting ooni/go patches to go1.17.

I'm still trying to figure out whether I can build oonimkall
using the forward ported patches and this error prevents me
from building, because the build fails.

"やれやれだぜ"

Note that this patch WILL need to be forward ported to master.

This bug was previosuly reported to me by @hellais.

Because I did run `go generate ./internal/netxlite/...` we also
get for free updated certificates, which is OK.
2021-11-10 13:00:41 +01:00

122 lines
3.7 KiB
Go

// Code generated by go generate; DO NOT EDIT.
// Generated: 2021-11-10 12:32:23.769840098 +0100 CET m=+3.529799255
package netxlite
import (
"errors"
"syscall"
"golang.org/x/sys/windows"
)
// This enumeration provides a canonical name for
// every system-call error we support. Note: this list
// 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
)
// 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 windows.WSAECONNREFUSED:
return FailureConnectionRefused
case windows.WSAECONNRESET:
return FailureConnectionReset
case windows.WSAEHOSTUNREACH:
return FailureHostUnreachable
case windows.WSAETIMEDOUT:
return FailureTimedOut
case windows.WSAEAFNOSUPPORT:
return FailureAddressFamilyNotSupported
case windows.WSAEADDRINUSE:
return FailureAddressInUse
case windows.WSAEADDRNOTAVAIL:
return FailureAddressNotAvailable
case windows.WSAEISCONN:
return FailureAlreadyConnected
case windows.WSAEFAULT:
return FailureBadAddress
case windows.WSAEBADF:
return FailureBadFileDescriptor
case windows.WSAECONNABORTED:
return FailureConnectionAborted
case windows.WSAEALREADY:
return FailureConnectionAlreadyInProgress
case windows.WSAEDESTADDRREQ:
return FailureDestinationAddressRequired
case windows.WSAEINTR:
return FailureInterrupted
case windows.WSAEINVAL:
return FailureInvalidArgument
case windows.WSAEMSGSIZE:
return FailureMessageSize
case windows.WSAENETDOWN:
return FailureNetworkDown
case windows.WSAENETRESET:
return FailureNetworkReset
case windows.WSAENETUNREACH:
return FailureNetworkUnreachable
case windows.WSAENOBUFS:
return FailureNoBufferSpace
case windows.WSAENOPROTOOPT:
return FailureNoProtocolOption
case windows.WSAENOTSOCK:
return FailureNotASocket
case windows.WSAENOTCONN:
return FailureNotConnected
case windows.WSAEWOULDBLOCK:
return FailureOperationWouldBlock
case windows.WSAEACCES:
return FailurePermissionDenied
case windows.WSAEPROTONOSUPPORT:
return FailureProtocolNotSupported
case windows.WSAEPROTOTYPE:
return FailureWrongProtocolType
case windows.WSANO_DATA:
return FailureDNSNoAnswer
case windows.WSANO_RECOVERY:
return FailureDNSNonRecoverableFailure
case windows.WSATRY_AGAIN:
return FailureDNSTemporaryFailure
}
return ""
}