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:
parent
f4f3ed7c42
commit
7e0b47311d
10 changed files with 119 additions and 58 deletions
|
|
@ -132,12 +132,7 @@ func NewQUICDialer(config Config) model.QUICDialer {
|
|||
if config.Logger != nil {
|
||||
logger = config.Logger
|
||||
}
|
||||
extensions := []netxlite.QUICDialerWrapper{
|
||||
func(dialer model.QUICDialer) model.QUICDialer {
|
||||
return config.TLSSaver.WrapQUICDialer(dialer) // robust to nil TLSSaver
|
||||
},
|
||||
}
|
||||
return netxlite.NewQUICDialerWithResolver(ql, logger, config.FullResolver, extensions...)
|
||||
return netxlite.NewQUICDialerWithResolver(ql, logger, config.FullResolver, config.TLSSaver)
|
||||
}
|
||||
|
||||
// NewTLSDialer creates a new TLSDialer from the specified config
|
||||
|
|
|
|||
Loading…
Reference in a new issue