Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ require (
github.com/pion/stun v0.6.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.24.1
github.com/quic-go/quic-go v0.43.1
github.com/quic-go/quic-go v0.56.0
github.com/rogpeppe/go-internal v1.15.0
github.com/rubenv/sql-migrate v1.8.1
github.com/schollz/progressbar/v3 v3.19.1
Expand Down Expand Up @@ -105,7 +105,6 @@ require (
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.7.0-rc.1 // indirect
github.com/golang/protobuf v1.5.4 // indirect
Expand All @@ -126,7 +125,7 @@ require (
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/mroth/weightedrand v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/ginkgo/v2 v2.12.0 // indirect
github.com/onsi/gomega v1.27.10 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pion/datachannel v1.6.0 // indirect
Expand Down Expand Up @@ -155,7 +154,7 @@ require (
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.70.1 // indirect
github.com/prometheus/procfs v0.21.1 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qpack v0.5.1 // indirect
github.com/realclientip/realclientip-go v1.0.0 // indirect
github.com/refraction-networking/conjure v0.7.11-0.20240130155008-c8df96195ab2 // indirect
github.com/refraction-networking/ed25519 v0.1.2 // indirect
Expand Down Expand Up @@ -187,7 +186,6 @@ require (
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec // indirect
gitlab.com/yawning/edwards25519-extra v0.0.0-20231005122941-2149dcafc266 // indirect
gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/ptutil v0.0.0-20240710081135-6c4d8ed41027 // indirect
go.uber.org/mock v0.4.0 // indirect
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
golang.org/x/mod v0.37.0 // indirect
golang.org/x/sync v0.22.0 // indirect
Expand Down
13 changes: 7 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ github.com/mroth/weightedrand v1.0.0/go.mod h1:3p2SIcC8al1YMzGhAIoXD+r9olo/g/cdJ
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo/v2 v2.12.0 h1:UIVDowFPwpg6yMUpPjGkYvf06K3RAiJXUhCxEwQVHRI=
github.com/onsi/ginkgo/v2 v2.12.0/go.mod h1:ZNEzXISYlqpb8S36iN71ifqLi3vVD1rVJGvWRCJOUpQ=
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
Expand Down Expand Up @@ -424,10 +425,10 @@ github.com/prometheus/common v0.70.1 h1:1HvjP4D5oL3t8RsPlwxA9onvvStjtIHYE5XuuwOi
github.com/prometheus/common v0.70.1/go.mod h1:VdFUQDMZK3VLkurFUVhia6uys/0suUp86TJz5qbJRhc=
github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI=
github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY=
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
github.com/quic-go/quic-go v0.43.1 h1:fLiMNfQVe9q2JvSsiXo4fXOEguXHGGl9+6gLp4RPeZQ=
github.com/quic-go/quic-go v0.43.1/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M=
github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=
github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg=
github.com/quic-go/quic-go v0.56.0 h1:q/TW+OLismmXAehgFLczhCDTYB3bFmua4D9lsNBWxvY=
github.com/quic-go/quic-go v0.56.0/go.mod h1:9gx5KsFQtw2oZ6GZTyh+7YEvOxWCL9WZAepnHxgAo6c=
github.com/realclientip/realclientip-go v1.0.0 h1:+yPxeC0mEaJzq1BfCt2h4BxlyrvIIBzR6suDc3BEF1U=
github.com/realclientip/realclientip-go v1.0.0/go.mod h1:CXnUdVwFRcXFJIRb/dTYqbT7ud48+Pi2pFm80bxDmcI=
github.com/refraction-networking/conjure v0.7.11-0.20240130155008-c8df96195ab2 h1:m2ZH6WV69otVmBpWbk8et3MypHFsjcYXTNrknQKS/PY=
Expand Down Expand Up @@ -573,8 +574,8 @@ gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2 v2.1
gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2 v2.10.1/go.mod h1:DI4jAA1yfL9jzwDsSuW6D5ePrDCzEArQ58vdhKWHxDA=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko=
go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o=
go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ=
go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
Expand Down
3 changes: 1 addition & 2 deletions internal/legacy/measurex/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/ooni/probe-cli/v3/internal/model"
"github.com/ooni/probe-cli/v3/internal/netxlite"
"github.com/ooni/probe-cli/v3/internal/runtimex"
"github.com/quic-go/quic-go"
"golang.org/x/net/publicsuffix"
)

Expand Down Expand Up @@ -95,7 +94,7 @@ func (mx *Measurer) NewHTTPTransportWithTLSConn(
// NewHTTPTransportWithQUICConn creates and wraps an HTTPTransport that
// does not dial and only uses the given QUIC connection.
func (mx *Measurer) NewHTTPTransportWithQUICConn(
logger model.Logger, db WritableDB, qconn quic.EarlyConnection) *HTTPTransportDB {
logger model.Logger, db WritableDB, qconn model.QUICConn) *HTTPTransportDB {
return mx.WrapHTTPTransport(db, netxlite.NewHTTP3Transport(
logger, netxlite.NewSingleUseQUICDialer(qconn),
&tls.Config{}, // #nosec G402 - we need to use a large TLS versions range for measuring
Expand Down
2 changes: 1 addition & 1 deletion internal/legacy/measurex/measurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func (mx *Measurer) quicHandshakeTimeout() time.Duration {
// db to store events rather than creating a temporary one and
// use it to generate a new Measurement.
func (mx *Measurer) QUICHandshakeWithDB(ctx context.Context, db WritableDB,
address string, config *tls.Config) (quic.EarlyConnection, error) {
address string, config *tls.Config) (model.QUICConn, error) {
timeout := mx.quicHandshakeTimeout()
ol := NewOperationLogger(mx.Logger,
"QUICHandshake %s with sni=%s", address, config.ServerName)
Expand Down
2 changes: 1 addition & 1 deletion internal/legacy/measurex/quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ type quicDialerDB struct {
}

func (qh *quicDialerDB) DialContext(ctx context.Context, address string,
tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error) {
tlsConfig *tls.Config, quicConfig *quic.Config) (model.QUICConn, error) {
started := time.Since(qh.begin).Seconds()
var state tls.ConnectionState
netx := &netxlite.Netx{}
Expand Down
4 changes: 2 additions & 2 deletions internal/legacy/tracex/quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (s *Saver) WrapQUICDialer(qd model.QUICDialer) model.QUICDialer {

// DialContext implements QUICDialer.DialContext
func (h *QUICDialerSaver) DialContext(ctx context.Context,
host string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error) {
host string, tlsCfg *tls.Config, cfg *quic.Config) (model.QUICConn, error) {
start := time.Now()
// TODO(bassosimone): in the future we probably want to also save
// information about what versions we're willing to accept.
Expand Down Expand Up @@ -92,7 +92,7 @@ func (h *QUICDialerSaver) CloseIdleConnections() {
}

// quicConnectionState returns the ConnectionState of a QUIC Session.
func quicConnectionState(sess quic.EarlyConnection) tls.ConnectionState {
func quicConnectionState(sess model.QUICConn) tls.ConnectionState {
return sess.ConnectionState().TLS
}

Expand Down
6 changes: 3 additions & 3 deletions internal/legacy/tracex/quic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestQUICDialerSaver(t *testing.T) {

t.Run("on success", func(t *testing.T) {
saver := &Saver{}
returnedConn := &mocks.QUICEarlyConnection{
returnedConn := &mocks.QUICConn{
MockConnectionState: func() quic.ConnectionState {
cs := quic.ConnectionState{}
cs.TLS.CipherSuite = tls.TLS_RSA_WITH_RC4_128_SHA
Expand All @@ -92,7 +92,7 @@ func TestQUICDialerSaver(t *testing.T) {
}
dialer := saver.WrapQUICDialer(&mocks.QUICDialer{
MockDialContext: func(ctx context.Context, address string,
tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error) {
tlsConfig *tls.Config, quicConfig *quic.Config) (model.QUICConn, error) {
return returnedConn, nil
},
})
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestQUICDialerSaver(t *testing.T) {
saver := &Saver{}
dialer := saver.WrapQUICDialer(&mocks.QUICDialer{
MockDialContext: func(ctx context.Context, address string,
tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error) {
tlsConfig *tls.Config, quicConfig *quic.Config) (model.QUICConn, error) {
return nil, expected
},
})
Expand Down
8 changes: 4 additions & 4 deletions internal/measurexlite/quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var _ model.QUICDialer = &quicDialerTrace{}
// DialContext implements model.QUICDialer.DialContext.
func (qdx *quicDialerTrace) DialContext(ctx context.Context,
address string, tlsConfig *tls.Config, quicConfig *quic.Config) (
quic.EarlyConnection, error) {
model.QUICConn, error) {
// TODO(https://github.com/ooni/probe/issues/2665)
return qdx.qd.DialContext(netxlite.ContextWithTrace(ctx, qdx.tx), address, tlsConfig, quicConfig)
}
Expand All @@ -59,7 +59,7 @@ func (tx *Trace) OnQUICHandshakeStart(now time.Time, remoteAddr string, config *
}

// OnQUICHandshakeDone implements model.Trace.OnQUICHandshakeDone
func (tx *Trace) OnQUICHandshakeDone(started time.Time, remoteAddr string, qconn quic.EarlyConnection,
func (tx *Trace) OnQUICHandshakeDone(started time.Time, remoteAddr string, qconn model.QUICConn,
config *tls.Config, err error, finished time.Time) {
t := finished.Sub(tx.ZeroTime())

Expand Down Expand Up @@ -112,8 +112,8 @@ func (tx *Trace) FirstQUICHandshakeOrNil() *model.ArchivalTLSOrQUICHandshakeResu
return ev[0]
}

// MaybeCloseQUICConn is a convenience function for closing a [quic.EarlyConnection] when it is not nil.
func MaybeCloseQUICConn(conn quic.EarlyConnection) (err error) {
// MaybeCloseQUICConn is a convenience function for closing a [model.QUICConn] when it is not nil.
func MaybeCloseQUICConn(conn model.QUICConn) (err error) {
if conn != nil {
err = conn.CloseWithError(0, "")
}
Expand Down
6 changes: 3 additions & 3 deletions internal/measurexlite/quic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestNewQUICDialerWithoutResolver(t *testing.T) {
var hasCorrectTrace bool
underlying := &mocks.QUICDialer{
MockDialContext: func(ctx context.Context, address string, tlsConfig *tls.Config,
quicConfig *quic.Config) (quic.EarlyConnection, error) {
quicConfig *quic.Config) (model.QUICConn, error) {
gotTrace := netxlite.ContextTraceOrDefault(ctx)
hasCorrectTrace = (gotTrace == trace)
return nil, expectedErr
Expand Down Expand Up @@ -370,7 +370,7 @@ func TestFirstQUICHandshake(t *testing.T) {
func TestMaybeCloseQUICConn(t *testing.T) {
type closeQuicTest struct {
name string
input quic.EarlyConnection
input model.QUICConn
called bool
}
var called bool
Expand All @@ -383,7 +383,7 @@ func TestMaybeCloseQUICConn(t *testing.T) {
},
{
name: "with nonnil conn",
input: &mocks.QUICEarlyConnection{
input: &mocks.QUICConn{
MockCloseWithError: func(code quic.ApplicationErrorCode, reason string) error {
called = true
return nil
Expand Down
100 changes: 23 additions & 77 deletions internal/mocks/quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
type QUICDialer struct {
// MockDialContext allows mocking DialContext.
MockDialContext func(ctx context.Context, address string,
tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error)
tlsConfig *tls.Config, quicConfig *quic.Config) (model.QUICConn, error)

// MockCloseIdleConnections allows mocking CloseIdleConnections.
MockCloseIdleConnections func()
Expand All @@ -25,7 +25,7 @@ var _ model.QUICDialer = &QUICDialer{}

// DialContext calls MockDialContext.
func (qcd *QUICDialer) DialContext(ctx context.Context, address string,
tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error) {
tlsConfig *tls.Config, quicConfig *quic.Config) (model.QUICConn, error) {
return qcd.MockDialContext(ctx, address, tlsConfig, quicConfig)
}

Expand All @@ -34,101 +34,47 @@ func (qcd *QUICDialer) CloseIdleConnections() {
qcd.MockCloseIdleConnections()
}

// QUICEarlyConnection is a mockable quic.EarlyConnection.
type QUICEarlyConnection struct {
MockAcceptStream func(context.Context) (quic.Stream, error)
MockAcceptUniStream func(context.Context) (quic.ReceiveStream, error)
MockOpenStream func() (quic.Stream, error)
MockOpenStreamSync func(ctx context.Context) (quic.Stream, error)
MockOpenUniStream func() (quic.SendStream, error)
MockOpenUniStreamSync func(ctx context.Context) (quic.SendStream, error)
// QUICConn is a mockable model.QUICConn.
type QUICConn struct {
MockCloseWithError func(code quic.ApplicationErrorCode, reason string) error
MockHandshakeComplete func() <-chan struct{}
MockConnectionState func() quic.ConnectionState
MockLocalAddr func() net.Addr
MockRemoteAddr func() net.Addr
MockCloseWithError func(code quic.ApplicationErrorCode, reason string) error
MockContext func() context.Context
MockConnectionState func() quic.ConnectionState
MockHandshakeComplete func() <-chan struct{}
MockNextConnection func() quic.Connection
MockSendDatagram func(b []byte) error
MockReceiveDatagram func(ctx context.Context) ([]byte, error)
}

var _ quic.EarlyConnection = &QUICEarlyConnection{}

// AcceptStream calls MockAcceptStream.
func (s *QUICEarlyConnection) AcceptStream(ctx context.Context) (quic.Stream, error) {
return s.MockAcceptStream(ctx)
}

// AcceptUniStream calls MockAcceptUniStream.
func (s *QUICEarlyConnection) AcceptUniStream(ctx context.Context) (quic.ReceiveStream, error) {
return s.MockAcceptUniStream(ctx)
}

// OpenStream calls MockOpenStream.
func (s *QUICEarlyConnection) OpenStream() (quic.Stream, error) {
return s.MockOpenStream()
}

// OpenStreamSync calls MockOpenStreamSync.
func (s *QUICEarlyConnection) OpenStreamSync(ctx context.Context) (quic.Stream, error) {
return s.MockOpenStreamSync(ctx)
}

// OpenUniStream calls MockOpenUniStream.
func (s *QUICEarlyConnection) OpenUniStream() (quic.SendStream, error) {
return s.MockOpenUniStream()
}

// OpenUniStreamSync calls MockOpenUniStreamSync.
func (s *QUICEarlyConnection) OpenUniStreamSync(ctx context.Context) (quic.SendStream, error) {
return s.MockOpenUniStreamSync(ctx)
}

// LocalAddr class MockLocalAddr.
func (c *QUICEarlyConnection) LocalAddr() net.Addr {
return c.MockLocalAddr()
}

// RemoteAddr calls MockRemoteAddr.
func (c *QUICEarlyConnection) RemoteAddr() net.Addr {
return c.MockRemoteAddr()
}
var _ model.QUICConn = &QUICConn{}

// CloseWithError calls MockCloseWithError.
func (c *QUICEarlyConnection) CloseWithError(
func (c *QUICConn) CloseWithError(
code quic.ApplicationErrorCode, reason string) error {
return c.MockCloseWithError(code, reason)
}

// Context calls MockContext.
func (s *QUICEarlyConnection) Context() context.Context {
return s.MockContext()
// HandshakeComplete calls MockHandshakeComplete.
func (c *QUICConn) HandshakeComplete() <-chan struct{} {
return c.MockHandshakeComplete()
}

// ConnectionState calls MockConnectionState.
func (s *QUICEarlyConnection) ConnectionState() quic.ConnectionState {
return s.MockConnectionState()
func (c *QUICConn) ConnectionState() quic.ConnectionState {
return c.MockConnectionState()
}

// HandshakeComplete calls MockHandshakeComplete.
func (s *QUICEarlyConnection) HandshakeComplete() <-chan struct{} {
return s.MockHandshakeComplete()
}

// NextConnection calls MockNextConnection.
func (s *QUICEarlyConnection) NextConnection() quic.Connection {
return s.MockNextConnection()
// LocalAddr calls MockLocalAddr.
func (c *QUICConn) LocalAddr() net.Addr {
return c.MockLocalAddr()
}

// SendDatagram calls MockSendDatagram.
func (s *QUICEarlyConnection) SendDatagram(b []byte) error {
return s.MockSendDatagram(b)
// RemoteAddr calls MockRemoteAddr.
func (c *QUICConn) RemoteAddr() net.Addr {
return c.MockRemoteAddr()
}

// ReceiveDatagram calls MockReceiveDatagram.
func (s *QUICEarlyConnection) ReceiveDatagram(ctx context.Context) ([]byte, error) {
return s.MockReceiveDatagram(ctx)
// Context calls MockContext.
func (c *QUICConn) Context() context.Context {
return c.MockContext()
}

// UDPLikeConn is an UDP conn used by QUIC.
Expand Down
Loading
Loading