refactor(netx/dialer): hide implementation complexity (#372)
* refactor(netx/dialer): hide implementation complexity This follows the blueprint of `module.Config` and `nodule.New` described at https://github.com/ooni/probe/issues/1591. * fix: ndt7 bug where we were not using the right resolver * fix(legacy/netx): clarify irrelevant implementation change * fix: improve comments * fix(hhfm): do not use dialer.New b/c it breaks it Unclear to me why this is happening. Still, improve upon the previous situation by adding a timeout. It does not seem a priority to look into this issue now.
This commit is contained in:
parent
b7a6dbe47b
commit
06ee0e55a9
30 changed files with 312 additions and 517 deletions
|
|
@ -146,24 +146,13 @@ func NewDialer(config Config) Dialer {
|
|||
if config.FullResolver == nil {
|
||||
config.FullResolver = NewResolver(config)
|
||||
}
|
||||
var d Dialer = dialer.Default
|
||||
d = dialer.ErrorWrapperDialer{Dialer: d}
|
||||
if config.Logger != nil {
|
||||
d = dialer.LoggingDialer{Dialer: d, Logger: config.Logger}
|
||||
}
|
||||
if config.DialSaver != nil {
|
||||
d = dialer.SaverDialer{Dialer: d, Saver: config.DialSaver}
|
||||
}
|
||||
if config.ReadWriteSaver != nil {
|
||||
d = dialer.SaverConnDialer{Dialer: d, Saver: config.ReadWriteSaver}
|
||||
}
|
||||
d = dialer.DNSDialer{Resolver: config.FullResolver, Dialer: d}
|
||||
d = dialer.ProxyDialer{ProxyURL: config.ProxyURL, Dialer: d}
|
||||
if config.ContextByteCounting {
|
||||
d = dialer.ByteCounterDialer{Dialer: d}
|
||||
}
|
||||
d = dialer.ShapingDialer{Dialer: d}
|
||||
return d
|
||||
return dialer.New(&dialer.Config{
|
||||
ContextByteCounting: config.ContextByteCounting,
|
||||
DialSaver: config.DialSaver,
|
||||
Logger: config.Logger,
|
||||
ProxyURL: config.ProxyURL,
|
||||
ReadWriteSaver: config.ReadWriteSaver,
|
||||
}, config.FullResolver)
|
||||
}
|
||||
|
||||
// NewQUICDialer creates a new DNS Dialer for QUIC, with the resolver from the specified config
|
||||
|
|
|
|||
Loading…
Reference in a new issue