Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

probe-cli: Update to quic-go v0.37.3 #1161

Merged
merged 20 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
90a29b5
update to quic-go v0.35.1
kelmenhorst Jun 18, 2023
baa25c5
(change from v0.34.0): chan instead of context in Connection.Handshak…
kelmenhorst Jun 18, 2023
734b65e
(API change): replace DialEarlyContext with DialEarly
kelmenhorst Jun 18, 2023
2ce5cf6
fix (change from v0.34.0): HandshakeComplete: use ctx.Done() as return
kelmenhorst Jun 18, 2023
07ada0e
(API change): replace Listener interface with pointer to struct
kelmenhorst Jun 18, 2023
188de7f
(API change): replace name mockDialEarlyContext
kelmenhorst Jun 18, 2023
6ef4d33
adapt mockDialEarly signature to quic.DialEarly
kelmenhorst Jun 18, 2023
5adddee
dialEarly: remove unnecessary address parameter
kelmenhorst Jun 18, 2023
762aef6
rename QUICListener to UDPListener
kelmenhorst Jun 19, 2023
17aef9d
rename NewQUICListener to NewUDPListener
kelmenhorst Jun 19, 2023
35c1a52
(API change): Use different mocks.UDPLikeConn for concurrent tests
kelmenhorst Jun 19, 2023
508e925
update to quic-go v0.36.0
kelmenhorst Jun 28, 2023
d2a807c
rename all QUICListeners to UDPListeners
kelmenhorst Jun 28, 2023
9e8887c
upgrade to quic-go 0.37.3
kelmenhorst Aug 7, 2023
a3a0e76
Merge remote-tracking branch 'origin/master' into quic-go-update
kelmenhorst Aug 22, 2023
c2787e2
fix: updated function name NewUDPListener
kelmenhorst Aug 22, 2023
77de949
Merge remote-tracking branch 'origin/master' into quic-go-update
kelmenhorst Aug 24, 2023
dafa58d
Merge branch 'master' into quic-go-update
bassosimone Sep 7, 2023
0d31156
x
bassosimone Sep 7, 2023
936fe24
Merge branch 'master' into quic-go-update
bassosimone Sep 8, 2023
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
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ require (
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.33.0
github.com/quic-go/quic-go v0.37.3
github.com/rogpeppe/go-internal v1.11.0
github.com/rubenv/sql-migrate v1.5.1
github.com/schollz/progressbar/v3 v3.13.1
Expand Down Expand Up @@ -74,7 +74,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-19 v0.3.2 // indirect
github.com/quic-go/qtls-go1-20 v0.2.2 // indirect
github.com/quic-go/qtls-go1-20 v0.3.1 // indirect
github.com/refraction-networking/conjure v0.4.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/segmentio/fasthash v1.0.3 // indirect
Expand Down
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0=
github.com/alecthomas/kingpin/v2 v2.3.2 h1:H0aULhgmSzN8xQ3nX1uxtdlTHYoPLu5AhHxWrKI6ocU=
github.com/alecthomas/kingpin/v2 v2.3.2/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
Expand Down Expand Up @@ -173,6 +174,7 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
Expand Down Expand Up @@ -338,6 +340,7 @@ github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0f
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.2.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/josharian/native v1.0.0 h1:Ts/E8zCSEsG17dUqv7joXJFybuMLjQfWE04tsBODTxk=
Expand All @@ -357,6 +360,8 @@ github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1
github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/keltia/proxy v0.9.3/go.mod h1:fLU4DmBPG0oh0md9fWggE2oG2m7Lchv3eim+GiO3pZY=
github.com/keltia/ripe-atlas v0.0.0-20211221125000-f6eb808d5dc6/go.mod h1:zYa+dM8811qRhclezc/AKX9imyQwPjjSk2cH0xTgTag=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
Expand Down Expand Up @@ -448,6 +453,7 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/mroth/weightedrand v1.0.0 h1:V8JeHChvl2MP1sAoXq4brElOcza+jxLkRuwvtQu8L3E=
Expand Down Expand Up @@ -620,8 +626,16 @@ github.com/quic-go/qtls-go1-19 v0.3.2 h1:tFxjCFcTQzK+oMxG6Zcvp4Dq8dx4yD3dDiIiyc8
github.com/quic-go/qtls-go1-19 v0.3.2/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI=
github.com/quic-go/qtls-go1-20 v0.2.2 h1:WLOPx6OY/hxtTxKV1Zrq20FtXtDEkeY00CGQm8GEa3E=
github.com/quic-go/qtls-go1-20 v0.2.2/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM=
github.com/quic-go/qtls-go1-20 v0.3.1 h1:O4BLOM3hwfVF3AcktIylQXyl7Yi2iBNVy5QsV+ySxbg=
github.com/quic-go/qtls-go1-20 v0.3.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
github.com/quic-go/quic-go v0.33.0 h1:ItNoTDN/Fm/zBlq769lLJc8ECe9gYaW40veHCCco7y0=
github.com/quic-go/quic-go v0.33.0/go.mod h1:YMuhaAV9/jIu0XclDXwZPAsP/2Kgr5yMYhe9oxhhOFA=
github.com/quic-go/quic-go v0.35.1 h1:b0kzj6b/cQAf05cT0CkQubHM31wiA+xH3IBkxP62poo=
github.com/quic-go/quic-go v0.35.1/go.mod h1:+4CVgVppm0FNjpG3UcX8Joi/frKOH7/ciD5yGcwOO1g=
github.com/quic-go/quic-go v0.36.0 h1:JIrO7p7Ug6hssFcARjWDiqS2RAKJHCiwPxBAA989rbI=
github.com/quic-go/quic-go v0.36.0/go.mod h1:zPetvwDlILVxt15n3hr3Gf/I3mDf7LpLKPhR4Ez0AZQ=
github.com/quic-go/quic-go v0.37.3 h1:pkHH3xaMNUNAh6OtgEV/0K6Fz+YIJXhPzgd/ShiRDm4=
github.com/quic-go/quic-go v0.37.3/go.mod h1:YsbH1r4mSHPJcLF4k4zruUkLBqctEMBDR6VPvcYjIsU=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/refraction-networking/conjure v0.4.0 h1:YObJ+6L/MnupE82N2+3m93GMzlHjHSHe1ysIYDOpqug=
github.com/refraction-networking/conjure v0.4.0/go.mod h1:7na+SFWdaTOToNoNrsJRIj4CIMwdGFZ4kwb/CO5Z0rQ=
Expand Down
6 changes: 3 additions & 3 deletions internal/dslx/quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ func (f *quicHandshakeFunc) Apply(
)

// setup
quicListener := netxlite.NewQUICListener()
udpListener := netxlite.NewUDPListener()
quicDialer := f.dialer
if quicDialer == nil {
quicDialer = trace.NewQUICDialerWithoutResolver(quicListener, input.Logger)
quicDialer = trace.NewQUICDialerWithoutResolver(udpListener, input.Logger)
}
config := &tls.Config{
NextProtos: []string{"h3"},
Expand All @@ -119,7 +119,7 @@ func (f *quicHandshakeFunc) Apply(
var tlsState tls.ConnectionState
if quicConn != nil {
closerConn = &quicCloserConn{quicConn}
tlsState = quicConn.ConnectionState().TLS.ConnectionState // only quicConn can be nil
tlsState = quicConn.ConnectionState().TLS // only quicConn can be nil
}

// possibly track established conn for late close
Expand Down
2 changes: 1 addition & 1 deletion internal/experiment/simplequicping/simplequicping.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (m *Measurer) quicHandshake(ctx context.Context, index int64,
alpn := strings.Split(m.config.alpn(), " ")
trace := measurexlite.NewTrace(index, zeroTime)
ol := measurexlite.NewOperationLogger(logger, "SimpleQUICPing #%d %s %s %v", index, address, sni, alpn)
listener := netxlite.NewQUICListener()
listener := netxlite.NewUDPListener()
dialer := trace.NewQUICDialerWithoutResolver(listener, logger)
// See https://github.com/ooni/probe/issues/2413 to understand
// why we're using nil to force netxlite to use the cached
Expand Down
2 changes: 1 addition & 1 deletion internal/legacy/netx/quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func NewQUICDialer(config Config) model.QUICDialer {
}
// TODO(https://github.com/ooni/probe/issues/2121#issuecomment-1147424810): we
// should count the bytes consumed by this QUIC dialer
ql := config.ReadWriteSaver.WrapQUICListener(netxlite.NewQUICListener())
ql := config.ReadWriteSaver.WrapUDPListener(netxlite.NewUDPListener())
logger := model.ValidLoggerOrDefault(config.Logger)
return netxlite.NewQUICDialerWithResolver(ql, logger, config.FullResolver, config.Saver)
}
20 changes: 10 additions & 10 deletions internal/measurex/quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import (
"github.com/quic-go/quic-go"
)

type quicListenerDB struct {
model.QUICListener
type udpListenerDB struct {
model.UDPListener
begin time.Time
db WritableDB
}

func (ql *quicListenerDB) Listen(addr *net.UDPAddr) (model.UDPLikeConn, error) {
pconn, err := ql.QUICListener.Listen(addr)
func (ql *udpListenerDB) Listen(addr *net.UDPAddr) (model.UDPLikeConn, error) {
pconn, err := ql.UDPListener.Listen(addr)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -109,17 +109,17 @@ func (qh *quicDialerDB) DialContext(ctx context.Context, address string,
tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error) {
started := time.Since(qh.begin).Seconds()
var state tls.ConnectionState
listener := &quicListenerDB{
QUICListener: netxlite.NewQUICListener(),
begin: qh.begin,
db: qh.db,
listener := &udpListenerDB{
UDPListener: netxlite.NewUDPListener(),
begin: qh.begin,
db: qh.db,
}
dialer := netxlite.NewQUICDialerWithoutResolver(listener, qh.logger)
defer dialer.CloseIdleConnections()
sess, err := dialer.DialContext(ctx, address, tlsConfig, quicConfig)
if err == nil {
<-sess.HandshakeComplete().Done() // robustness (the dialer already does that)
state = sess.ConnectionState().TLS.ConnectionState
<-sess.HandshakeComplete() // robustness (the dialer already does that)
state = sess.ConnectionState().TLS
}
finished := time.Since(qh.begin).Seconds()
qh.db.InsertIntoQUICHandshake(&QUICTLSHandshakeEvent{
Expand Down
4 changes: 2 additions & 2 deletions internal/measurexlite/quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

// NewQUICDialerWithoutResolver is equivalent to netxlite.NewQUICDialerWithoutResolver
// except that it returns a model.QUICDialer that uses this trace.
func (tx *Trace) NewQUICDialerWithoutResolver(listener model.QUICListener, dl model.DebugLogger) model.QUICDialer {
func (tx *Trace) NewQUICDialerWithoutResolver(listener model.UDPListener, dl model.DebugLogger) model.QUICDialer {
return &quicDialerTrace{
qd: tx.newQUICDialerWithoutResolver(listener, dl),
tx: tx,
Expand Down Expand Up @@ -60,7 +60,7 @@ func (tx *Trace) OnQUICHandshakeDone(started time.Time, remoteAddr string, qconn

state := tls.ConnectionState{}
if qconn != nil {
state = qconn.ConnectionState().TLS.ConnectionState
state = qconn.ConnectionState().TLS
}

select {
Expand Down
34 changes: 23 additions & 11 deletions internal/measurexlite/quic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ func TestNewQUICDialerWithoutResolver(t *testing.T) {
underlying := &mocks.QUICDialer{}
zeroTime := time.Now()
trace := NewTrace(0, zeroTime)
trace.newQUICDialerWithoutResolverFn = func(listener model.QUICListener, dl model.DebugLogger) model.QUICDialer {
trace.newQUICDialerWithoutResolverFn = func(listener model.UDPListener, dl model.DebugLogger) model.QUICDialer {
return underlying
}
listener := &mocks.QUICListener{}
listener := &mocks.UDPListener{}
dialer := trace.NewQUICDialerWithoutResolver(listener, model.DiscardLogger)
dt := dialer.(*quicDialerTrace)
if dt.qd != underlying {
Expand All @@ -50,10 +50,10 @@ func TestNewQUICDialerWithoutResolver(t *testing.T) {
return nil, expectedErr
},
}
trace.newQUICDialerWithoutResolverFn = func(listener model.QUICListener, dl model.DebugLogger) model.QUICDialer {
trace.newQUICDialerWithoutResolverFn = func(listener model.UDPListener, dl model.DebugLogger) model.QUICDialer {
return underlying
}
listener := &mocks.QUICListener{}
listener := &mocks.UDPListener{}
dialer := trace.NewQUICDialerWithoutResolver(listener, model.DiscardLogger)
ctx := context.Background()
conn, err := dialer.DialContext(ctx, "1.1.1.1:443", &tls.Config{}, &quic.Config{})
Expand All @@ -77,10 +77,10 @@ func TestNewQUICDialerWithoutResolver(t *testing.T) {
called = true
},
}
trace.newQUICDialerWithoutResolverFn = func(listener model.QUICListener, dl model.DebugLogger) model.QUICDialer {
trace.newQUICDialerWithoutResolverFn = func(listener model.UDPListener, dl model.DebugLogger) model.QUICDialer {
return underlying
}
listener := &mocks.QUICListener{}
listener := &mocks.UDPListener{}
dialer := trace.NewQUICDialerWithoutResolver(listener, model.DiscardLogger)
dialer.CloseIdleConnections()
if !called {
Expand All @@ -97,6 +97,9 @@ func TestNewQUICDialerWithoutResolver(t *testing.T) {
pconn := &mocks.UDPLikeConn{
MockLocalAddr: func() net.Addr {
return &net.UDPAddr{
// quic-go does not allow the use of the same net.PacketConn for multiple "Dial"
// calls (unless a quic.Transport is used), so we have to make sure to mock local
// addresses with different ports, as tests run in parallel.
Port: 0,
}
},
Expand All @@ -111,8 +114,11 @@ func TestNewQUICDialerWithoutResolver(t *testing.T) {
MockClose: func() error {
return nil
},
MockSetReadBuffer: func(n int) error {
return nil
},
}
listener := &mocks.QUICListener{
listener := &mocks.UDPListener{
MockListen: func(addr *net.UDPAddr) (model.UDPLikeConn, error) {
return pconn, nil
},
Expand Down Expand Up @@ -207,7 +213,10 @@ func TestNewQUICDialerWithoutResolver(t *testing.T) {
pconn := &mocks.UDPLikeConn{
MockLocalAddr: func() net.Addr {
return &net.UDPAddr{
Port: 0,
// quic-go does not allow the use of the same net.PacketConn for multiple "Dial"
// calls (unless a quic.Transport is used), so we have to make sure to mock local
// addresses with different ports, as tests run in parallel.
Port: 1,
}
},
MockRemoteAddr: func() net.Addr {
Expand All @@ -221,8 +230,11 @@ func TestNewQUICDialerWithoutResolver(t *testing.T) {
MockClose: func() error {
return nil
},
MockSetReadBuffer: func(n int) error {
return nil
},
}
listener := &mocks.QUICListener{
listener := &mocks.UDPListener{
MockListen: func(addr *net.UDPAddr) (model.UDPLikeConn, error) {
return pconn, nil
},
Expand Down Expand Up @@ -262,8 +274,8 @@ func TestOnQUICHandshakeDoneExtractsTheConnectionState(t *testing.T) {
trace := NewTrace(0, time.Now())

// create a QUIC dialer
quicListener := netxlite.NewQUICListener()
quicDialer := trace.NewQUICDialerWithoutResolver(quicListener, model.DiscardLogger)
udpListener := netxlite.NewUDPListener()
quicDialer := trace.NewQUICDialerWithoutResolver(udpListener, model.DiscardLogger)

// dial with the endpoint we use for testing
quicConn, err := quicDialer.DialContext(
Expand Down
4 changes: 2 additions & 2 deletions internal/measurexlite/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type Trace struct {

// NewDialerWithoutResolverFn is OPTIONAL and can be used to override
// calls to the netxlite.NewQUICDialerWithoutResolver factory.
newQUICDialerWithoutResolverFn func(listener model.QUICListener, dl model.DebugLogger) model.QUICDialer
newQUICDialerWithoutResolverFn func(listener model.UDPListener, dl model.DebugLogger) model.QUICDialer

// dnsLookup is MANDATORY and buffers DNS Lookup observations.
dnsLookup chan *model.ArchivalDNSLookupResult
Expand Down Expand Up @@ -229,7 +229,7 @@ func (tx *Trace) newTLSHandshakerUTLS(dl model.DebugLogger, id *utls.ClientHello

// newQUICDialerWithoutResolver indirectly calls netxlite.NewQUICDialerWithoutResolver
// thus allowing us to mock this func for testing.
func (tx *Trace) newQUICDialerWithoutResolver(listener model.QUICListener, dl model.DebugLogger) model.QUICDialer {
func (tx *Trace) newQUICDialerWithoutResolver(listener model.UDPListener, dl model.DebugLogger) model.QUICDialer {
if tx.newQUICDialerWithoutResolverFn != nil {
return tx.newQUICDialerWithoutResolverFn(listener, dl)
}
Expand Down
12 changes: 9 additions & 3 deletions internal/measurexlite/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ func TestTrace(t *testing.T) {
t.Run("when not nil", func(t *testing.T) {
mockedErr := errors.New("mocked")
tx := &Trace{
newQUICDialerWithoutResolverFn: func(listener model.QUICListener, dl model.DebugLogger) model.QUICDialer {
newQUICDialerWithoutResolverFn: func(listener model.UDPListener, dl model.DebugLogger) model.QUICDialer {
return &mocks.QUICDialer{
MockDialContext: func(ctx context.Context, address string,
tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error) {
Expand All @@ -517,7 +517,7 @@ func TestTrace(t *testing.T) {
}
},
}
qdx := tx.newQUICDialerWithoutResolver(&mocks.QUICListener{}, model.DiscardLogger)
qdx := tx.newQUICDialerWithoutResolver(&mocks.UDPListener{}, model.DiscardLogger)
ctx := context.Background()
qconn, err := qdx.DialContext(ctx, "1.1.1.1:443", &tls.Config{}, &quic.Config{})
if !errors.Is(err, mockedErr) {
Expand All @@ -536,6 +536,9 @@ func TestTrace(t *testing.T) {
pconn := &mocks.UDPLikeConn{
MockLocalAddr: func() net.Addr {
return &net.UDPAddr{
// quic-go does not allow the use of the same net.PacketConn for multiple "Dial"
// calls (unless a quic.Transport is used), so we have to make sure to mock local
// addresses with different ports, as tests run in parallel.
Port: 0,
}
},
Expand All @@ -550,8 +553,11 @@ func TestTrace(t *testing.T) {
MockClose: func() error {
return nil
},
MockSetReadBuffer: func(n int) error {
return nil
},
}
listener := &mocks.QUICListener{
listener := &mocks.UDPListener{
MockListen: func(addr *net.UDPAddr) (model.UDPLikeConn, error) {
return pconn, nil
},
Expand Down
16 changes: 8 additions & 8 deletions internal/mocks/quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
"github.com/quic-go/quic-go"
)

// QUICListener is a mockable netxlite.QUICListener.
type QUICListener struct {
// UDPListener is a mockable netxlite.UDPListener.
type UDPListener struct {
MockListen func(addr *net.UDPAddr) (model.UDPLikeConn, error)
}

// Listen calls MockListen.
func (ql *QUICListener) Listen(addr *net.UDPAddr) (model.UDPLikeConn, error) {
func (ql *UDPListener) Listen(addr *net.UDPAddr) (model.UDPLikeConn, error) {
return ql.MockListen(addr)
}

Expand Down Expand Up @@ -57,10 +57,10 @@ type QUICEarlyConnection struct {
MockCloseWithError func(code quic.ApplicationErrorCode, reason string) error
MockContext func() context.Context
MockConnectionState func() quic.ConnectionState
MockHandshakeComplete func() context.Context
MockHandshakeComplete func() <-chan struct{}
MockNextConnection func() quic.Connection
MockSendMessage func(b []byte) error
MockReceiveMessage func() ([]byte, error)
MockReceiveMessage func(ctx context.Context) ([]byte, error)
}

var _ quic.EarlyConnection = &QUICEarlyConnection{}
Expand Down Expand Up @@ -122,7 +122,7 @@ func (s *QUICEarlyConnection) ConnectionState() quic.ConnectionState {
}

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

Expand All @@ -137,8 +137,8 @@ func (s *QUICEarlyConnection) SendMessage(b []byte) error {
}

// ReceiveMessage calls MockReceiveMessage.
func (s *QUICEarlyConnection) ReceiveMessage() ([]byte, error) {
return s.MockReceiveMessage()
func (s *QUICEarlyConnection) ReceiveMessage(ctx context.Context) ([]byte, error) {
return s.MockReceiveMessage(ctx)
}

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