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:
@@ -64,17 +64,19 @@ func maybeWithMeasurementRoot(
|
||||
// - dialer.Default
|
||||
//
|
||||
// If you have others needs, manually build the chain you need.
|
||||
func newDNSDialer(resolver dialer.Resolver) dialer.DNSDialer {
|
||||
return dialer.DNSDialer{
|
||||
Dialer: EmitterDialer{
|
||||
Dialer: dialer.ErrorWrapperDialer{
|
||||
Dialer: dialer.ByteCounterDialer{
|
||||
Dialer: dialer.Default,
|
||||
},
|
||||
},
|
||||
},
|
||||
Resolver: resolver,
|
||||
}
|
||||
func newDNSDialer(resolver dialer.Resolver) dialer.Dialer {
|
||||
// Implementation note: we're wrapping the result of dialer.New
|
||||
// on the outside, while previously we were puttting the
|
||||
// EmitterDialer before the DNSDialer (see the above comment).
|
||||
//
|
||||
// Yet, this is fine because the only experiment which is
|
||||
// using this code is tor, for which it doesn't matter.
|
||||
//
|
||||
// Also (and I am always scared to write this kind of
|
||||
// comments), we should rewrite tor soon.
|
||||
return &EmitterDialer{dialer.New(&dialer.Config{
|
||||
ContextByteCounting: true,
|
||||
}, resolver)}
|
||||
}
|
||||
|
||||
// DialContext is like Dial but the context allows to interrupt a
|
||||
|
||||
Reference in New Issue
Block a user