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"
|
_ "embed"
|
||||||
|
|
||||||
"filippo.io/age"
|
"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
|
//go:embed psiphon-config.json.age
|
||||||
|
@ -35,7 +35,7 @@ func (s *sessionTunnelEarlySession) FetchPsiphonConfig(ctx context.Context) ([]b
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return iox.ReadAllContext(ctx, output)
|
return netxlite.ReadAllContext(ctx, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchPsiphonConfig decrypts psiphonConfigJSONAge using
|
// FetchPsiphonConfig decrypts psiphonConfigJSONAge using
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Code generated by go generate; DO NOT EDIT.
|
// 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
|
// https://curl.haxx.se/ca/cacert.pem
|
||||||
|
|
||||||
package netxlite
|
package netxlite
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Code generated by go generate; DO NOT EDIT.
|
// 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
|
package netxlite
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ const (
|
||||||
//
|
//
|
||||||
// System errors
|
// System errors
|
||||||
//
|
//
|
||||||
FailureOperationCanceled = "operation_canceled"
|
|
||||||
FailureConnectionRefused = "connection_refused"
|
FailureConnectionRefused = "connection_refused"
|
||||||
FailureConnectionReset = "connection_reset"
|
FailureConnectionReset = "connection_reset"
|
||||||
FailureHostUnreachable = "host_unreachable"
|
FailureHostUnreachable = "host_unreachable"
|
||||||
|
@ -67,7 +66,6 @@ const (
|
||||||
// failureMap lists all failures so we can match them
|
// failureMap lists all failures so we can match them
|
||||||
// when they are wrapped by quic.TransportError.
|
// when they are wrapped by quic.TransportError.
|
||||||
var failuresMap = map[string]string{
|
var failuresMap = map[string]string{
|
||||||
"operation_canceled": "operation_canceled",
|
|
||||||
"connection_refused": "connection_refused",
|
"connection_refused": "connection_refused",
|
||||||
"connection_reset": "connection_reset",
|
"connection_reset": "connection_reset",
|
||||||
"host_unreachable": "host_unreachable",
|
"host_unreachable": "host_unreachable",
|
||||||
|
@ -120,8 +118,6 @@ func classifySyscallError(err error) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
switch errno {
|
switch errno {
|
||||||
case ECANCELED:
|
|
||||||
return FailureOperationCanceled
|
|
||||||
case ECONNREFUSED:
|
case ECONNREFUSED:
|
||||||
return FailureConnectionRefused
|
return FailureConnectionRefused
|
||||||
case ECONNRESET:
|
case ECONNRESET:
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
// Code generated by go generate; DO NOT EDIT.
|
// 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
|
package netxlite
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ECANCELED = unix.ECANCELED
|
|
||||||
ECONNREFUSED = unix.ECONNREFUSED
|
ECONNREFUSED = unix.ECONNREFUSED
|
||||||
ECONNRESET = unix.ECONNRESET
|
ECONNRESET = unix.ECONNRESET
|
||||||
EHOSTUNREACH = unix.EHOSTUNREACH
|
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.
|
// 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
|
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) {
|
t.Run("for ECONNREFUSED", func(t *testing.T) {
|
||||||
if v := classifySyscallError(ECONNREFUSED); v != FailureConnectionRefused {
|
if v := classifySyscallError(ECONNREFUSED); v != FailureConnectionRefused {
|
||||||
t.Fatalf("expected '%s', got '%s'", FailureConnectionRefused, v)
|
t.Fatalf("expected '%s', got '%s'", FailureConnectionRefused, v)
|
||||||
|
|
|
@ -1,37 +1,36 @@
|
||||||
// Code generated by go generate; DO NOT EDIT.
|
// 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
|
package netxlite
|
||||||
|
|
||||||
import "golang.org/x/sys/windows"
|
import "golang.org/x/sys/windows"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ECANCELED = windows.ECANCELED
|
ECONNREFUSED = windows.WSAECONNREFUSED
|
||||||
ECONNREFUSED = windows.ECONNREFUSED
|
ECONNRESET = windows.WSAECONNRESET
|
||||||
ECONNRESET = windows.ECONNRESET
|
EHOSTUNREACH = windows.WSAEHOSTUNREACH
|
||||||
EHOSTUNREACH = windows.EHOSTUNREACH
|
ETIMEDOUT = windows.WSAETIMEDOUT
|
||||||
ETIMEDOUT = windows.ETIMEDOUT
|
EAFNOSUPPORT = windows.WSAEAFNOSUPPORT
|
||||||
EAFNOSUPPORT = windows.EAFNOSUPPORT
|
EADDRINUSE = windows.WSAEADDRINUSE
|
||||||
EADDRINUSE = windows.EADDRINUSE
|
EADDRNOTAVAIL = windows.WSAEADDRNOTAVAIL
|
||||||
EADDRNOTAVAIL = windows.EADDRNOTAVAIL
|
EISCONN = windows.WSAEISCONN
|
||||||
EISCONN = windows.EISCONN
|
EFAULT = windows.WSAEFAULT
|
||||||
EFAULT = windows.EFAULT
|
EBADF = windows.WSAEBADF
|
||||||
EBADF = windows.EBADF
|
ECONNABORTED = windows.WSAECONNABORTED
|
||||||
ECONNABORTED = windows.ECONNABORTED
|
EALREADY = windows.WSAEALREADY
|
||||||
EALREADY = windows.EALREADY
|
EDESTADDRREQ = windows.WSAEDESTADDRREQ
|
||||||
EDESTADDRREQ = windows.EDESTADDRREQ
|
EINTR = windows.WSAEINTR
|
||||||
EINTR = windows.EINTR
|
EINVAL = windows.WSAEINVAL
|
||||||
EINVAL = windows.EINVAL
|
EMSGSIZE = windows.WSAEMSGSIZE
|
||||||
EMSGSIZE = windows.EMSGSIZE
|
ENETDOWN = windows.WSAENETDOWN
|
||||||
ENETDOWN = windows.ENETDOWN
|
ENETRESET = windows.WSAENETRESET
|
||||||
ENETRESET = windows.ENETRESET
|
ENETUNREACH = windows.WSAENETUNREACH
|
||||||
ENETUNREACH = windows.ENETUNREACH
|
ENOBUFS = windows.WSAENOBUFS
|
||||||
ENOBUFS = windows.ENOBUFS
|
ENOPROTOOPT = windows.WSAENOPROTOOPT
|
||||||
ENOPROTOOPT = windows.ENOPROTOOPT
|
ENOTSOCK = windows.WSAENOTSOCK
|
||||||
ENOTSOCK = windows.ENOTSOCK
|
ENOTCONN = windows.WSAENOTCONN
|
||||||
ENOTCONN = windows.ENOTCONN
|
EWOULDBLOCK = windows.WSAEWOULDBLOCK
|
||||||
EWOULDBLOCK = windows.EWOULDBLOCK
|
EACCES = windows.WSAEACCES
|
||||||
EACCES = windows.EACCES
|
EPROTONOSUPPORT = windows.WSAEPROTONOSUPPORT
|
||||||
EPROTONOSUPPORT = windows.EPROTONOSUPPORT
|
EPROTOTYPE = windows.WSAEPROTOTYPE
|
||||||
EPROTOTYPE = windows.EPROTOTYPE
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -59,7 +59,6 @@ func (es *ErrorSpec) IsSystemError() bool {
|
||||||
|
|
||||||
// Specs contains all the error specs.
|
// Specs contains all the error specs.
|
||||||
var Specs = []*ErrorSpec{
|
var Specs = []*ErrorSpec{
|
||||||
NewSystemError("ECANCELED", "operation_canceled"),
|
|
||||||
NewSystemError("ECONNREFUSED", "connection_refused"),
|
NewSystemError("ECONNREFUSED", "connection_refused"),
|
||||||
NewSystemError("ECONNRESET", "connection_reset"),
|
NewSystemError("ECONNRESET", "connection_reset"),
|
||||||
NewSystemError("EHOSTUNREACH", "host_unreachable"),
|
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"
|
filename := "errno_" + kind + ".go"
|
||||||
filep := fileCreate(filename)
|
filep := fileCreate(filename)
|
||||||
fileWrite(filep, "// Code generated by go generate; DO NOT EDIT.\n")
|
fileWrite(filep, "// Code generated by go generate; DO NOT EDIT.\n")
|
||||||
filePrintf(filep, "// Generated: %+v\n\n", time.Now())
|
filePrintf(filep, "// Generated: %+v\n\n", time.Now())
|
||||||
fileWrite(filep, "package netxlite\n\n")
|
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")
|
fileWrite(filep, "const (\n")
|
||||||
for _, spec := range Specs {
|
for _, spec := range Specs {
|
||||||
if !spec.IsSystemError() {
|
if !spec.IsSystemError() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
filePrintf(filep, "\t%s = %s.%s\n",
|
filePrintf(filep, "\t%s = %s.%s%s\n",
|
||||||
spec.AsErrnoName(), kind, spec.AsErrnoName())
|
spec.AsErrnoName(), library, prefix, spec.AsErrnoName())
|
||||||
}
|
}
|
||||||
fileWrite(filep, ")\n\n")
|
fileWrite(filep, ")\n\n")
|
||||||
fileClose(filep)
|
fileClose(filep)
|
||||||
|
@ -277,8 +276,12 @@ func writeGenericTestFile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
writeSystemSpecificFile("unix")
|
writeSystemSpecificFile("android", "unix", "")
|
||||||
writeSystemSpecificFile("windows")
|
writeSystemSpecificFile("darwin", "unix", "")
|
||||||
|
writeSystemSpecificFile("freebsd", "unix", "")
|
||||||
|
writeSystemSpecificFile("ios", "unix", "")
|
||||||
|
writeSystemSpecificFile("linux", "unix", "")
|
||||||
|
writeSystemSpecificFile("windows", "windows", "WSA")
|
||||||
writeGenericFile()
|
writeGenericFile()
|
||||||
writeGenericTestFile()
|
writeGenericTestFile()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user