Skip to content

Commit

Permalink
chore: sync with ooni/[email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Mar 26, 2024
1 parent b120dc7 commit bbd48d3
Show file tree
Hide file tree
Showing 632 changed files with 74,633 additions and 15,148 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "1.20.12"
go-version: "1.20.14"
- run: go build ./...
2 changes: 1 addition & 1 deletion UPSTREAM
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.20.0
v3.21.0-alpha
36 changes: 18 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ go 1.20

require (
filippo.io/age v1.1.1
github.com/Psiphon-Labs/psiphon-tunnel-core v1.0.11-0.20231206204740-a8e5fc0cf6c7
github.com/Psiphon-Labs/psiphon-tunnel-core v1.0.11-0.20240312131609-91e2a902d867
github.com/apex/log v1.9.0
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
github.com/cloudflare/circl v1.3.6
github.com/cloudflare/circl v1.3.7
github.com/cretz/bine v0.2.0
github.com/dop251/goja v0.0.0-20231027120936-b396bb4c349d
github.com/dop251/goja_nodejs v0.0.0-20231122114759-e84d9a924c5c
Expand All @@ -16,27 +16,27 @@ require (
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/gorilla/websocket v1.5.1
github.com/hexops/gotextdiff v1.0.3
github.com/miekg/dns v1.1.57
github.com/miekg/dns v1.1.58
github.com/montanaflynn/stats v0.7.1
github.com/ooni/netem v0.0.0-20231213064826-3cc1ea5e942c
github.com/ooni/oocrypto v0.5.7
github.com/ooni/oohttp v0.6.7
github.com/ooni/probe-assets v0.21.0
github.com/ooni/netem v0.0.0-20240208095707-608dcbcd82b8
github.com/ooni/oocrypto v0.5.8
github.com/ooni/oohttp v0.6.8
github.com/ooni/probe-assets v0.22.0
github.com/pborman/getopt/v2 v2.1.0
github.com/pion/stun v0.6.1
github.com/pkg/errors v0.9.1
github.com/quic-go/quic-go v0.40.1
github.com/rogpeppe/go-internal v1.11.0
github.com/rogpeppe/go-internal v1.12.0
github.com/rubenv/sql-migrate v1.5.2
github.com/schollz/progressbar/v3 v3.14.1
github.com/schollz/progressbar/v3 v3.14.2
github.com/upper/db/v4 v4.7.0
gitlab.com/yawning/obfs4.git v0.0.0-20231012084234-c3e2d44b1033
gitlab.com/yawning/utls.git v0.0.12-1
gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/goptlib v1.5.0
gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2 v2.6.1
golang.org/x/crypto v0.16.0
golang.org/x/net v0.19.0
golang.org/x/sys v0.15.0
golang.org/x/crypto v0.21.0
golang.org/x/net v0.22.0
golang.org/x/sys v0.18.0
)

require (
Expand All @@ -57,7 +57,7 @@ require (
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/pprof v0.0.0-20231212022811-ec68065c825e // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/libp2p/go-reuseport v0.4.0 // indirect
Expand All @@ -74,7 +74,7 @@ require (
github.com/refraction-networking/conjure v0.7.10 // indirect
github.com/refraction-networking/ed25519 v0.1.2 // indirect
github.com/refraction-networking/obfs4 v0.1.2 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/segmentio/fasthash v1.0.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.8.4 // indirect
Expand Down Expand Up @@ -111,7 +111,7 @@ require (
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/klauspost/reedsolomon v1.11.8 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-sqlite3 v1.14.18
github.com/mattn/go-sqlite3 v1.14.22
github.com/oschwald/maxminddb-golang v1.12.0
github.com/pion/datachannel v1.5.5 // indirect
github.com/pion/dtls/v2 v2.2.8 // indirect
Expand Down Expand Up @@ -146,8 +146,8 @@ require (
github.com/xtaci/smux v1.5.24 // indirect
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.16.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
golang.org/x/tools v0.17.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
)
78 changes: 39 additions & 39 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/bytecounter/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

type byteCounterSessionKey struct{}

// ContextSessionByteCounter retrieves the session byte counter from the context
// ContextSessionByteCounter retrieves the possibly-nil session byte counter from the context.
func ContextSessionByteCounter(ctx context.Context) *Counter {
counter, _ := ctx.Value(byteCounterSessionKey{}).(*Counter)
return counter
Expand All @@ -24,7 +24,7 @@ func WithSessionByteCounter(ctx context.Context, counter *Counter) context.Conte

type byteCounterExperimentKey struct{}

// ContextExperimentByteCounter retrieves the experiment byte counter from the context
// ContextExperimentByteCounter retrieves the possibly-nil experiment byte counter from the context.
func ContextExperimentByteCounter(ctx context.Context) *Counter {
counter, _ := ctx.Value(byteCounterExperimentKey{}).(*Counter)
return counter
Expand Down
5 changes: 2 additions & 3 deletions pkg/bytecounter/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ import (
// MaybeWrapWithContextAwareDialer wraps the given dialer with a ContextAwareDialer
// if the enabled argument is true and otherwise just returns the given dialer.
//
// # Bug
// # Caveat
//
// This implementation cannot properly account for the bytes that are sent by
// persistent connections, because they stick to the counters set when the
// connection was established. This typically means we miss the bytes sent and
// received when submitting a measurement. Such bytes are specifically not
// seen by the experiment specific byte counter.
//
// For this reason, this implementation may be heavily changed/removed
// in the future (<- this message is now ~two years old, though).
// As such, this implementation should only be used when measuring.
func MaybeWrapWithContextAwareDialer(enabled bool, dialer model.Dialer) model.Dialer {
if !enabled {
return dialer
Expand Down
50 changes: 49 additions & 1 deletion pkg/bytecounter/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,59 @@ import (
"github.com/ooni/probe-engine/pkg/netxlite"
)

// WrapWithContextAwareSystemResolver wraps the given resolver with a resolver that
// is aware of context-byte counting. See MaybeWrapSystemResolver for a list of caveats.
func WrapWithContextAwareSystemResolver(reso model.Resolver) model.Resolver {
return &ContextAwareSystemResolver{reso}
}

// ContextAwareSystemResolver is a [model.Resolver] that knows how to count bytes
// sent and received. We typically use this for the system resolver only because for
// other resolvers we are better off just wrapping their connections.
type ContextAwareSystemResolver struct {
R model.Resolver
}

// Address implements model.Resolver.
func (r *ContextAwareSystemResolver) Address() string {
return r.R.Address()
}

// CloseIdleConnections implements model.Resolver.
func (r *ContextAwareSystemResolver) CloseIdleConnections() {
r.R.CloseIdleConnections()
}

func (r *ContextAwareSystemResolver) wrap(ctx context.Context) model.Resolver {
return MaybeWrapSystemResolver(MaybeWrapSystemResolver(
r.R, ContextSessionByteCounter(ctx)), ContextExperimentByteCounter(ctx))
}

// LookupHTTPS implements model.Resolver.
func (r *ContextAwareSystemResolver) LookupHTTPS(ctx context.Context, domain string) (*model.HTTPSSvc, error) {
return r.wrap(ctx).LookupHTTPS(ctx, domain)
}

// LookupHost implements model.Resolver.
func (r *ContextAwareSystemResolver) LookupHost(ctx context.Context, hostname string) (addrs []string, err error) {
return r.wrap(ctx).LookupHost(ctx, hostname)
}

// LookupNS implements model.Resolver.
func (r *ContextAwareSystemResolver) LookupNS(ctx context.Context, domain string) ([]*net.NS, error) {
return r.wrap(ctx).LookupNS(ctx, domain)
}

// Network implements model.Resolver.
func (r *ContextAwareSystemResolver) Network() string {
return r.R.Network()
}

// MaybeWrapSystemResolver takes in input a Resolver and either wraps it
// to perform byte counting, if this counter is not nil, or just returns to the
// caller the original resolver, when the counter is nil.
//
// # Bug
// # Caveat
//
// The returned resolver will only approximately estimate the bytes
// sent and received by this resolver if this resolver is the system
Expand Down
Loading

0 comments on commit bbd48d3

Please sign in to comment.