refactor(ndt7): use netxlite rather than netx (#768)
This diff required us to move some code around, but no major change actually happened, except better tests. While there, I also slightly refactored ndt7's implementation and removed the ProxyURL setting, which was actually unused. See https://github.com/ooni/probe/issues/2121
This commit is contained in:
parent
314c3c934d
commit
3265bc670a
12 changed files with 189 additions and 159 deletions
|
|
@ -1,26 +1,5 @@
|
|||
package dialer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
import "github.com/ooni/probe-cli/v3/internal/bytecounter"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/bytecounter"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
// byteCounterDialer is a byte-counting-aware dialer. To perform byte counting, you
|
||||
// should make sure that you insert this dialer in the dialing chain.
|
||||
type byteCounterDialer struct {
|
||||
model.Dialer
|
||||
}
|
||||
|
||||
// DialContext implements Dialer.DialContext
|
||||
func (d *byteCounterDialer) DialContext(
|
||||
ctx context.Context, network, address string) (net.Conn, error) {
|
||||
conn, err := d.Dialer.DialContext(ctx, network, address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
conn = bytecounter.MaybeWrapWithContextByteCounters(ctx, conn)
|
||||
return conn, nil
|
||||
}
|
||||
type byteCounterDialer = bytecounter.ContextAwareDialer
|
||||
|
|
|
|||
Loading…
Reference in a new issue