fix: disable psiphon when building with go1.19 (#871)
Part of https://github.com/ooni/probe/issues/2211. See also https://github.com/ooni/probe/issues/2222, which describes the issue we have with psiphon and go1.19.
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -275,6 +276,9 @@ func TestGetterWithCancelledContextNoFollowRedirects(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetterWithCancelledContextCannotStartTunnel(t *testing.T) {
|
||||
if strings.HasPrefix(runtime.Version(), "go1.19") {
|
||||
t.Skip("TODO(https://github.com/ooni/probe/issues/2222)")
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel() // fail immediately
|
||||
g := urlgetter.Getter{
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/cretz/bine/control"
|
||||
"github.com/cretz/bine/tor"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/psiphon/tunnel-core/ClientLibrary/clientlib"
|
||||
"golang.org/x/sys/execabs"
|
||||
)
|
||||
|
||||
@@ -60,10 +59,6 @@ type Config struct {
|
||||
// testSocks5New allows us to mock socks5.New in testing code.
|
||||
testSocks5New func(conf *socks5.Config) (*socks5.Server, error)
|
||||
|
||||
// testStartPsiphon allows us to mock psiphon's clientlib.StartTunnel.
|
||||
testStartPsiphon func(ctx context.Context, config []byte,
|
||||
workdir string) (*clientlib.PsiphonTunnel, error)
|
||||
|
||||
// testTorStart allows us to mock tor.Start.
|
||||
testTorStart func(ctx context.Context, conf *tor.StartConf) (*tor.Tor, error)
|
||||
|
||||
@@ -119,16 +114,6 @@ func (c *Config) socks5New(conf *socks5.Config) (*socks5.Server, error) {
|
||||
return socks5.New(conf)
|
||||
}
|
||||
|
||||
// startPsiphon calls either testStartPsiphon or psiphon's clientlib.StartTunnel.
|
||||
func (c *Config) startPsiphon(ctx context.Context, config []byte,
|
||||
workdir string) (*clientlib.PsiphonTunnel, error) {
|
||||
if c.testStartPsiphon != nil {
|
||||
return c.testStartPsiphon(ctx, config, workdir)
|
||||
}
|
||||
return clientlib.StartTunnel(ctx, config, "", clientlib.Parameters{
|
||||
DataRootDirectory: &workdir}, nil, nil)
|
||||
}
|
||||
|
||||
// ooniTorBinaryEnv is the name of the environment variable
|
||||
// we're using to get the path to the tor binary when we are
|
||||
// being run by the ooni/probe-desktop application.
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
//go:build !go1.19
|
||||
|
||||
package tunnel
|
||||
|
||||
//
|
||||
// Psiphon not working with go1.19
|
||||
//
|
||||
// TODO(https://github.com/ooni/probe/issues/2222)
|
||||
//
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
@@ -11,6 +19,13 @@ import (
|
||||
"github.com/ooni/psiphon/tunnel-core/ClientLibrary/clientlib"
|
||||
)
|
||||
|
||||
// mockableStartPsiphon allows us to test for psiphon startup failures.
|
||||
var mockableStartPsiphon = func(
|
||||
ctx context.Context, config []byte, workdir string) (*clientlib.PsiphonTunnel, error) {
|
||||
return clientlib.StartTunnel(ctx, config, "", clientlib.Parameters{
|
||||
DataRootDirectory: &workdir}, nil, nil)
|
||||
}
|
||||
|
||||
// psiphonTunnel is a psiphon tunnel
|
||||
type psiphonTunnel struct {
|
||||
// bootstrapTime is the bootstrapTime of the bootstrap
|
||||
@@ -53,7 +68,7 @@ func psiphonStart(ctx context.Context, config *Config) (Tunnel, DebugInfo, error
|
||||
return nil, debugInfo, err
|
||||
}
|
||||
start := time.Now()
|
||||
tunnel, err := config.startPsiphon(ctx, configJSON, workdir)
|
||||
tunnel, err := mockableStartPsiphon(ctx, configJSON, workdir)
|
||||
if err != nil {
|
||||
return nil, debugInfo, err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//go:build go1.19
|
||||
|
||||
package tunnel
|
||||
|
||||
//
|
||||
// Psiphon not working with go1.19: TODO(https://github.com/ooni/probe/issues/2222)
|
||||
//
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// psiphonStart starts the psiphon tunnel.
|
||||
func psiphonStart(ctx context.Context, config *Config) (Tunnel, DebugInfo, error) {
|
||||
return nil, DebugInfo{}, errors.New(
|
||||
"psiphon is disabled when building with go1.19: see https://github.com/ooni/probe/issues/2222 for more information",
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
//go:build !go1.19
|
||||
|
||||
package tunnel_test
|
||||
|
||||
//
|
||||
// Psiphon not working with go1.19: TODO(https://github.com/ooni/probe/issues/2222)
|
||||
//
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
//go:build !go1.19
|
||||
|
||||
package tunnel
|
||||
|
||||
//
|
||||
// Psiphon not working with go1.19: TODO(https://github.com/ooni/probe/issues/2222)
|
||||
//
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
@@ -82,13 +88,17 @@ func TestPsiphonStartFailure(t *testing.T) {
|
||||
sess := &MockableSession{
|
||||
Result: []byte(`{}`),
|
||||
}
|
||||
oldStartPsiphon := mockableStartPsiphon
|
||||
defer func() {
|
||||
mockableStartPsiphon = oldStartPsiphon
|
||||
}()
|
||||
mockableStartPsiphon = func(ctx context.Context, config []byte,
|
||||
workdir string) (*clientlib.PsiphonTunnel, error) {
|
||||
return nil, expected
|
||||
}
|
||||
tunnel, _, err := psiphonStart(context.Background(), &Config{
|
||||
Session: sess,
|
||||
TunnelDir: "testdata",
|
||||
testStartPsiphon: func(ctx context.Context, config []byte,
|
||||
workdir string) (*clientlib.PsiphonTunnel, error) {
|
||||
return nil, expected
|
||||
},
|
||||
})
|
||||
if !errors.Is(err, expected) {
|
||||
t.Fatal("not the error we expected")
|
||||
|
||||
@@ -3,6 +3,8 @@ package tunnel_test
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/tunnel"
|
||||
@@ -23,6 +25,9 @@ func TestStartNoTunnel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStartPsiphonWithCancelledContext(t *testing.T) {
|
||||
if strings.HasPrefix(runtime.Version(), "go1.19") {
|
||||
t.Skip("TODO(https://github.com/ooni/probe/issues/2222)")
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel() // fail immediately
|
||||
tun, _, err := tunnel.Start(ctx, &tunnel.Config{
|
||||
|
||||
Reference in New Issue
Block a user