refactor: allow automatically wrap net/quic conn (#867)
See https://github.com/ooni/probe/issues/2219
This commit is contained in:
parent
e1d014e826
commit
097926c51f
12 changed files with 83 additions and 101 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue