fix: allow to build miniooni for windows (#520)
I need to run test on Windows and I just discovered that: 1. the `errno_unix.go` filename does not mean anything because `unix` is not a valid platform, so we need a filename for each platform that we care about; 2. on Windows we need to use WSA prefixed names; 3. `i/e/session_psiphon.go` was not building because of the migration from `netxlite/iox` to `netxlite`. This diff attempts to fix all three issues. The reference issue is https://github.com/ooni/probe/issues/1733, because I was working on such an issue.
This commit is contained in:
parent
9ef4d9df7d
commit
9523753b87
|
@ -9,7 +9,7 @@ import (
|
|||
_ "embed"
|
||||
|
||||
"filippo.io/age"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/iox"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
//go:embed psiphon-config.json.age
|
||||
|
@ -35,7 +35,7 @@ func (s *sessionTunnelEarlySession) FetchPsiphonConfig(ctx context.Context) ([]b
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return iox.ReadAllContext(ctx, output)
|
||||
return netxlite.ReadAllContext(ctx, output)
|
||||
}
|
||||
|
||||
// FetchPsiphonConfig decrypts psiphonConfigJSONAge using
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2021-09-28 12:05:19.526032 +0200 CEST m=+0.405934084
|
||||
// 2021-09-28 18:13:53.557509 +0200 CEST m=+0.459759459
|
||||
// https://curl.haxx.se/ca/cacert.pem
|
||||
|
||||
package netxlite
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// Generated: 2021-09-28 12:05:19.868647 +0200 CEST m=+0.105301959
|
||||
// Generated: 2021-09-28 18:13:54.361886 +0200 CEST m=+0.453564501
|
||||
|
||||
package netxlite
|
||||
|
||||
|
@ -16,7 +16,6 @@ const (
|
|||
//
|
||||
// System errors
|
||||
//
|
||||
FailureOperationCanceled = "operation_canceled"
|
||||
FailureConnectionRefused = "connection_refused"
|
||||
FailureConnectionReset = "connection_reset"
|
||||
FailureHostUnreachable = "host_unreachable"
|
||||
|
@ -67,7 +66,6 @@ const (
|
|||
// failureMap lists all failures so we can match them
|
||||
// when they are wrapped by quic.TransportError.
|
||||
var failuresMap = map[string]string{
|
||||
"operation_canceled": "operation_canceled",
|
||||
"connection_refused": "connection_refused",
|
||||
"connection_reset": "connection_reset",
|
||||
"host_unreachable": "host_unreachable",
|
||||
|
@ -120,8 +118,6 @@ func classifySyscallError(err error) string {
|
|||
return ""
|
||||
}
|
||||
switch errno {
|
||||
case ECANCELED:
|
||||
return FailureOperationCanceled
|
||||
case ECONNREFUSED:
|
||||
return FailureConnectionRefused
|
||||
case ECONNRESET:
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// Generated: 2021-09-28 12:05:19.763535 +0200 CEST m=+0.000187668
|
||||
// Generated: 2021-09-28 18:13:53.909532 +0200 CEST m=+0.001205084
|
||||
|
||||
package netxlite
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
const (
|
||||
ECANCELED = unix.ECANCELED
|
||||
ECONNREFUSED = unix.ECONNREFUSED
|
||||
ECONNRESET = unix.ECONNRESET
|
||||
EHOSTUNREACH = unix.EHOSTUNREACH
|
36
internal/netxlite/errno_darwin.go
Normal file
36
internal/netxlite/errno_darwin.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// Generated: 2021-09-28 18:13:54.015321 +0200 CEST m=+0.106996042
|
||||
|
||||
package netxlite
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
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
|
||||
)
|
36
internal/netxlite/errno_freebsd.go
Normal file
36
internal/netxlite/errno_freebsd.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// Generated: 2021-09-28 18:13:54.08291 +0200 CEST m=+0.174585667
|
||||
|
||||
package netxlite
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
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
|
||||
)
|
36
internal/netxlite/errno_ios.go
Normal file
36
internal/netxlite/errno_ios.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// Generated: 2021-09-28 18:13:54.151936 +0200 CEST m=+0.243612834
|
||||
|
||||
package netxlite
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
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
|
||||
)
|
36
internal/netxlite/errno_linux.go
Normal file
36
internal/netxlite/errno_linux.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// Generated: 2021-09-28 18:13:54.230156 +0200 CEST m=+0.321833417
|
||||
|
||||
package netxlite
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
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
|
||||
)
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// Generated: 2021-09-28 12:05:19.918073 +0200 CEST m=+0.154728959
|
||||
// Generated: 2021-09-28 18:13:54.431042 +0200 CEST m=+0.522721376
|
||||
|
||||
package netxlite
|
||||
|
||||
|
@ -16,12 +16,6 @@ func TestClassifySyscallError(t *testing.T) {
|
|||
}
|
||||
})
|
||||
|
||||
t.Run("for ECANCELED", func(t *testing.T) {
|
||||
if v := classifySyscallError(ECANCELED); v != FailureOperationCanceled {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureOperationCanceled, v)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("for ECONNREFUSED", func(t *testing.T) {
|
||||
if v := classifySyscallError(ECONNREFUSED); v != FailureConnectionRefused {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureConnectionRefused, v)
|
||||
|
|
|
@ -1,37 +1,36 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// Generated: 2021-09-28 12:05:19.843209 +0200 CEST m=+0.079863168
|
||||
// Generated: 2021-09-28 18:13:54.317744 +0200 CEST m=+0.409422292
|
||||
|
||||
package netxlite
|
||||
|
||||
import "golang.org/x/sys/windows"
|
||||
|
||||
const (
|
||||
ECANCELED = windows.ECANCELED
|
||||
ECONNREFUSED = windows.ECONNREFUSED
|
||||
ECONNRESET = windows.ECONNRESET
|
||||
EHOSTUNREACH = windows.EHOSTUNREACH
|
||||
ETIMEDOUT = windows.ETIMEDOUT
|
||||
EAFNOSUPPORT = windows.EAFNOSUPPORT
|
||||
EADDRINUSE = windows.EADDRINUSE
|
||||
EADDRNOTAVAIL = windows.EADDRNOTAVAIL
|
||||
EISCONN = windows.EISCONN
|
||||
EFAULT = windows.EFAULT
|
||||
EBADF = windows.EBADF
|
||||
ECONNABORTED = windows.ECONNABORTED
|
||||
EALREADY = windows.EALREADY
|
||||
EDESTADDRREQ = windows.EDESTADDRREQ
|
||||
EINTR = windows.EINTR
|
||||
EINVAL = windows.EINVAL
|
||||
EMSGSIZE = windows.EMSGSIZE
|
||||
ENETDOWN = windows.ENETDOWN
|
||||
ENETRESET = windows.ENETRESET
|
||||
ENETUNREACH = windows.ENETUNREACH
|
||||
ENOBUFS = windows.ENOBUFS
|
||||
ENOPROTOOPT = windows.ENOPROTOOPT
|
||||
ENOTSOCK = windows.ENOTSOCK
|
||||
ENOTCONN = windows.ENOTCONN
|
||||
EWOULDBLOCK = windows.EWOULDBLOCK
|
||||
EACCES = windows.EACCES
|
||||
EPROTONOSUPPORT = windows.EPROTONOSUPPORT
|
||||
EPROTOTYPE = windows.EPROTOTYPE
|
||||
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
|
||||
)
|
||||
|
|
|
@ -59,7 +59,6 @@ func (es *ErrorSpec) IsSystemError() bool {
|
|||
|
||||
// Specs contains all the error specs.
|
||||
var Specs = []*ErrorSpec{
|
||||
NewSystemError("ECANCELED", "operation_canceled"),
|
||||
NewSystemError("ECONNREFUSED", "connection_refused"),
|
||||
NewSystemError("ECONNRESET", "connection_reset"),
|
||||
NewSystemError("EHOSTUNREACH", "host_unreachable"),
|
||||
|
@ -138,20 +137,20 @@ func gofmt(filename string) {
|
|||
}
|
||||
}
|
||||
|
||||
func writeSystemSpecificFile(kind string) {
|
||||
func writeSystemSpecificFile(kind, library, prefix string) {
|
||||
filename := "errno_" + kind + ".go"
|
||||
filep := fileCreate(filename)
|
||||
fileWrite(filep, "// Code generated by go generate; DO NOT EDIT.\n")
|
||||
filePrintf(filep, "// Generated: %+v\n\n", time.Now())
|
||||
fileWrite(filep, "package netxlite\n\n")
|
||||
filePrintf(filep, "import \"golang.org/x/sys/%s\"\n\n", kind)
|
||||
filePrintf(filep, "import \"golang.org/x/sys/%s\"\n\n", library)
|
||||
fileWrite(filep, "const (\n")
|
||||
for _, spec := range Specs {
|
||||
if !spec.IsSystemError() {
|
||||
continue
|
||||
}
|
||||
filePrintf(filep, "\t%s = %s.%s\n",
|
||||
spec.AsErrnoName(), kind, spec.AsErrnoName())
|
||||
filePrintf(filep, "\t%s = %s.%s%s\n",
|
||||
spec.AsErrnoName(), library, prefix, spec.AsErrnoName())
|
||||
}
|
||||
fileWrite(filep, ")\n\n")
|
||||
fileClose(filep)
|
||||
|
@ -277,8 +276,12 @@ func writeGenericTestFile() {
|
|||
}
|
||||
|
||||
func main() {
|
||||
writeSystemSpecificFile("unix")
|
||||
writeSystemSpecificFile("windows")
|
||||
writeSystemSpecificFile("android", "unix", "")
|
||||
writeSystemSpecificFile("darwin", "unix", "")
|
||||
writeSystemSpecificFile("freebsd", "unix", "")
|
||||
writeSystemSpecificFile("ios", "unix", "")
|
||||
writeSystemSpecificFile("linux", "unix", "")
|
||||
writeSystemSpecificFile("windows", "windows", "WSA")
|
||||
writeGenericFile()
|
||||
writeGenericTestFile()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user