refactor(netxlite): better integration with tracex (#774)
Rather than passing functions to construct complex objects such as Dialer and QUICDialer, pass interface implementations. Ensure that a nil implementation does not cause harm. Make Saver implement the correct interface either directly or indirectly. We need to implement the correct interface indirectly for TCP conns (or connected UDP sockets) because we have two distinct use cases inside netx: observing just the connect event and observing just the I/O events. With this change, the construction of composed Dialers and QUICDialers is greatly simplified and more obvious. Part of https://github.com/ooni/probe/issues/2121
This commit is contained in:
@@ -119,6 +119,12 @@ type DNSTransport interface {
|
||||
CloseIdleConnections()
|
||||
}
|
||||
|
||||
// DialerWrapper is a type that takes in input a Dialer
|
||||
// and returns in output a wrapped Dialer.
|
||||
type DialerWrapper interface {
|
||||
WrapDialer(d Dialer) Dialer
|
||||
}
|
||||
|
||||
// SimpleDialer establishes network connections.
|
||||
type SimpleDialer interface {
|
||||
// DialContext behaves like net.Dialer.DialContext.
|
||||
@@ -171,6 +177,12 @@ type QUICListener interface {
|
||||
Listen(addr *net.UDPAddr) (UDPLikeConn, error)
|
||||
}
|
||||
|
||||
// QUICDialerWrapper is a type that takes in input a QUICDialer
|
||||
// and returns in output a wrapped QUICDialer.
|
||||
type QUICDialerWrapper interface {
|
||||
WrapQUICDialer(qd QUICDialer) QUICDialer
|
||||
}
|
||||
|
||||
// QUICDialer dials QUIC sessions.
|
||||
type QUICDialer interface {
|
||||
// DialContext establishes a new QUIC session using the given
|
||||
|
||||
Reference in New Issue
Block a user