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:
Simone Basso 2022-08-22 11:50:58 +02:00 committed by GitHub
parent 9ffa124511
commit 208ffa253b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 113 additions and 37 deletions

View File

@ -15,7 +15,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

View File

@ -22,7 +22,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

View File

@ -15,7 +15,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

27
.github/workflows/go1.19.yml vendored Normal file
View File

@ -0,0 +1,27 @@
# Interim build script checking for go1.19
#
# Psiphon not working with go1.19: TODO(https://github.com/ooni/probe/issues/2222)
#
name: go1.19
on:
pull_request:
push:
branches:
- "master"
- "release/**"
jobs:
build_and_test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- run: go install golang.org/dl/go1.19@latest
- run: $(go env GOPATH)/bin/go1.19 download
- run: $(go env GOPATH)/bin/go1.19 build -v ./...
- run: $(go env GOPATH)/bin/go1.19 test -short -race -tags shaping ./...

View File

@ -19,7 +19,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

View File

@ -22,7 +22,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

View File

@ -15,7 +15,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

View File

@ -22,7 +22,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

View File

@ -27,7 +27,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

View File

@ -19,7 +19,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

View File

@ -15,7 +15,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

View File

@ -15,7 +15,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

View File

@ -15,7 +15,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

View File

@ -15,7 +15,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

View File

@ -15,7 +15,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

View File

@ -15,7 +15,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

View File

@ -21,7 +21,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

View File

@ -19,7 +19,7 @@ jobs:
id: goversion
run: echo ::set-output name=version::$(cat GOVERSION)
- uses: actions/setup-go@v1
- uses: actions/setup-go@v3
with:
go-version: "${{ steps.goversion.outputs.version }}"

View File

@ -57,6 +57,11 @@ Be sure you have:
2. a C compiler (Mingw-w64 for Windows).
### Caveats
As of 2022-08-22, building with go1.19 will not include [Psiphon](https://psiphon.ca/) as
a dependency. Fixing this issue is TODO(https://github.com/ooni/probe/issues/2222).
### ooniprobe
Ooniprobe is the official CLI client. Compile using:

View File

@ -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{

View File

@ -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.

View File

@ -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
}

View File

@ -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",
)
}

View File

@ -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"

View File

@ -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")

View File

@ -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{