Skip to content

Commit

Permalink
fix: disable psiphon when building with go1.19 (#871)
Browse files Browse the repository at this point in the history
Part of ooni/probe#2211.

See also ooni/probe#2222, which
describes the issue we have with psiphon and go1.19.
  • Loading branch information
bassosimone committed Aug 22, 2022
1 parent 9ffa124 commit 208ffa2
Show file tree
Hide file tree
Showing 26 changed files with 113 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/alltests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/go1.19.yml
Original file line number Diff line number Diff line change
@@ -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 ./...

2 changes: 1 addition & 1 deletion .github/workflows/gosec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jafar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/miniooni.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/oohelperd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qafbmessenger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qahhfm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qahirl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qatelegram.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qawebconnectivity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qawhatsapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tarball.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
5 changes: 5 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"net/http"
"runtime"
"strings"
"testing"

Expand Down Expand Up @@ -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{
Expand Down
15 changes: 0 additions & 15 deletions internal/tunnel/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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.
Expand Down
17 changes: 16 additions & 1 deletion internal/tunnel/psiphon.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
19 changes: 19 additions & 0 deletions internal/tunnel/psiphon_go119.go
Original file line number Diff line number Diff line change
@@ -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",
)
}
6 changes: 6 additions & 0 deletions internal/tunnel/psiphon_integration_test.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
18 changes: 14 additions & 4 deletions internal/tunnel/psiphon_test.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions internal/tunnel/tunnel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package tunnel_test
import (
"context"
"errors"
"runtime"
"strings"
"testing"

"github.com/ooni/probe-cli/v3/internal/tunnel"
Expand All @@ -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{
Expand Down

0 comments on commit 208ffa2

Please sign in to comment.