refactor: allow automatically wrap net/quic conn (#867)

See https://github.com/ooni/probe/issues/2219
This commit is contained in:
DecFox 2022-08-18 00:28:06 +05:30 committed by GitHub
commit 097926c51f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 83 additions and 101 deletions

View file

@ -7,7 +7,6 @@ package measurexlite
import (
"context"
"crypto/tls"
"net"
"time"
"github.com/lucas-clemente/quic-go"
@ -15,29 +14,6 @@ import (
"github.com/ooni/probe-cli/v3/internal/netxlite"
)
// WrapQUICListener returns a wrapped model.QUICListener that uses this trace.
func (tx *Trace) WrapQUICListener(listener model.QUICListener) model.QUICListener {
return &quicListenerTrace{
QUICListener: listener,
tx: tx,
}
}
// quicListenerTrace is a trace-aware QUIC listener.
type quicListenerTrace struct {
model.QUICListener
tx *Trace
}
// Listen implements model.QUICListener.Listen
func (ql *quicListenerTrace) Listen(addr *net.UDPAddr) (model.UDPLikeConn, error) {
pconn, err := ql.QUICListener.Listen(addr)
if err != nil {
return nil, err
}
return ql.tx.WrapUDPLikeConn(pconn), nil
}
// 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 {