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:
Simone Basso 2022-05-30 23:14:07 +02:00 committed by GitHub
commit 3265bc670a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 189 additions and 159 deletions

View file

@ -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