06ee0e55a9
* 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.
24 lines
552 B
Go
24 lines
552 B
Go
package dialer
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
"time"
|
|
)
|
|
|
|
// loggingDialer is a Dialer with logging
|
|
type loggingDialer struct {
|
|
Dialer
|
|
Logger Logger
|
|
}
|
|
|
|
// DialContext implements Dialer.DialContext
|
|
func (d *loggingDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
|
|
d.Logger.Debugf("dial %s/%s...", address, network)
|
|
start := time.Now()
|
|
conn, err := d.Dialer.DialContext(ctx, network, address)
|
|
stop := time.Now()
|
|
d.Logger.Debugf("dial %s/%s... %+v in %s", address, network, err, stop.Sub(start))
|
|
return conn, err
|
|
}
|