Skip to content

Commit 313c4c9

Browse files
committed
Merge remote-tracking branch 'origin/master' into iosbuild
2 parents 189be65 + d9bfb1e commit 313c4c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1095
-577
lines changed

GOVERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.20.8
1+
1.20.10

Readme.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Debian/Ubuntu. Once `ooniprobe` is installed, refer to the
6161
## Developer instructions
6262

6363
This repository requires _exactly_ the Go version mentioned by the
64-
[GOVERSION](GOVERSION) file (i.e., go1.20.8). Using a different version of
64+
[GOVERSION](GOVERSION) file (i.e., go1.20.10). Using a different version of
6565
Go _may_ work as intended but is not recommended: we depend
6666
on packages forked from the standard library; so, it is
6767
more robust to use the same version of Go from which
@@ -88,10 +88,10 @@ sudo apt install golang build-essential ca-certificates git
8888
sudo apt install mingw-w64
8989

9090
# install the required go version binary
91-
go install -v golang.org/dl/go1.20.8@latest
91+
go install -v golang.org/dl/go1.20.10@latest
9292

9393
# fetch the whole go distribution
94-
$HOME/go/bin/go1.20.8 download
94+
$HOME/go/bin/go1.20.10 download
9595
```
9696

9797
### Fedora developer setup
@@ -107,10 +107,10 @@ sudo dnf install golang make gcc gcc-c++ git
107107
sudo dnf install mingw64-gcc mingw64-gcc-c++
108108

109109
# install the required go version binary
110-
go install -v golang.org/dl/go1.20.8@latest
110+
go install -v golang.org/dl/go1.20.10@latest
111111

112112
# fetch the whole go distribution
113-
$HOME/go/bin/go1.20.8 download
113+
$HOME/go/bin/go1.20.10 download
114114
```
115115

116116
### macOS developer setup
@@ -127,10 +127,10 @@ Then, you need to follow these instructions:
127127
brew install go
128128

129129
# install the required go version binary
130-
go install -v golang.org/dl/go1.20.8@latest
130+
go install -v golang.org/dl/go1.20.10@latest
131131

132132
# fetch the whole go distribution
133-
$HOME/go/bin/go1.20.8 download
133+
$HOME/go/bin/go1.20.10 download
134134
```
135135

136136
### Build instructions
@@ -139,7 +139,7 @@ Once you have installed the correct Go version and a C compiler,
139139
you can compile `ooniprobe` using:
140140

141141
```bash
142-
$HOME/go/bin/go1.20.8 build -v -ldflags '-s -w' ./cmd/ooniprobe
142+
$HOME/go/bin/go1.20.10 build -v -ldflags '-s -w' ./cmd/ooniprobe
143143
```
144144

145145
This command will generate a stripped binary called `ooniprobe`
@@ -148,7 +148,7 @@ in the toplevel directory.
148148
Likewise, you can compile `miniooni` using:
149149

150150
```bash
151-
$HOME/go/bin/go1.20.8 build -v -ldflags '-s -w' ./internal/cmd/miniooni
151+
$HOME/go/bin/go1.20.10 build -v -ldflags '-s -w' ./internal/cmd/miniooni
152152
```
153153

154154
This command will generate a stripped binary called `miniooni`
@@ -157,7 +157,7 @@ in the toplevel directory.
157157
And `oohelperd` using:
158158

159159
```bash
160-
$HOME/go/bin/go1.20.8 build -v -ldflags '-s -w' ./internal/cmd/oohelperd
160+
$HOME/go/bin/go1.20.10 build -v -ldflags '-s -w' ./internal/cmd/oohelperd
161161
```
162162

163163
This command will generate a stripped binary called `oohelperd`
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package nettests
2+
3+
// ECHCheck nettest implementation.
4+
type ECHCheck struct{}
5+
6+
// Run starts the nettest.
7+
func (n ECHCheck) Run(ctl *Controller) error {
8+
builder, err := ctl.Session.NewExperimentBuilder("echcheck")
9+
if err != nil {
10+
return err
11+
}
12+
// providing an input containing an empty string causes the experiment
13+
// to recognize the empty string and use the default URL
14+
return ctl.Run(builder, []string{""})
15+
}

cmd/ooniprobe/internal/nettests/groups.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ var All = map[string]Group{
5555
Label: "Experimental Nettests",
5656
Nettests: []Nettest{
5757
DNSCheck{},
58+
ECHCheck{},
5859
STUNReachability{},
60+
RiseupVPN{},
5961
TorSf{},
6062
VanillaTor{},
6163
},

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/cloudflare/circl v1.3.3
1313
github.com/cretz/bine v0.2.0
1414
github.com/fatih/color v1.15.0
15-
github.com/google/go-cmp v0.5.9
15+
github.com/google/go-cmp v0.6.0
1616
github.com/google/gopacket v1.1.19
1717
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
1818
github.com/google/uuid v1.3.1
@@ -24,8 +24,8 @@ require (
2424
github.com/montanaflynn/stats v0.7.1
2525
github.com/ooni/go-libtor v1.1.8
2626
github.com/ooni/netem v0.0.0-20230920215742-15f3ffec0107
27-
github.com/ooni/oocrypto v0.5.4
28-
github.com/ooni/oohttp v0.6.4
27+
github.com/ooni/oocrypto v0.5.5
28+
github.com/ooni/oohttp v0.6.5
2929
github.com/ooni/probe-assets v0.19.0
3030
github.com/pborman/getopt/v2 v2.1.0
3131
github.com/pion/stun v0.6.1
@@ -40,7 +40,7 @@ require (
4040
gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/goptlib v1.5.0
4141
gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2 v2.6.1
4242
golang.org/x/crypto v0.14.0
43-
golang.org/x/net v0.16.0
43+
golang.org/x/net v0.17.0
4444
golang.org/x/sys v0.13.0
4545
)
4646

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
159159
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
160160
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
161161
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
162-
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
163-
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
162+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
163+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
164164
github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8=
165165
github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo=
166166
github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 h1:pUa4ghanp6q4IJHwE9RwLgmVFfReJN+KbQ8ExNEUUoQ=
@@ -326,10 +326,10 @@ github.com/ooni/go-libtor v1.1.8 h1:Wo3V3DVTxl5vZdxtQakqYP+DAHx7pPtAFSl1bnAa08w=
326326
github.com/ooni/go-libtor v1.1.8/go.mod h1:q1YyLwRD9GeMyeerVvwc0vJ2YgwDLTp2bdVcrh/JXyI=
327327
github.com/ooni/netem v0.0.0-20230920215742-15f3ffec0107 h1:PktaCPQ1NYZOaK+J8pQGYiPCYFkGR5H3ZURg9zPkQsI=
328328
github.com/ooni/netem v0.0.0-20230920215742-15f3ffec0107/go.mod h1:5X3Lk4+cnrwrQiYgRlCWXgV33IMDgLaO5s1x0DD/fO0=
329-
github.com/ooni/oocrypto v0.5.4 h1:/AkVZd+aq54+OXgOtWEmK8xgZsFQtlmtPf2VgY20YWw=
330-
github.com/ooni/oocrypto v0.5.4/go.mod h1:HjEQ5pQBl6btcWgAsKKq1tFo8CfBrZu63C/vPAUGIDk=
331-
github.com/ooni/oohttp v0.6.4 h1:QZyOO4e88AzLOHGTgapXmsjtn1EVR7Wl+BtHd8okIf4=
332-
github.com/ooni/oohttp v0.6.4/go.mod h1:RipdYAUiw1UTnpm0ISd0r1Kiv/CGaRUgn08xbK1JgVo=
329+
github.com/ooni/oocrypto v0.5.5 h1:x0wIgtBfghVu8Ok0tR/xVyfHlo646hN1LB/5bzuXcIg=
330+
github.com/ooni/oocrypto v0.5.5/go.mod h1:HjEQ5pQBl6btcWgAsKKq1tFo8CfBrZu63C/vPAUGIDk=
331+
github.com/ooni/oohttp v0.6.5 h1:hjMnX2fGNHYHqh1JmfxoTfnN9JmdgT0fa6yIEjoYhG8=
332+
github.com/ooni/oohttp v0.6.5/go.mod h1:RipdYAUiw1UTnpm0ISd0r1Kiv/CGaRUgn08xbK1JgVo=
333333
github.com/ooni/probe-assets v0.19.0 h1:XloDJQt6uxn6EYVwfWCOnlgsJZbmzO7VPFsJ8RPW8Ns=
334334
github.com/ooni/probe-assets v0.19.0/go.mod h1:m0k2FFzcLfFm7dhgyYkLCUR3R0CoRPr0jcjctDS2+gU=
335335
github.com/oschwald/geoip2-golang v1.9.0 h1:uvD3O6fXAXs+usU+UGExshpdP13GAqp4GBrzN7IgKZc=
@@ -616,8 +616,8 @@ golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ=
616616
golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
617617
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
618618
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
619-
golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos=
620-
golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
619+
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
620+
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
621621
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
622622
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
623623
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

internal/checkincache/checkincache.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package checkincache
33

44
import (
55
"encoding/json"
6+
"fmt"
67
"time"
78

89
"github.com/ooni/probe-cli/v3/internal/model"
@@ -25,6 +26,9 @@ type checkInFlagsWrapper struct {
2526
}
2627

2728
// Store stores the result of the latest check-in in the given key-value store.
29+
//
30+
// We store check-in feature flags in a file called checkinflags.state. These flags
31+
// are valid for 24 hours, after which we consider them stale.
2832
func Store(kvStore model.KeyValueStore, resp *model.OOAPICheckInResult) error {
2933
// store the check-in flags in the key-value store
3034
wrapper := &checkInFlagsWrapper{
@@ -52,3 +56,16 @@ func GetFeatureFlag(kvStore model.KeyValueStore, name string) bool {
5256
}
5357
return wrapper.Flags[name] // works even if map is nil
5458
}
59+
60+
// ExperimentEnabledKey returns the [model.KeyValueStore] key to use to
61+
// know whether a disabled experiment has been enabled via check-in.
62+
func ExperimentEnabledKey(name string) string {
63+
return fmt.Sprintf("%s_enabled", name)
64+
}
65+
66+
// ExperimentEnabled returns whether a given experiment has been enabled by a previous
67+
// execution of check-in. Some experiments are disabled by default for different reasons
68+
// and we use the check-in API to control whether and when they should be enabled.
69+
func ExperimentEnabled(kvStore model.KeyValueStore, name string) bool {
70+
return GetFeatureFlag(kvStore, ExperimentEnabledKey(name))
71+
}

internal/engine/experiment_integration_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"testing"
1414

1515
"github.com/ooni/probe-cli/v3/internal/model"
16+
"github.com/ooni/probe-cli/v3/internal/registry"
1617
)
1718

1819
func TestCreateAll(t *testing.T) {
@@ -21,6 +22,12 @@ func TestCreateAll(t *testing.T) {
2122
}
2223
sess := newSessionForTesting(t)
2324
defer sess.Close()
25+
26+
// Since https://github.com/ooni/probe-cli/pull/1355, some experiments are disabled
27+
// by default and we need an environment variable to instantiate them
28+
os.Setenv(registry.OONI_FORCE_ENABLE_EXPERIMENT, "1")
29+
defer os.Unsetenv(registry.OONI_FORCE_ENABLE_EXPERIMENT)
30+
2431
for _, name := range AllExperiments() {
2532
builder, err := sess.NewExperimentBuilder(name)
2633
if err != nil {

internal/engine/experimentbuilder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (b *experimentBuilder) NewExperiment() model.Experiment {
6262

6363
// newExperimentBuilder creates a new experimentBuilder instance.
6464
func newExperimentBuilder(session *Session, name string) (*experimentBuilder, error) {
65-
factory, err := registry.NewFactory(name)
65+
factory, err := registry.NewFactory(name, session.kvStore, session.logger)
6666
if err != nil {
6767
return nil, err
6868
}

internal/engine/inputloader.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ func StaticBareInputForExperiment(name string) ([]string, error) {
219219
// Implementation note: we may be called from pkg/oonimkall
220220
// with a non-canonical experiment name, so we need to convert
221221
// the experiment name to be canonical before proceeding.
222+
//
223+
// TODO(https://github.com/ooni/probe/issues/1390): serve DNSCheck
224+
// inputs using richer input (aka check-in v2).
225+
//
226+
// TODO(https://github.com/ooni/probe/issues/2557): server STUNReachability
227+
// inputs using richer input (aka check-in v2).
222228
switch registry.CanonicalizeExperimentName(name) {
223229
case "dnscheck":
224230
return dnsCheckDefaultInput, nil

internal/engine/session.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ import (
1111
"sync/atomic"
1212

1313
"github.com/ooni/probe-cli/v3/internal/bytecounter"
14-
"github.com/ooni/probe-cli/v3/internal/checkincache"
1514
"github.com/ooni/probe-cli/v3/internal/enginelocate"
1615
"github.com/ooni/probe-cli/v3/internal/enginenetx"
1716
"github.com/ooni/probe-cli/v3/internal/engineresolver"
1817
"github.com/ooni/probe-cli/v3/internal/kvstore"
1918
"github.com/ooni/probe-cli/v3/internal/model"
2019
"github.com/ooni/probe-cli/v3/internal/platform"
2120
"github.com/ooni/probe-cli/v3/internal/probeservices"
22-
"github.com/ooni/probe-cli/v3/internal/registry"
2321
"github.com/ooni/probe-cli/v3/internal/runtimex"
2422
"github.com/ooni/probe-cli/v3/internal/tunnel"
2523
"github.com/ooni/probe-cli/v3/internal/version"
@@ -406,16 +404,6 @@ var ErrAlreadyUsingProxy = errors.New(
406404
// for the experiment with the given name, or an error if
407405
// there's no such experiment with the given name
408406
func (s *Session) NewExperimentBuilder(name string) (model.ExperimentBuilder, error) {
409-
name = registry.CanonicalizeExperimentName(name)
410-
switch {
411-
case name == "web_connectivity" && checkincache.GetFeatureFlag(s.kvStore, "webconnectivity_0.5"):
412-
// use LTE rather than the normal webconnectivity when the
413-
// feature flag has been set through the check-in API
414-
s.Logger().Infof("using webconnectivity LTE")
415-
416-
default:
417-
// nothing
418-
}
419407
eb, err := newExperimentBuilder(s, name)
420408
if err != nil {
421409
return nil, err

internal/experiment/echcheck/handshake.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"time"
99

1010
"github.com/apex/log"
11+
"github.com/ooni/probe-cli/v3/internal/logx"
1112
"github.com/ooni/probe-cli/v3/internal/measurexlite"
1213
"github.com/ooni/probe-cli/v3/internal/model"
1314
"github.com/ooni/probe-cli/v3/internal/netxlite"
@@ -16,11 +17,13 @@ import (
1617

1718
const echExtensionType uint16 = 0xfe0d
1819

19-
func handshake(ctx context.Context, conn net.Conn, zeroTime time.Time, address string, sni string) *model.ArchivalTLSOrQUICHandshakeResult {
20-
return handshakeWithExtension(ctx, conn, zeroTime, address, sni, []utls.TLSExtension{})
20+
func handshake(ctx context.Context, conn net.Conn, zeroTime time.Time,
21+
address string, sni string, logger model.Logger) *model.ArchivalTLSOrQUICHandshakeResult {
22+
return handshakeWithExtension(ctx, conn, zeroTime, address, sni, []utls.TLSExtension{}, logger)
2123
}
2224

23-
func handshakeWithEch(ctx context.Context, conn net.Conn, zeroTime time.Time, address string, sni string) *model.ArchivalTLSOrQUICHandshakeResult {
25+
func handshakeWithEch(ctx context.Context, conn net.Conn, zeroTime time.Time,
26+
address string, sni string, logger model.Logger) *model.ArchivalTLSOrQUICHandshakeResult {
2427
payload, err := generateGreaseExtension(rand.Reader)
2528
if err != nil {
2629
panic("failed to generate grease ECH: " + err.Error())
@@ -31,18 +34,28 @@ func handshakeWithEch(ctx context.Context, conn net.Conn, zeroTime time.Time, ad
3134
utlsEchExtension.Id = echExtensionType
3235
utlsEchExtension.Data = payload
3336

34-
return handshakeWithExtension(ctx, conn, zeroTime, address, sni, []utls.TLSExtension{&utlsEchExtension})
37+
return handshakeWithExtension(ctx, conn, zeroTime, address, sni, []utls.TLSExtension{&utlsEchExtension}, logger)
3538
}
3639

37-
func handshakeWithExtension(ctx context.Context, conn net.Conn, zeroTime time.Time, address string, sni string, extensions []utls.TLSExtension) *model.ArchivalTLSOrQUICHandshakeResult {
40+
func handshakeMaybePrintWithECH(doprint bool) string {
41+
if doprint {
42+
return "WithECH"
43+
}
44+
return ""
45+
}
46+
47+
func handshakeWithExtension(ctx context.Context, conn net.Conn, zeroTime time.Time, address string, sni string,
48+
extensions []utls.TLSExtension, logger model.Logger) *model.ArchivalTLSOrQUICHandshakeResult {
3849
tlsConfig := genTLSConfig(sni)
3950

4051
handshakerConstructor := newHandshakerWithExtensions(extensions)
4152
tracedHandshaker := handshakerConstructor(log.Log, &utls.HelloFirefox_Auto)
4253

54+
ol := logx.NewOperationLogger(logger, "echcheck: TLSHandshake%s", handshakeMaybePrintWithECH(len(extensions) > 0))
4355
start := time.Now()
4456
maybeTLSConn, err := tracedHandshaker.Handshake(ctx, conn, tlsConfig)
4557
finish := time.Now()
58+
ol.Stop(err)
4659

4760
connState := netxlite.MaybeTLSConnectionState(maybeTLSConn)
4861
return measurexlite.NewArchivalTLSOrQUICHandshakeResult(0, start.Sub(zeroTime), "tcp", address, tlsConfig,

internal/experiment/echcheck/handshake_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"net/url"
1010
"testing"
1111
"time"
12+
13+
"github.com/ooni/probe-cli/v3/internal/model"
1214
)
1315

1416
func TestHandshake(t *testing.T) {
@@ -31,7 +33,7 @@ func TestHandshake(t *testing.T) {
3133
t.Fatal(err)
3234
}
3335

34-
result := handshakeWithEch(ctx, conn, time.Now(), parsed.Host, "example.org")
36+
result := handshakeWithEch(ctx, conn, time.Now(), parsed.Host, "crypto.cloudflare.com", model.DiscardLogger)
3537
if result == nil {
3638
t.Fatal("expected result")
3739
}

0 commit comments

Comments
 (0)