refactor(netxlite): hide details without breaking the rest of the tree (#454)

## Description

This PR continues the refactoring of `netx` under the following principles:

1. do not break the rest of the tree and do not engage in extensive tree-wide refactoring yet
2. move under `netxlite` clearly related subpackages (e.g., `iox`, `netxmocks`)
3. move into `internal/netxlite/internal` stuff that is clearly private of `netxlite`
4. hide implementation details in `netxlite` pending new factories
5. refactor `tls` code in `netxlite` to clearly separate `crypto/tls` code from `utls` code

After each commit, I run `go test -short -race ./...` locally. Each individual commit explains what it does. I will squash, but this operation will preserve the original commit titles, so this will give further insight on each step.

## Commits

* refactor: rename netxmocks -> netxlite/mocks

Part of https://github.com/ooni/probe/issues/1591

* refactor: rename quicx -> netxlite/quicx

See https://github.com/ooni/probe/issues/1591

* refactor: rename iox -> netxlite/iox

Regenerate sources and make sure the tests pass.

See https://github.com/ooni/probe/issues/1591.

* refactor(iox): move MockableReader to netxlite/mocks

See https://github.com/ooni/probe/issues/1591

* refactor(netxlite): generator is an implementation detail

See https://github.com/ooni/probe/issues/1591

* refactor(netxlite): separate tls and utls code

See https://github.com/ooni/probe/issues/1591

* refactor(netxlite): hide most types but keep old names as legacy

With this change we avoid breaking the rest of the tree, but we start
hiding some implementation details a bit. Factories will follow.

See https://github.com/ooni/probe/issues/1591
This commit is contained in:
Simone Basso 2021-09-05 14:49:38 +02:00 committed by GitHub
parent ae799c4942
commit 2e0118d1a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
137 changed files with 1244 additions and 1173 deletions

View File

@ -65,8 +65,8 @@ run `go mod tidy` to minimize such changes.
- use `./internal/fsx.OpenFile` when you need to open a file - use `./internal/fsx.OpenFile` when you need to open a file
- use `./internal/iox.ReadAllContext` instead of `io.ReadAll` - use `./internal/netxlite/iox.ReadAllContext` instead of `io.ReadAll`
and `./internal/iox.CopyContext` instead of `io.Copy` and `./internal/netxlite/iox.CopyContext` instead of `io.Copy`
## Code testing requirements ## Code testing requirements

View File

@ -8,7 +8,7 @@ import (
"os" "os"
"testing" "testing"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
func getShasum(path string) (string, error) { func getShasum(path string) (string, error) {

View File

@ -6,7 +6,7 @@ import (
"embed" "embed"
"github.com/apex/log" "github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
migrate "github.com/rubenv/sql-migrate" migrate "github.com/rubenv/sql-migrate"
"upper.io/db.v3/lib/sqlbuilder" "upper.io/db.v3/lib/sqlbuilder"
"upper.io/db.v3/sqlite" "upper.io/db.v3/sqlite"

View File

@ -4,12 +4,12 @@ import (
"errors" "errors"
"testing" "testing"
"github.com/ooni/probe-cli/v3/internal/netxmocks" "github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
) )
func TestConnWorksOnSuccess(t *testing.T) { func TestConnWorksOnSuccess(t *testing.T) {
counter := New() counter := New()
underlying := &netxmocks.Conn{ underlying := &mocks.Conn{
MockRead: func(b []byte) (int, error) { MockRead: func(b []byte) (int, error) {
return 10, nil return 10, nil
}, },
@ -39,7 +39,7 @@ func TestConnWorksOnFailure(t *testing.T) {
readError := errors.New("read error") readError := errors.New("read error")
writeError := errors.New("write error") writeError := errors.New("write error")
counter := New() counter := New()
underlying := &netxmocks.Conn{ underlying := &mocks.Conn{
MockRead: func(b []byte) (int, error) { MockRead: func(b []byte) (int, error) {
return 0, readError return 0, readError
}, },

View File

@ -16,7 +16,7 @@ import (
"time" "time"
"github.com/google/martian/v3/mitm" "github.com/google/martian/v3/mitm"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
// CensoringProxy is a proxy that does not behave correctly. // CensoringProxy is a proxy that does not behave correctly.

View File

@ -8,7 +8,7 @@ import (
"testing" "testing"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/uncensored" "github.com/ooni/probe-cli/v3/internal/cmd/jafar/uncensored"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
func TestPass(t *testing.T) { func TestPass(t *testing.T) {

View File

@ -1,3 +1,4 @@
//go:build linux
// +build linux // +build linux
package iptables package iptables

View File

@ -1,3 +1,4 @@
//go:build !linux
// +build !linux // +build !linux
package iptables package iptables

View File

@ -7,7 +7,7 @@ import (
"net/url" "net/url"
"testing" "testing"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
func TestGood(t *testing.T) { func TestGood(t *testing.T) {

View File

@ -14,7 +14,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity" "github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader" "github.com/ooni/probe-cli/v3/internal/engine/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/netx" "github.com/ooni/probe-cli/v3/internal/engine/netx"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
"github.com/ooni/probe-cli/v3/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/runtimex"
"github.com/ooni/probe-cli/v3/internal/version" "github.com/ooni/probe-cli/v3/internal/version"
) )

View File

@ -9,7 +9,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/atomicx" "github.com/ooni/probe-cli/v3/internal/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/netx" "github.com/ooni/probe-cli/v3/internal/engine/netx"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
type FakeResolver struct { type FakeResolver struct {

View File

@ -9,7 +9,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/atomicx" "github.com/ooni/probe-cli/v3/internal/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/netx" "github.com/ooni/probe-cli/v3/internal/engine/netx"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
type FakeResolver struct { type FakeResolver struct {

View File

@ -8,7 +8,7 @@ import (
"sync" "sync"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity" "github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
// CtrlHTTPResponse is the result of the HTTP check performed by // CtrlHTTPResponse is the result of the HTTP check performed by

View File

@ -7,7 +7,7 @@ import (
"net/http" "net/http"
"github.com/ooni/probe-cli/v3/internal/engine/netx" "github.com/ooni/probe-cli/v3/internal/engine/netx"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
"github.com/ooni/probe-cli/v3/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/runtimex"
"github.com/ooni/probe-cli/v3/internal/version" "github.com/ooni/probe-cli/v3/internal/version"
) )

View File

@ -10,8 +10,8 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/ooni/probe-cli/v3/internal/iox"
"github.com/ooni/probe-cli/v3/internal/netxlite" "github.com/ooni/probe-cli/v3/internal/netxlite"
"github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
const simplerequest = `{ const simplerequest = `{

View File

@ -13,7 +13,7 @@ import (
"net/http" "net/http"
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival" "github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
"github.com/ooni/probe-cli/v3/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/runtimex"
"github.com/ooni/probe-cli/v3/internal/version" "github.com/ooni/probe-cli/v3/internal/version"
) )

View File

@ -10,7 +10,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
const requestnoredirect = `{ const requestnoredirect = `{

View File

@ -19,7 +19,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace" "github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
"github.com/ooni/probe-cli/v3/internal/errorsx" "github.com/ooni/probe-cli/v3/internal/errorsx"
"github.com/ooni/probe-cli/v3/internal/humanize" "github.com/ooni/probe-cli/v3/internal/humanize"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
const ( const (

View File

@ -6,7 +6,7 @@ import (
"net/http" "net/http"
"time" "time"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
type FakeDialer struct { type FakeDialer struct {

View File

@ -20,7 +20,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival" "github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
"github.com/ooni/probe-cli/v3/internal/engine/netx/dialer" "github.com/ooni/probe-cli/v3/internal/engine/netx/dialer"
"github.com/ooni/probe-cli/v3/internal/errorsx" "github.com/ooni/probe-cli/v3/internal/errorsx"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
"github.com/ooni/probe-cli/v3/internal/randx" "github.com/ooni/probe-cli/v3/internal/randx"
) )

View File

@ -7,7 +7,7 @@ import (
"time" "time"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
type downloadManager struct { type downloadManager struct {

View File

@ -12,7 +12,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/httpheader" "github.com/ooni/probe-cli/v3/internal/engine/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/netx" "github.com/ooni/probe-cli/v3/internal/engine/netx"
"github.com/ooni/probe-cli/v3/internal/errorsx" "github.com/ooni/probe-cli/v3/internal/errorsx"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
"github.com/ooni/probe-cli/v3/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/runtimex"
) )

View File

@ -66,7 +66,7 @@ func (m Measurer) ExperimentVersion() string {
// SupportedQUICVersions are the H3 over QUIC versions we currently support // SupportedQUICVersions are the H3 over QUIC versions we currently support
var SupportedQUICVersions = map[string]bool{ var SupportedQUICVersions = map[string]bool{
"h3": true, "h3": true,
} }
var ( var (

View File

@ -4,7 +4,7 @@ import (
"net/http" "net/http"
"time" "time"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
type FakeTransport struct { type FakeTransport struct {

View File

@ -4,7 +4,7 @@ import (
"net/http" "net/http"
"time" "time"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
type FakeTransport struct { type FakeTransport struct {

View File

@ -10,7 +10,7 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
// Logger is the definition of Logger used by this package. // Logger is the definition of Logger used by this package.

View File

@ -10,7 +10,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/handlers" "github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/handlers"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx" "github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx"
"github.com/ooni/probe-cli/v3/internal/netxmocks" "github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
) )
func TestEmitterFailure(t *testing.T) { func TestEmitterFailure(t *testing.T) {
@ -20,7 +20,7 @@ func TestEmitterFailure(t *testing.T) {
Beginning: time.Now(), Beginning: time.Now(),
Handler: saver, Handler: saver,
}) })
d := EmitterDialer{Dialer: &netxmocks.Dialer{ d := EmitterDialer{Dialer: &mocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) { MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
return nil, io.EOF return nil, io.EOF
}, },
@ -69,9 +69,9 @@ func TestEmitterSuccess(t *testing.T) {
Beginning: time.Now(), Beginning: time.Now(),
Handler: saver, Handler: saver,
}) })
d := EmitterDialer{Dialer: &netxmocks.Dialer{ d := EmitterDialer{Dialer: &mocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) { MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
return &netxmocks.Conn{ return &mocks.Conn{
MockRead: func(b []byte) (int, error) { MockRead: func(b []byte) (int, error) {
return 0, io.EOF return 0, io.EOF
}, },

View File

@ -14,7 +14,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx" "github.com/ooni/probe-cli/v3/internal/engine/legacy/netx"
"github.com/ooni/probe-cli/v3/internal/errorsx" "github.com/ooni/probe-cli/v3/internal/errorsx"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
func dowithclient(t *testing.T, client *netx.HTTPClient) { func dowithclient(t *testing.T, client *netx.HTTPClient) {

View File

@ -5,7 +5,7 @@ import (
"net/http" "net/http"
"testing" "testing"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
func TestBodyTracerSuccess(t *testing.T) { func TestBodyTracerSuccess(t *testing.T) {

View File

@ -5,7 +5,7 @@ import (
"net/http" "net/http"
"testing" "testing"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
func TestGood(t *testing.T) { func TestGood(t *testing.T) {

View File

@ -13,7 +13,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/atomicx" "github.com/ooni/probe-cli/v3/internal/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx" "github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx"
"github.com/ooni/probe-cli/v3/internal/errorsx" "github.com/ooni/probe-cli/v3/internal/errorsx"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
// TraceTripper performs single HTTP transactions. // TraceTripper performs single HTTP transactions.

View File

@ -13,7 +13,7 @@ import (
"github.com/miekg/dns" "github.com/miekg/dns"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx" "github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
func TestTraceTripperSuccess(t *testing.T) { func TestTraceTripperSuccess(t *testing.T) {

View File

@ -10,7 +10,7 @@ import (
"github.com/apex/log/handlers/discard" "github.com/apex/log/handlers/discard"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx" "github.com/ooni/probe-cli/v3/internal/engine/legacy/netx"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx" "github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
func TestGood(t *testing.T) { func TestGood(t *testing.T) {

View File

@ -24,7 +24,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx" "github.com/ooni/probe-cli/v3/internal/engine/legacy/netx"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/handlers" "github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/handlers"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx" "github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
"github.com/ooni/probe-cli/v3/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/runtimex"
"gitlab.com/yawning/obfs4.git/transports" "gitlab.com/yawning/obfs4.git/transports"
obfs4base "gitlab.com/yawning/obfs4.git/transports/base" obfs4base "gitlab.com/yawning/obfs4.git/transports/base"

View File

@ -9,8 +9,8 @@ import (
"testing" "testing"
"github.com/ooni/probe-cli/v3/internal/bytecounter" "github.com/ooni/probe-cli/v3/internal/bytecounter"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
"github.com/ooni/probe-cli/v3/internal/netxmocks" "github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
) )
func dorequest(ctx context.Context, url string) error { func dorequest(ctx context.Context, url string) error {
@ -76,7 +76,7 @@ func TestByteCounterNoHandlers(t *testing.T) {
} }
func TestByteCounterConnectFailure(t *testing.T) { func TestByteCounterConnectFailure(t *testing.T) {
dialer := &byteCounterDialer{Dialer: &netxmocks.Dialer{ dialer := &byteCounterDialer{Dialer: &mocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) { MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
return nil, io.EOF return nil, io.EOF
}, },

View File

@ -8,13 +8,13 @@ import (
"net/url" "net/url"
"testing" "testing"
"github.com/ooni/probe-cli/v3/internal/netxmocks" "github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
) )
func TestProxyDialerDialContextNoProxyURL(t *testing.T) { func TestProxyDialerDialContextNoProxyURL(t *testing.T) {
expected := errors.New("mocked error") expected := errors.New("mocked error")
d := &proxyDialer{ d := &proxyDialer{
Dialer: &netxmocks.Dialer{ Dialer: &mocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) { MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
return nil, expected return nil, expected
}, },
@ -45,7 +45,7 @@ func TestProxyDialerDialContextInvalidScheme(t *testing.T) {
func TestProxyDialerDialContextWithEOF(t *testing.T) { func TestProxyDialerDialContextWithEOF(t *testing.T) {
const expect = "10.0.0.1:9050" const expect = "10.0.0.1:9050"
d := &proxyDialer{ d := &proxyDialer{
Dialer: &netxmocks.Dialer{ Dialer: &mocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) { MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
if address != expect { if address != expect {
return nil, errors.New("unexpected address") return nil, errors.New("unexpected address")

View File

@ -10,14 +10,14 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace" "github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
"github.com/ooni/probe-cli/v3/internal/errorsx" "github.com/ooni/probe-cli/v3/internal/errorsx"
"github.com/ooni/probe-cli/v3/internal/netxmocks" "github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
) )
func TestSaverDialerFailure(t *testing.T) { func TestSaverDialerFailure(t *testing.T) {
expected := errors.New("mocked error") expected := errors.New("mocked error")
saver := &trace.Saver{} saver := &trace.Saver{}
dlr := &saverDialer{ dlr := &saverDialer{
Dialer: &netxmocks.Dialer{ Dialer: &mocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) { MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
return nil, expected return nil, expected
}, },
@ -59,7 +59,7 @@ func TestSaverConnDialerFailure(t *testing.T) {
expected := errors.New("mocked error") expected := errors.New("mocked error")
saver := &trace.Saver{} saver := &trace.Saver{}
dlr := &saverConnDialer{ dlr := &saverConnDialer{
Dialer: &netxmocks.Dialer{ Dialer: &mocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) { MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
return nil, expected return nil, expected
}, },
@ -79,9 +79,9 @@ func TestSaverConnDialerSuccess(t *testing.T) {
saver := &trace.Saver{} saver := &trace.Saver{}
dlr := &saverConnDialer{ dlr := &saverConnDialer{
Dialer: &saverDialer{ Dialer: &saverDialer{
Dialer: &netxmocks.Dialer{ Dialer: &mocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) { MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
return &netxmocks.Conn{ return &mocks.Conn{
MockRead: func(b []byte) (int, error) { MockRead: func(b []byte) (int, error) {
return 0, io.EOF return 0, io.EOF
}, },

View File

@ -1,3 +1,4 @@
//go:build !shaping
// +build !shaping // +build !shaping
package dialer package dialer

View File

@ -1,3 +1,4 @@
//go:build shaping
// +build shaping // +build shaping
package dialer package dialer

View File

@ -6,7 +6,7 @@ import (
"net/http" "net/http"
"time" "time"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
type FakeDialer struct { type FakeDialer struct {

View File

@ -10,7 +10,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/bytecounter" "github.com/ooni/probe-cli/v3/internal/bytecounter"
"github.com/ooni/probe-cli/v3/internal/engine/netx/httptransport" "github.com/ooni/probe-cli/v3/internal/engine/netx/httptransport"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
func TestByteCounterFailure(t *testing.T) { func TestByteCounterFailure(t *testing.T) {

View File

@ -6,7 +6,7 @@ import (
"net/http" "net/http"
"time" "time"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
type FakeDialer struct { type FakeDialer struct {

View File

@ -10,7 +10,7 @@ import (
"time" "time"
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace" "github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
// SaverPerformanceHTTPTransport is a RoundTripper that saves // SaverPerformanceHTTPTransport is a RoundTripper that saves

View File

@ -11,7 +11,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/netx/httptransport" "github.com/ooni/probe-cli/v3/internal/engine/netx/httptransport"
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace" "github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
func TestSaverPerformanceNoMultipleEvents(t *testing.T) { func TestSaverPerformanceNoMultipleEvents(t *testing.T) {

View File

@ -11,7 +11,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/netx" "github.com/ooni/probe-cli/v3/internal/engine/netx"
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace" "github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
"github.com/ooni/probe-cli/v3/internal/errorsx" "github.com/ooni/probe-cli/v3/internal/errorsx"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
func TestSuccess(t *testing.T) { func TestSuccess(t *testing.T) {

View File

@ -6,7 +6,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace" "github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
"github.com/ooni/probe-cli/v3/internal/errorsx" "github.com/ooni/probe-cli/v3/internal/errorsx"
"github.com/ooni/probe-cli/v3/internal/quicx" "github.com/ooni/probe-cli/v3/internal/netxlite/quicx"
) )
// QUICListener listens for QUIC connections. // QUICListener listens for QUIC connections.

View File

@ -12,14 +12,14 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace" "github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
"github.com/ooni/probe-cli/v3/internal/errorsx" "github.com/ooni/probe-cli/v3/internal/errorsx"
"github.com/ooni/probe-cli/v3/internal/netxlite" "github.com/ooni/probe-cli/v3/internal/netxlite"
"github.com/ooni/probe-cli/v3/internal/netxmocks" "github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
"github.com/ooni/probe-cli/v3/internal/quicx" "github.com/ooni/probe-cli/v3/internal/netxlite/quicx"
) )
func TestQUICListenerSaverCannotListen(t *testing.T) { func TestQUICListenerSaverCannotListen(t *testing.T) {
expected := errors.New("mocked error") expected := errors.New("mocked error")
qls := &quicdialer.QUICListenerSaver{ qls := &quicdialer.QUICListenerSaver{
QUICListener: &netxmocks.QUICListener{ QUICListener: &mocks.QUICListener{
MockListen: func(addr *net.UDPAddr) (quicx.UDPLikeConn, error) { MockListen: func(addr *net.UDPAddr) (quicx.UDPLikeConn, error) {
return nil, expected return nil, expected
}, },

View File

@ -8,7 +8,7 @@ import (
"time" "time"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader" "github.com/ooni/probe-cli/v3/internal/engine/httpheader"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
// DNSOverHTTPS is a DNS over HTTPS RoundTripper. Requests are submitted over // DNSOverHTTPS is a DNS over HTTPS RoundTripper. Requests are submitted over

View File

@ -15,7 +15,7 @@ import (
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/ooni/probe-cli/v3/internal/engine/model" "github.com/ooni/probe-cli/v3/internal/engine/model"
"github.com/ooni/probe-cli/v3/internal/engine/probeservices" "github.com/ooni/probe-cli/v3/internal/engine/probeservices"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
type fakeTestKeys struct { type fakeTestKeys struct {

View File

@ -16,7 +16,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/model" "github.com/ooni/probe-cli/v3/internal/engine/model"
"github.com/ooni/probe-cli/v3/internal/engine/probeservices" "github.com/ooni/probe-cli/v3/internal/engine/probeservices"
"github.com/ooni/probe-cli/v3/internal/engine/probeservices/testorchestra" "github.com/ooni/probe-cli/v3/internal/engine/probeservices/testorchestra"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
func newclient() *probeservices.Client { func newclient() *probeservices.Client {

View File

@ -16,7 +16,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/geolocate" "github.com/ooni/probe-cli/v3/internal/engine/geolocate"
"github.com/ooni/probe-cli/v3/internal/engine/model" "github.com/ooni/probe-cli/v3/internal/engine/model"
"github.com/ooni/probe-cli/v3/internal/engine/probeservices" "github.com/ooni/probe-cli/v3/internal/engine/probeservices"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
"github.com/ooni/probe-cli/v3/internal/version" "github.com/ooni/probe-cli/v3/internal/version"
) )

View File

@ -1,3 +1,4 @@
//go:build !ooni_psiphon_config
// +build !ooni_psiphon_config // +build !ooni_psiphon_config
package engine package engine

View File

@ -1,3 +1,4 @@
//go:build !ooni_psiphon_config
// +build !ooni_psiphon_config // +build !ooni_psiphon_config
package engine package engine

View File

@ -1,3 +1,4 @@
//go:build ooni_psiphon_config
// +build ooni_psiphon_config // +build ooni_psiphon_config
package engine package engine
@ -8,7 +9,7 @@ import (
_ "embed" _ "embed"
"filippo.io/age" "filippo.io/age"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
//go:embed psiphon-config.json.age //go:embed psiphon-config.json.age

View File

@ -1,3 +1,4 @@
//go:build ooni_psiphon_config
// +build ooni_psiphon_config // +build ooni_psiphon_config
package engine package engine

View File

@ -7,12 +7,12 @@ import (
"net" "net"
"testing" "testing"
"github.com/ooni/probe-cli/v3/internal/netxmocks" "github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
) )
func TestErrorWrapperDialerFailure(t *testing.T) { func TestErrorWrapperDialerFailure(t *testing.T) {
ctx := context.Background() ctx := context.Background()
d := &ErrorWrapperDialer{Dialer: &netxmocks.Dialer{ d := &ErrorWrapperDialer{Dialer: &mocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) { MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
return nil, io.EOF return nil, io.EOF
}, },
@ -39,7 +39,7 @@ func TestErrorWrapperDialerFailure(t *testing.T) {
func TestErrorWrapperDialerSuccess(t *testing.T) { func TestErrorWrapperDialerSuccess(t *testing.T) {
origConn := &net.TCPConn{} origConn := &net.TCPConn{}
ctx := context.Background() ctx := context.Background()
d := &ErrorWrapperDialer{Dialer: &netxmocks.Dialer{ d := &ErrorWrapperDialer{Dialer: &mocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) { MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
return origConn, nil return origConn, nil
}, },
@ -59,7 +59,7 @@ func TestErrorWrapperDialerSuccess(t *testing.T) {
func TestErrorWrapperConnReadFailure(t *testing.T) { func TestErrorWrapperConnReadFailure(t *testing.T) {
c := &errorWrapperConn{ c := &errorWrapperConn{
Conn: &netxmocks.Conn{ Conn: &mocks.Conn{
MockRead: func(b []byte) (int, error) { MockRead: func(b []byte) (int, error) {
return 0, io.EOF return 0, io.EOF
}, },
@ -87,7 +87,7 @@ func TestErrorWrapperConnReadFailure(t *testing.T) {
func TestErrorWrapperConnReadSuccess(t *testing.T) { func TestErrorWrapperConnReadSuccess(t *testing.T) {
c := &errorWrapperConn{ c := &errorWrapperConn{
Conn: &netxmocks.Conn{ Conn: &mocks.Conn{
MockRead: func(b []byte) (int, error) { MockRead: func(b []byte) (int, error) {
return len(b), nil return len(b), nil
}, },
@ -105,7 +105,7 @@ func TestErrorWrapperConnReadSuccess(t *testing.T) {
func TestErrorWrapperConnWriteFailure(t *testing.T) { func TestErrorWrapperConnWriteFailure(t *testing.T) {
c := &errorWrapperConn{ c := &errorWrapperConn{
Conn: &netxmocks.Conn{ Conn: &mocks.Conn{
MockWrite: func(b []byte) (int, error) { MockWrite: func(b []byte) (int, error) {
return 0, io.EOF return 0, io.EOF
}, },
@ -133,7 +133,7 @@ func TestErrorWrapperConnWriteFailure(t *testing.T) {
func TestErrorWrapperConnWriteSuccess(t *testing.T) { func TestErrorWrapperConnWriteSuccess(t *testing.T) {
c := &errorWrapperConn{ c := &errorWrapperConn{
Conn: &netxmocks.Conn{ Conn: &mocks.Conn{
MockWrite: func(b []byte) (int, error) { MockWrite: func(b []byte) (int, error) {
return len(b), nil return len(b), nil
}, },
@ -151,7 +151,7 @@ func TestErrorWrapperConnWriteSuccess(t *testing.T) {
func TestErrorWrapperConnCloseFailure(t *testing.T) { func TestErrorWrapperConnCloseFailure(t *testing.T) {
c := &errorWrapperConn{ c := &errorWrapperConn{
Conn: &netxmocks.Conn{ Conn: &mocks.Conn{
MockClose: func() error { MockClose: func() error {
return io.EOF return io.EOF
}, },
@ -175,7 +175,7 @@ func TestErrorWrapperConnCloseFailure(t *testing.T) {
func TestErrorWrapperConnCloseSuccess(t *testing.T) { func TestErrorWrapperConnCloseSuccess(t *testing.T) {
c := &errorWrapperConn{ c := &errorWrapperConn{
Conn: &netxmocks.Conn{ Conn: &mocks.Conn{
MockClose: func() error { MockClose: func() error {
return nil return nil
}, },

View File

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT. // Code generated by go generate; DO NOT EDIT.
// Generated: 2021-07-02 17:54:06.182341 +0200 CEST m=+0.120124584 // Generated: 2021-09-05 13:54:14.649711 +0200 CEST m=+0.136980959
package errorsx package errorsx

View File

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT. // Code generated by go generate; DO NOT EDIT.
// Generated: 2021-07-02 17:54:06.226224 +0200 CEST m=+0.164008293 // Generated: 2021-09-05 13:54:14.695896 +0200 CEST m=+0.183167084
package errorsx package errorsx

View File

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT. // Code generated by go generate; DO NOT EDIT.
// Generated: 2021-07-02 17:54:06.062944 +0200 CEST m=+0.000724793 // Generated: 2021-09-05 13:54:14.514032 +0200 CEST m=+0.001299626
package errorsx package errorsx

View File

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT. // Code generated by go generate; DO NOT EDIT.
// Generated: 2021-07-02 17:54:06.155868 +0200 CEST m=+0.093650376 // Generated: 2021-09-05 13:54:14.622035 +0200 CEST m=+0.109304917
package errorsx package errorsx

View File

@ -7,7 +7,7 @@ import (
"net" "net"
"github.com/lucas-clemente/quic-go" "github.com/lucas-clemente/quic-go"
"github.com/ooni/probe-cli/v3/internal/quicx" "github.com/ooni/probe-cli/v3/internal/netxlite/quicx"
) )
// QUICContextDialer is a dialer for QUIC using Context. // QUICContextDialer is a dialer for QUIC using Context.

View File

@ -9,13 +9,13 @@ import (
"testing" "testing"
"github.com/lucas-clemente/quic-go" "github.com/lucas-clemente/quic-go"
"github.com/ooni/probe-cli/v3/internal/netxmocks" "github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
"github.com/ooni/probe-cli/v3/internal/quicx" "github.com/ooni/probe-cli/v3/internal/netxlite/quicx"
) )
func TestErrorWrapperQUICListenerSuccess(t *testing.T) { func TestErrorWrapperQUICListenerSuccess(t *testing.T) {
ql := &ErrorWrapperQUICListener{ ql := &ErrorWrapperQUICListener{
QUICListener: &netxmocks.QUICListener{ QUICListener: &mocks.QUICListener{
MockListen: func(addr *net.UDPAddr) (quicx.UDPLikeConn, error) { MockListen: func(addr *net.UDPAddr) (quicx.UDPLikeConn, error) {
return &net.UDPConn{}, nil return &net.UDPConn{}, nil
}, },
@ -30,7 +30,7 @@ func TestErrorWrapperQUICListenerSuccess(t *testing.T) {
func TestErrorWrapperQUICListenerFailure(t *testing.T) { func TestErrorWrapperQUICListenerFailure(t *testing.T) {
ql := &ErrorWrapperQUICListener{ ql := &ErrorWrapperQUICListener{
QUICListener: &netxmocks.QUICListener{ QUICListener: &mocks.QUICListener{
MockListen: func(addr *net.UDPAddr) (quicx.UDPLikeConn, error) { MockListen: func(addr *net.UDPAddr) (quicx.UDPLikeConn, error) {
return nil, io.EOF return nil, io.EOF
}, },
@ -47,7 +47,7 @@ func TestErrorWrapperQUICListenerFailure(t *testing.T) {
func TestErrorWrapperUDPConnWriteToSuccess(t *testing.T) { func TestErrorWrapperUDPConnWriteToSuccess(t *testing.T) {
quc := &errorWrapperUDPConn{ quc := &errorWrapperUDPConn{
UDPLikeConn: &netxmocks.QUICUDPConn{ UDPLikeConn: &mocks.QUICUDPConn{
MockWriteTo: func(p []byte, addr net.Addr) (int, error) { MockWriteTo: func(p []byte, addr net.Addr) (int, error) {
return 10, nil return 10, nil
}, },
@ -67,7 +67,7 @@ func TestErrorWrapperUDPConnWriteToSuccess(t *testing.T) {
func TestErrorWrapperUDPConnWriteToFailure(t *testing.T) { func TestErrorWrapperUDPConnWriteToFailure(t *testing.T) {
expected := errors.New("mocked error") expected := errors.New("mocked error")
quc := &errorWrapperUDPConn{ quc := &errorWrapperUDPConn{
UDPLikeConn: &netxmocks.QUICUDPConn{ UDPLikeConn: &mocks.QUICUDPConn{
MockWriteTo: func(p []byte, addr net.Addr) (int, error) { MockWriteTo: func(p []byte, addr net.Addr) (int, error) {
return 0, expected return 0, expected
}, },
@ -87,7 +87,7 @@ func TestErrorWrapperUDPConnWriteToFailure(t *testing.T) {
func TestErrorWrapperUDPConnReadFromSuccess(t *testing.T) { func TestErrorWrapperUDPConnReadFromSuccess(t *testing.T) {
expected := errors.New("mocked error") expected := errors.New("mocked error")
quc := &errorWrapperUDPConn{ quc := &errorWrapperUDPConn{
UDPLikeConn: &netxmocks.QUICUDPConn{ UDPLikeConn: &mocks.QUICUDPConn{
MockReadFrom: func(b []byte) (int, net.Addr, error) { MockReadFrom: func(b []byte) (int, net.Addr, error) {
return 0, nil, expected return 0, nil, expected
}, },
@ -108,7 +108,7 @@ func TestErrorWrapperUDPConnReadFromSuccess(t *testing.T) {
func TestErrorWrapperUDPConnReadFromFailure(t *testing.T) { func TestErrorWrapperUDPConnReadFromFailure(t *testing.T) {
quc := &errorWrapperUDPConn{ quc := &errorWrapperUDPConn{
UDPLikeConn: &netxmocks.QUICUDPConn{ UDPLikeConn: &mocks.QUICUDPConn{
MockReadFrom: func(b []byte) (int, net.Addr, error) { MockReadFrom: func(b []byte) (int, net.Addr, error) {
return 10, nil, nil return 10, nil, nil
}, },
@ -129,7 +129,7 @@ func TestErrorWrapperUDPConnReadFromFailure(t *testing.T) {
func TestErrorWrapperQUICDialerFailure(t *testing.T) { func TestErrorWrapperQUICDialerFailure(t *testing.T) {
ctx := context.Background() ctx := context.Background()
d := &ErrorWrapperQUICDialer{Dialer: &netxmocks.QUICContextDialer{ d := &ErrorWrapperQUICDialer{Dialer: &mocks.QUICContextDialer{
MockDialContext: func(ctx context.Context, network, address string, tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error) { MockDialContext: func(ctx context.Context, network, address string, tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error) {
return nil, io.EOF return nil, io.EOF
}, },

View File

@ -6,13 +6,13 @@ import (
"net" "net"
"testing" "testing"
"github.com/ooni/probe-cli/v3/internal/netxmocks" "github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
) )
func TestErrorWrapperResolverSuccess(t *testing.T) { func TestErrorWrapperResolverSuccess(t *testing.T) {
orig := []string{"8.8.8.8"} orig := []string{"8.8.8.8"}
r := &ErrorWrapperResolver{ r := &ErrorWrapperResolver{
Resolver: &netxmocks.Resolver{ Resolver: &mocks.Resolver{
MockLookupHost: func(ctx context.Context, domain string) ([]string, error) { MockLookupHost: func(ctx context.Context, domain string) ([]string, error) {
return orig, nil return orig, nil
}, },
@ -29,7 +29,7 @@ func TestErrorWrapperResolverSuccess(t *testing.T) {
func TestErrorWrapperResolverFailure(t *testing.T) { func TestErrorWrapperResolverFailure(t *testing.T) {
r := &ErrorWrapperResolver{ r := &ErrorWrapperResolver{
Resolver: &netxmocks.Resolver{ Resolver: &mocks.Resolver{
MockLookupHost: func(ctx context.Context, domain string) ([]string, error) { MockLookupHost: func(ctx context.Context, domain string) ([]string, error) {
return nil, errors.New("no such host") return nil, errors.New("no such host")
}, },
@ -53,7 +53,7 @@ func TestErrorWrapperResolverFailure(t *testing.T) {
} }
func TestErrorWrapperResolverChildNetworkAddress(t *testing.T) { func TestErrorWrapperResolverChildNetworkAddress(t *testing.T) {
r := &ErrorWrapperResolver{Resolver: &netxmocks.Resolver{ r := &ErrorWrapperResolver{Resolver: &mocks.Resolver{
MockNetwork: func() string { MockNetwork: func() string {
return "udp" return "udp"
}, },

View File

@ -8,17 +8,17 @@ import (
"net" "net"
"testing" "testing"
"github.com/ooni/probe-cli/v3/internal/netxmocks" "github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
) )
func TestErrorWrapperTLSHandshakerFailure(t *testing.T) { func TestErrorWrapperTLSHandshakerFailure(t *testing.T) {
th := ErrorWrapperTLSHandshaker{TLSHandshaker: &netxmocks.TLSHandshaker{ th := ErrorWrapperTLSHandshaker{TLSHandshaker: &mocks.TLSHandshaker{
MockHandshake: func(ctx context.Context, conn net.Conn, config *tls.Config) (net.Conn, tls.ConnectionState, error) { MockHandshake: func(ctx context.Context, conn net.Conn, config *tls.Config) (net.Conn, tls.ConnectionState, error) {
return nil, tls.ConnectionState{}, io.EOF return nil, tls.ConnectionState{}, io.EOF
}, },
}} }}
conn, _, err := th.Handshake( conn, _, err := th.Handshake(
context.Background(), &netxmocks.Conn{ context.Background(), &mocks.Conn{
MockRead: func(b []byte) (int, error) { MockRead: func(b []byte) (int, error) {
return 0, io.EOF return 0, io.EOF
}, },

View File

@ -9,7 +9,7 @@ import (
"syscall" "syscall"
"github.com/ooni/probe-cli/v3/internal/fsx" "github.com/ooni/probe-cli/v3/internal/fsx"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
func ExampleOpenFile_openingDir() { func ExampleOpenFile_openingDir() {

View File

@ -12,7 +12,7 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
// Logger is the logger expected by this package. // Logger is the logger expected by this package.

View File

@ -4,7 +4,7 @@ import (
"net/http" "net/http"
"time" "time"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
type FakeTransport struct { type FakeTransport struct {

View File

@ -12,7 +12,7 @@ import (
"net/url" "net/url"
"regexp" "regexp"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
const ( const (

View File

@ -1,16 +1,16 @@
// Code generated by go generate; DO NOT EDIT. // Code generated by go generate; DO NOT EDIT.
// 2021-07-02 14:26:19.300018 +0200 CEST m=+0.978891751 // 2021-09-05 14:01:12.627844 +0200 CEST m=+0.441951210
// https://curl.haxx.se/ca/cacert.pem // https://curl.haxx.se/ca/cacert.pem
package netxlite package netxlite
//go:generate go run ./generator/ "https://curl.haxx.se/ca/cacert.pem" //go:generate go run ./internal/generator/ "https://curl.haxx.se/ca/cacert.pem"
const pemcerts string = ` const pemcerts string = `
## ##
## Bundle of CA Root Certificates ## Bundle of CA Root Certificates
## ##
## Certificate data from Mozilla as of: Tue May 25 03:12:05 2021 GMT ## Certificate data from Mozilla as of: Mon Jul 5 21:35:54 2021 GMT
## ##
## This is a bundle of X.509 certificates of public Certificate Authorities ## This is a bundle of X.509 certificates of public Certificate Authorities
## (CA). These were automatically extracted from Mozilla's root certificates ## (CA). These were automatically extracted from Mozilla's root certificates
@ -23,7 +23,7 @@ const pemcerts string = `
## Just configure this file as the SSLCACertificateFile. ## Just configure this file as the SSLCACertificateFile.
## ##
## Conversion done with mk-ca-bundle.pl version 1.28. ## Conversion done with mk-ca-bundle.pl version 1.28.
## SHA256: e292bd4e2d500c86df45b830d89417be5c42ee670408f1d2c454c63d8a782865 ## SHA256: c8f6733d1ff4e6a4769c182971a1234f95ae079247a9c439a13423fe8ba5c24f
## ##
@ -165,38 +165,6 @@ Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2G9w84FoVxp7Z
12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg== 12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==
-----END CERTIFICATE----- -----END CERTIFICATE-----
QuoVadis Root CA
================
-----BEGIN CERTIFICATE-----
MIIF0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SBwYXJ0eSBhc3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJs
ZSBzdGFuZGFyZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRpb24gcHJh
Y3RpY2VzLCBhbmQgdGhlIFF1b1ZhZGlzIENlcnRpZmljYXRlIFBvbGljeS4wIgYIKwYBBQUHAgEW
Fmh0dHA6Ly93d3cucXVvdmFkaXMuYm0wHQYDVR0OBBYEFItLbe3TKbkGGew5Oanwl4Rqy+/fMIGu
BgNVHSMEgaYwgaOAFItLbe3TKbkGGew5Oanwl4Rqy+/foYGEpIGBMH8xCzAJBgNVBAYTAkJNMRkw
FwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0
aG9yaXR5MS4wLAYDVQQDEyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggQ6
tlCLMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAitQUtf70mpKnGdSkfnIYj9lo
fFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf87C9TqnN7Az10buYWnuul
LsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1RcHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2x
gI4JVrmcGmD+XcHXetwReNDWXcG31a0ymQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi
5upZIof4l/UO/erMkqQWxFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi
5nrQNiOKSnQ2+Q==
-----END CERTIFICATE-----
QuoVadis Root CA 2 QuoVadis Root CA 2
================== ==================
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
@ -284,26 +252,6 @@ s58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJUJRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ
FL39vmwLAw== FL39vmwLAw==
-----END CERTIFICATE----- -----END CERTIFICATE-----
Sonera Class 2 Root CA
======================
-----BEGIN CERTIFICATE-----
MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEPMA0GA1UEChMG
U29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAxMDQwNjA3Mjk0MFoXDTIxMDQw
NjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNVBAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJh
IENsYXNzMiBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3
/Ei9vX+ALTU74W+oZ6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybT
dXnt5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s3TmVToMG
f+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2EjvOr7nQKV0ba5cTppCD8P
tOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu8nYybieDwnPz3BjotJPqdURrBGAgcVeH
nfO+oJAjPYok4doh28MCAwEAAaMzMDEwDwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITT
XjwwCwYDVR0PBAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt
0jSv9zilzqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/3DEI
cbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvDFNr450kkkdAdavph
Oe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6Tk6ezAyNlNzZRZxe7EJQY670XcSx
EtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLH
llpwrN9M
-----END CERTIFICATE-----
XRamp Global CA Root XRamp Global CA Root
==================== ====================
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
@ -1203,27 +1151,6 @@ OR/qnuOf0GZvBeyqdn6/axag67XH/JJULysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9
vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg== vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==
-----END CERTIFICATE----- -----END CERTIFICATE-----
Trustis FPS Root CA
===================
-----BEGIN CERTIFICATE-----
MIIDZzCCAk+gAwIBAgIQGx+ttiD5JNM2a/fH8YygWTANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQG
EwJHQjEYMBYGA1UEChMPVHJ1c3RpcyBMaW1pdGVkMRwwGgYDVQQLExNUcnVzdGlzIEZQUyBSb290
IENBMB4XDTAzMTIyMzEyMTQwNloXDTI0MDEyMTExMzY1NFowRTELMAkGA1UEBhMCR0IxGDAWBgNV
BAoTD1RydXN0aXMgTGltaXRlZDEcMBoGA1UECxMTVHJ1c3RpcyBGUFMgUm9vdCBDQTCCASIwDQYJ
KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMVQe547NdDfxIzNjpvto8A2mfRC6qc+gIMPpqdZh8mQ
RUN+AOqGeSoDvT03mYlmt+WKVoaTnGhLaASMk5MCPjDSNzoiYYkchU59j9WvezX2fihHiTHcDnlk
H5nSW7r+f2C/revnPDgpai/lkQtV/+xvWNUtyd5MZnGPDNcE2gfmHhjjvSkCqPoc4Vu5g6hBSLwa
cY3nYuUtsuvffM/bq1rKMfFMIvMFE/eC+XN5DL7XSxzA0RU8k0Fk0ea+IxciAIleH2ulrG6nS4zt
o3Lmr2NNL4XSFDWaLk6M6jKYKIahkQlBOrTh4/L68MkKokHdqeMDx4gVOxzUGpTXn2RZEm0CAwEA
AaNTMFEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBS6+nEleYtXQSUhhgtx67JkDoshZzAd
BgNVHQ4EFgQUuvpxJXmLV0ElIYYLceuyZA6LIWcwDQYJKoZIhvcNAQEFBQADggEBAH5Y//01GX2c
GE+esCu8jowU/yyg2kdbw++BLa8F6nRIW/M+TgfHbcWzk88iNVy2P3UnXwmWzaD+vkAMXBJV+JOC
yinpXj9WV4s4NvdFGkwozZ5BuO1WTISkQMi4sKUraXAEasP41BIy+Q7DsdwyhEQsb8tGD+pmQQ9P
8Vilpg0ND2HepZ5dfWWhPBfnqFVO76DH7cZEf1T1o+CP8HxVIo8ptoGj4W1OLBuAZ+ytIJ8MYmHV
l/9D7S3B2l0pKoU/rGXuhg8FjZBf3+6f9L/uHfuY5H+QK4R4EA5sSVPvFVtlRkpdr7r7OnIdzfYl
iB6XzCGcKQENZetX2fNXlrtIzYE=
-----END CERTIFICATE-----
Buypass Class 2 Root CA Buypass Class 2 Root CA
======================= =======================
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
@ -3146,4 +3073,113 @@ vLtoURMMA/cVi4RguYv/Uo7njLwcAjA8+RHUjE7AwWHCFUyqqx0LMV87HOIAl0Qx5v5zli/altP+
CAezNIm8BZ/3Hobui3A= CAezNIm8BZ/3Hobui3A=
-----END CERTIFICATE----- -----END CERTIFICATE-----
GLOBALTRUST 2020
================
-----BEGIN CERTIFICATE-----
MIIFgjCCA2qgAwIBAgILWku9WvtPilv6ZeUwDQYJKoZIhvcNAQELBQAwTTELMAkGA1UEBhMCQVQx
IzAhBgNVBAoTGmUtY29tbWVyY2UgbW9uaXRvcmluZyBHbWJIMRkwFwYDVQQDExBHTE9CQUxUUlVT
VCAyMDIwMB4XDTIwMD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QOaA
4kZf5ePBAFmo+eggvIksDkc0C+pXwlM2/KfUrzHN/gLldfq5Jwn58/U7yn2fqSLLiMmq0Uc9Nneo
WWRrJ8/vJ8HjJLWG965+Mk2weWjROeiQWMODvA8s1pfrzgzhIMfatz7DP78v3DSk+yshzWePS/Tj
6tQ/50+6uaWTRRxmHyH6ZF5v4HaUMst19W7l9o/HuKTMqJZ9ZPskWkoDbGs4xugDQ5r3V7mzKWmT
OPQD8rv7gmsHINFSH5pkAnuYZttcTVoP0ISVoDwUQwbKytu4QTbaakRnh6+v40URFWkIsr4WOZck
bxJF0WddCajJFdr60qZfE2Efv4WstK2tBZQIgx51F9NxO5NQI1mg7TyRVJ12AMXDuDjb
-----END CERTIFICATE-----
` `

View File

@ -12,17 +12,17 @@ type Dialer interface {
DialContext(ctx context.Context, network, address string) (net.Conn, error) DialContext(ctx context.Context, network, address string) (net.Conn, error)
} }
// DefaultDialer is the Dialer we use by default. // defaultDialer is the Dialer we use by default.
var DefaultDialer = &net.Dialer{ var defaultDialer = &net.Dialer{
Timeout: 15 * time.Second, Timeout: 15 * time.Second,
KeepAlive: 15 * time.Second, KeepAlive: 15 * time.Second,
} }
var _ Dialer = DefaultDialer var _ Dialer = defaultDialer
// DialerResolver is a dialer that uses the configured Resolver to resolver a // dialerResolver is a dialer that uses the configured Resolver to resolver a
// domain name to IP addresses, and the configured Dialer to connect. // domain name to IP addresses, and the configured Dialer to connect.
type DialerResolver struct { type dialerResolver struct {
// Dialer is the underlying Dialer. // Dialer is the underlying Dialer.
Dialer Dialer Dialer Dialer
@ -30,10 +30,10 @@ type DialerResolver struct {
Resolver Resolver Resolver Resolver
} }
var _ Dialer = &DialerResolver{} var _ Dialer = &dialerResolver{}
// DialContext implements Dialer.DialContext. // DialContext implements Dialer.DialContext.
func (d *DialerResolver) DialContext(ctx context.Context, network, address string) (net.Conn, error) { func (d *dialerResolver) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
onlyhost, onlyport, err := net.SplitHostPort(address) onlyhost, onlyport, err := net.SplitHostPort(address)
if err != nil { if err != nil {
return nil, err return nil, err
@ -59,15 +59,15 @@ func (d *DialerResolver) DialContext(ctx context.Context, network, address strin
} }
// lookupHost performs a domain name resolution. // lookupHost performs a domain name resolution.
func (d *DialerResolver) lookupHost(ctx context.Context, hostname string) ([]string, error) { func (d *dialerResolver) lookupHost(ctx context.Context, hostname string) ([]string, error) {
if net.ParseIP(hostname) != nil { if net.ParseIP(hostname) != nil {
return []string{hostname}, nil return []string{hostname}, nil
} }
return d.Resolver.LookupHost(ctx, hostname) return d.Resolver.LookupHost(ctx, hostname)
} }
// DialerLogger is a Dialer with logging. // dialerLogger is a Dialer with logging.
type DialerLogger struct { type dialerLogger struct {
// Dialer is the underlying dialer. // Dialer is the underlying dialer.
Dialer Dialer Dialer Dialer
@ -75,10 +75,10 @@ type DialerLogger struct {
Logger Logger Logger Logger
} }
var _ Dialer = &DialerLogger{} var _ Dialer = &dialerLogger{}
// DialContext implements Dialer.DialContext // DialContext implements Dialer.DialContext
func (d *DialerLogger) DialContext(ctx context.Context, network, address string) (net.Conn, error) { func (d *dialerLogger) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
d.Logger.Debugf("dial %s/%s...", address, network) d.Logger.Debugf("dial %s/%s...", address, network)
start := time.Now() start := time.Now()
conn, err := d.Dialer.DialContext(ctx, network, address) conn, err := d.Dialer.DialContext(ctx, network, address)

View File

@ -10,11 +10,11 @@ import (
"time" "time"
"github.com/apex/log" "github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/netxmocks" "github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
) )
func TestDialerResolverNoPort(t *testing.T) { func TestDialerResolverNoPort(t *testing.T) {
dialer := &DialerResolver{Dialer: &net.Dialer{}, Resolver: DefaultResolver} dialer := &dialerResolver{Dialer: &net.Dialer{}, Resolver: DefaultResolver}
conn, err := dialer.DialContext(context.Background(), "tcp", "ooni.nu") conn, err := dialer.DialContext(context.Background(), "tcp", "ooni.nu")
if err == nil || !strings.HasSuffix(err.Error(), "missing port in address") { if err == nil || !strings.HasSuffix(err.Error(), "missing port in address") {
t.Fatal("not the error we expected", err) t.Fatal("not the error we expected", err)
@ -25,7 +25,7 @@ func TestDialerResolverNoPort(t *testing.T) {
} }
func TestDialerResolverLookupHostAddress(t *testing.T) { func TestDialerResolverLookupHostAddress(t *testing.T) {
dialer := &DialerResolver{Dialer: new(net.Dialer), Resolver: &netxmocks.Resolver{ dialer := &dialerResolver{Dialer: new(net.Dialer), Resolver: &mocks.Resolver{
MockLookupHost: func(ctx context.Context, domain string) ([]string, error) { MockLookupHost: func(ctx context.Context, domain string) ([]string, error) {
return nil, errors.New("we should not call this function") return nil, errors.New("we should not call this function")
}, },
@ -41,7 +41,7 @@ func TestDialerResolverLookupHostAddress(t *testing.T) {
func TestDialerResolverLookupHostFailure(t *testing.T) { func TestDialerResolverLookupHostFailure(t *testing.T) {
expected := errors.New("mocked error") expected := errors.New("mocked error")
dialer := &DialerResolver{Dialer: new(net.Dialer), Resolver: &netxmocks.Resolver{ dialer := &dialerResolver{Dialer: new(net.Dialer), Resolver: &mocks.Resolver{
MockLookupHost: func(ctx context.Context, domain string) ([]string, error) { MockLookupHost: func(ctx context.Context, domain string) ([]string, error) {
return nil, expected return nil, expected
}, },
@ -57,7 +57,7 @@ func TestDialerResolverLookupHostFailure(t *testing.T) {
} }
func TestDialerResolverDialForSingleIPFails(t *testing.T) { func TestDialerResolverDialForSingleIPFails(t *testing.T) {
dialer := &DialerResolver{Dialer: &netxmocks.Dialer{ dialer := &dialerResolver{Dialer: &mocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) { MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
return nil, io.EOF return nil, io.EOF
}, },
@ -72,12 +72,12 @@ func TestDialerResolverDialForSingleIPFails(t *testing.T) {
} }
func TestDialerResolverDialForManyIPFails(t *testing.T) { func TestDialerResolverDialForManyIPFails(t *testing.T) {
dialer := &DialerResolver{ dialer := &dialerResolver{
Dialer: &netxmocks.Dialer{ Dialer: &mocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) { MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
return nil, io.EOF return nil, io.EOF
}, },
}, Resolver: &netxmocks.Resolver{ }, Resolver: &mocks.Resolver{
MockLookupHost: func(ctx context.Context, domain string) ([]string, error) { MockLookupHost: func(ctx context.Context, domain string) ([]string, error) {
return []string{"1.1.1.1", "8.8.8.8"}, nil return []string{"1.1.1.1", "8.8.8.8"}, nil
}, },
@ -92,15 +92,15 @@ func TestDialerResolverDialForManyIPFails(t *testing.T) {
} }
func TestDialerResolverDialForManyIPSuccess(t *testing.T) { func TestDialerResolverDialForManyIPSuccess(t *testing.T) {
dialer := &DialerResolver{Dialer: &netxmocks.Dialer{ dialer := &dialerResolver{Dialer: &mocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) { MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
return &netxmocks.Conn{ return &mocks.Conn{
MockClose: func() error { MockClose: func() error {
return nil return nil
}, },
}, nil }, nil
}, },
}, Resolver: &netxmocks.Resolver{ }, Resolver: &mocks.Resolver{
MockLookupHost: func(ctx context.Context, domain string) ([]string, error) { MockLookupHost: func(ctx context.Context, domain string) ([]string, error) {
return []string{"1.1.1.1", "8.8.8.8"}, nil return []string{"1.1.1.1", "8.8.8.8"}, nil
}, },
@ -116,10 +116,10 @@ func TestDialerResolverDialForManyIPSuccess(t *testing.T) {
} }
func TestDialerLoggerSuccess(t *testing.T) { func TestDialerLoggerSuccess(t *testing.T) {
d := &DialerLogger{ d := &dialerLogger{
Dialer: &netxmocks.Dialer{ Dialer: &mocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) { MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
return &netxmocks.Conn{ return &mocks.Conn{
MockClose: func() error { MockClose: func() error {
return nil return nil
}, },
@ -139,8 +139,8 @@ func TestDialerLoggerSuccess(t *testing.T) {
} }
func TestDialerLoggerFailure(t *testing.T) { func TestDialerLoggerFailure(t *testing.T) {
d := &DialerLogger{ d := &dialerLogger{
Dialer: &netxmocks.Dialer{ Dialer: &mocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) { MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
return nil, io.EOF return nil, io.EOF
}, },
@ -158,7 +158,7 @@ func TestDialerLoggerFailure(t *testing.T) {
func TestDefaultDialerHasTimeout(t *testing.T) { func TestDefaultDialerHasTimeout(t *testing.T) {
expected := 15 * time.Second expected := 15 * time.Second
if DefaultDialer.Timeout != expected { if defaultDialer.Timeout != expected {
t.Fatal("unexpected timeout value") t.Fatal("unexpected timeout value")
} }
} }

View File

@ -17,8 +17,8 @@ type HTTPTransport interface {
CloseIdleConnections() CloseIdleConnections()
} }
// HTTPTransportLogger is an HTTPTransport with logging. // httpTransportLogger is an HTTPTransport with logging.
type HTTPTransportLogger struct { type httpTransportLogger struct {
// HTTPTransport is the underlying HTTP transport. // HTTPTransport is the underlying HTTP transport.
HTTPTransport HTTPTransport HTTPTransport HTTPTransport
@ -26,10 +26,10 @@ type HTTPTransportLogger struct {
Logger Logger Logger Logger
} }
var _ HTTPTransport = &HTTPTransportLogger{} var _ HTTPTransport = &httpTransportLogger{}
// RoundTrip implements HTTPTransport.RoundTrip. // RoundTrip implements HTTPTransport.RoundTrip.
func (txp *HTTPTransportLogger) RoundTrip(req *http.Request) (*http.Response, error) { func (txp *httpTransportLogger) RoundTrip(req *http.Request) (*http.Response, error) {
host := req.Host host := req.Host
if host == "" { if host == "" {
host = req.URL.Host host = req.URL.Host
@ -39,7 +39,7 @@ func (txp *HTTPTransportLogger) RoundTrip(req *http.Request) (*http.Response, er
} }
// logTrip is an HTTP round trip with logging. // logTrip is an HTTP round trip with logging.
func (txp *HTTPTransportLogger) logTrip(req *http.Request) (*http.Response, error) { func (txp *httpTransportLogger) logTrip(req *http.Request) (*http.Response, error) {
txp.Logger.Debugf("> %s %s", req.Method, req.URL.String()) txp.Logger.Debugf("> %s %s", req.Method, req.URL.String())
for key, values := range req.Header { for key, values := range req.Header {
for _, value := range values { for _, value := range values {
@ -63,7 +63,7 @@ func (txp *HTTPTransportLogger) logTrip(req *http.Request) (*http.Response, erro
} }
// CloseIdleConnections implement HTTPTransport.CloseIdleConnections. // CloseIdleConnections implement HTTPTransport.CloseIdleConnections.
func (txp *HTTPTransportLogger) CloseIdleConnections() { func (txp *httpTransportLogger) CloseIdleConnections() {
txp.HTTPTransport.CloseIdleConnections() txp.HTTPTransport.CloseIdleConnections()
} }

View File

@ -8,9 +8,9 @@ import (
) )
func TestHTTP3TransportWorks(t *testing.T) { func TestHTTP3TransportWorks(t *testing.T) {
d := &QUICDialerResolver{ d := &quicDialerResolver{
Dialer: &QUICDialerQUICGo{ Dialer: &quicDialerQUICGo{
QUICListener: &QUICListenerStdlib{}, QUICListener: &quicListenerStdlib{},
}, },
Resolver: &net.Resolver{}, Resolver: &net.Resolver{},
} }

View File

@ -13,14 +13,14 @@ import (
"github.com/apex/log" "github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/atomicx" "github.com/ooni/probe-cli/v3/internal/atomicx"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
"github.com/ooni/probe-cli/v3/internal/netxmocks" "github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
) )
func TestHTTPTransportLoggerFailure(t *testing.T) { func TestHTTPTransportLoggerFailure(t *testing.T) {
txp := &HTTPTransportLogger{ txp := &httpTransportLogger{
Logger: log.Log, Logger: log.Log,
HTTPTransport: &netxmocks.HTTPTransport{ HTTPTransport: &mocks.HTTPTransport{
MockRoundTrip: func(req *http.Request) (*http.Response, error) { MockRoundTrip: func(req *http.Request) (*http.Response, error) {
return nil, io.EOF return nil, io.EOF
}, },
@ -38,9 +38,9 @@ func TestHTTPTransportLoggerFailure(t *testing.T) {
func TestHTTPTransportLoggerFailureWithNoHostHeader(t *testing.T) { func TestHTTPTransportLoggerFailureWithNoHostHeader(t *testing.T) {
foundHost := &atomicx.Int64{} foundHost := &atomicx.Int64{}
txp := &HTTPTransportLogger{ txp := &httpTransportLogger{
Logger: log.Log, Logger: log.Log,
HTTPTransport: &netxmocks.HTTPTransport{ HTTPTransport: &mocks.HTTPTransport{
MockRoundTrip: func(req *http.Request) (*http.Response, error) { MockRoundTrip: func(req *http.Request) (*http.Response, error) {
if req.Header.Get("Host") == "www.google.com" { if req.Header.Get("Host") == "www.google.com" {
foundHost.Add(1) foundHost.Add(1)
@ -70,9 +70,9 @@ func TestHTTPTransportLoggerFailureWithNoHostHeader(t *testing.T) {
} }
func TestHTTPTransportLoggerSuccess(t *testing.T) { func TestHTTPTransportLoggerSuccess(t *testing.T) {
txp := &HTTPTransportLogger{ txp := &httpTransportLogger{
Logger: log.Log, Logger: log.Log,
HTTPTransport: &netxmocks.HTTPTransport{ HTTPTransport: &mocks.HTTPTransport{
MockRoundTrip: func(req *http.Request) (*http.Response, error) { MockRoundTrip: func(req *http.Request) (*http.Response, error) {
return &http.Response{ return &http.Response{
Body: io.NopCloser(strings.NewReader("")), Body: io.NopCloser(strings.NewReader("")),
@ -95,8 +95,8 @@ func TestHTTPTransportLoggerSuccess(t *testing.T) {
func TestHTTPTransportLoggerCloseIdleConnections(t *testing.T) { func TestHTTPTransportLoggerCloseIdleConnections(t *testing.T) {
calls := &atomicx.Int64{} calls := &atomicx.Int64{}
txp := &HTTPTransportLogger{ txp := &httpTransportLogger{
HTTPTransport: &netxmocks.HTTPTransport{ HTTPTransport: &mocks.HTTPTransport{
MockCloseIdleConnections: func() { MockCloseIdleConnections: func() {
calls.Add(1) calls.Add(1)
}, },
@ -110,11 +110,11 @@ func TestHTTPTransportLoggerCloseIdleConnections(t *testing.T) {
} }
func TestHTTPTransportWorks(t *testing.T) { func TestHTTPTransportWorks(t *testing.T) {
d := &DialerResolver{ d := &dialerResolver{
Dialer: DefaultDialer, Dialer: defaultDialer,
Resolver: &net.Resolver{}, Resolver: &net.Resolver{},
} }
th := &TLSHandshakerConfigurable{} th := &tlsHandshakerConfigurable{}
txp := NewHTTPTransport(d, &tls.Config{}, th) txp := NewHTTPTransport(d, &tls.Config{}, th)
client := &http.Client{Transport: txp} client := &http.Client{Transport: txp}
resp, err := client.Get("https://www.google.com/robots.txt") resp, err := client.Get("https://www.google.com/robots.txt")
@ -127,8 +127,8 @@ func TestHTTPTransportWorks(t *testing.T) {
func TestHTTPTransportWithFailingDialer(t *testing.T) { func TestHTTPTransportWithFailingDialer(t *testing.T) {
expected := errors.New("mocked error") expected := errors.New("mocked error")
d := &DialerResolver{ d := &dialerResolver{
Dialer: &netxmocks.Dialer{ Dialer: &mocks.Dialer{
MockDialContext: func(ctx context.Context, MockDialContext: func(ctx context.Context,
network, address string) (net.Conn, error) { network, address string) (net.Conn, error) {
return nil, expected return nil, expected
@ -136,7 +136,7 @@ func TestHTTPTransportWithFailingDialer(t *testing.T) {
}, },
Resolver: &net.Resolver{}, Resolver: &net.Resolver{},
} }
th := &TLSHandshakerConfigurable{} th := &tlsHandshakerConfigurable{}
txp := NewHTTPTransport(d, &tls.Config{}, th) txp := NewHTTPTransport(d, &tls.Config{}, th)
client := &http.Client{Transport: txp} client := &http.Client{Transport: txp}
resp, err := client.Get("https://www.google.com/robots.txt") resp, err := client.Get("https://www.google.com/robots.txt")

View File

@ -19,7 +19,7 @@ import (
"text/template" "text/template"
"time" "time"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
var tmpl = template.Must(template.New("").Parse(`// Code generated by go generate; DO NOT EDIT. var tmpl = template.Must(template.New("").Parse(`// Code generated by go generate; DO NOT EDIT.
@ -28,7 +28,7 @@ var tmpl = template.Must(template.New("").Parse(`// Code generated by go generat
package netxlite package netxlite
//{{ .GoGenerate }} go run ./generator/ "{{ .URL }}" //{{ .GoGenerate }} go run ./internal/generator/ "{{ .URL }}"
const pemcerts string = ` + "`" + ` const pemcerts string = ` + "`" + `
{{ .Bundle }} {{ .Bundle }}

View File

@ -6,7 +6,7 @@ import (
"log" "log"
"strings" "strings"
"github.com/ooni/probe-cli/v3/internal/iox" "github.com/ooni/probe-cli/v3/internal/netxlite/iox"
) )
func ExampleReadAllContext() { func ExampleReadAllContext() {

View File

@ -33,19 +33,6 @@ func ReadAllContext(ctx context.Context, r io.Reader) ([]byte, error) {
} }
} }
// MockableReader allows to mock any io.Reader.
type MockableReader struct {
MockRead func(b []byte) (int, error)
}
// MockableReader implements an io.Reader.
var _ io.Reader = &MockableReader{}
// Read implements io.Reader.Read.
func (r *MockableReader) Read(b []byte) (int, error) {
return r.MockRead(b)
}
// CopyContext is like io.Copy but may terminate earlier // CopyContext is like io.Copy but may terminate earlier
// when the context expires. This function has the same // when the context expires. This function has the same
// caveats of ReadAllContext regarding the temporary leaking // caveats of ReadAllContext regarding the temporary leaking

View File

@ -7,6 +7,8 @@ import (
"strings" "strings"
"testing" "testing"
"time" "time"
"github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
) )
func TestReadAllContextCommonCase(t *testing.T) { func TestReadAllContextCommonCase(t *testing.T) {
@ -23,7 +25,7 @@ func TestReadAllContextCommonCase(t *testing.T) {
func TestReadAllContextWithError(t *testing.T) { func TestReadAllContextWithError(t *testing.T) {
expected := errors.New("mocked error") expected := errors.New("mocked error")
r := &MockableReader{ r := &mocks.Reader{
MockRead: func(b []byte) (int, error) { MockRead: func(b []byte) (int, error) {
return 0, expected return 0, expected
}, },
@ -53,7 +55,7 @@ func TestReadAllContextWithCancelledContext(t *testing.T) {
func TestReadAllContextWithErrorAndCancelledContext(t *testing.T) { func TestReadAllContextWithErrorAndCancelledContext(t *testing.T) {
expected := errors.New("mocked error") expected := errors.New("mocked error")
r := &MockableReader{ r := &mocks.Reader{
MockRead: func(b []byte) (int, error) { MockRead: func(b []byte) (int, error) {
time.Sleep(time.Millisecond) time.Sleep(time.Millisecond)
return 0, expected return 0, expected
@ -84,7 +86,7 @@ func TestCopyContextCommonCase(t *testing.T) {
func TestCopyContextWithError(t *testing.T) { func TestCopyContextWithError(t *testing.T) {
expected := errors.New("mocked error") expected := errors.New("mocked error")
r := &MockableReader{ r := &mocks.Reader{
MockRead: func(b []byte) (int, error) { MockRead: func(b []byte) (int, error) {
return 0, expected return 0, expected
}, },
@ -114,7 +116,7 @@ func TestCopyContextWithCancelledContext(t *testing.T) {
func TestCopyContextWithErrorAndCancelledContext(t *testing.T) { func TestCopyContextWithErrorAndCancelledContext(t *testing.T) {
expected := errors.New("mocked error") expected := errors.New("mocked error")
r := &MockableReader{ r := &mocks.Reader{
MockRead: func(b []byte) (int, error) { MockRead: func(b []byte) (int, error) {
time.Sleep(time.Millisecond) time.Sleep(time.Millisecond)
return 0, expected return 0, expected

View File

@ -37,3 +37,25 @@ func reduceErrors(errorslist []error) error {
// TODO(bassosimone): handle this case in a better way // TODO(bassosimone): handle this case in a better way
return errorslist[0] return errorslist[0]
} }
// These vars export internal names to legacy ooni/probe-cli code.
var (
DefaultDialer = defaultDialer
DefaultTLSHandshaker = defaultTLSHandshaker
)
// These types export internal names to legacy ooni/probe-cli code.
type (
DialerResolver = dialerResolver
DialerLogger = dialerLogger
HTTPTransportLogger = httpTransportLogger
QUICListenerStdlib = quicListenerStdlib
QUICDialerQUICGo = quicDialerQUICGo
QUICDialerResolver = quicDialerResolver
QUICDialerLogger = quicDialerLogger
ResolverSystem = resolverSystem
ResolverLogger = resolverLogger
ResolverIDNA = resolverIDNA
TLSHandshakerConfigurable = tlsHandshakerConfigurable
TLSHandshakerLogger = tlsHandshakerLogger
)

View File

@ -1,4 +1,4 @@
package netxmocks package mocks
import ( import (
"net" "net"

View File

@ -1,4 +1,4 @@
package netxmocks package mocks
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package netxmocks package mocks
import ( import (
"context" "context"

View File

@ -1,4 +1,4 @@
package netxmocks package mocks
import ( import (
"context" "context"

View File

@ -0,0 +1,2 @@
// Package mocks contains mocks for netx types.
package mocks

View File

@ -1,4 +1,4 @@
package netxmocks package mocks
import "net/http" import "net/http"

View File

@ -1,4 +1,4 @@
package netxmocks package mocks
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package netxmocks package mocks
import ( import (
"context" "context"
@ -8,7 +8,7 @@ import (
"time" "time"
"github.com/lucas-clemente/quic-go" "github.com/lucas-clemente/quic-go"
"github.com/ooni/probe-cli/v3/internal/quicx" "github.com/ooni/probe-cli/v3/internal/netxlite/quicx"
) )
// QUICListener is a mockable netxlite.QUICListener. // QUICListener is a mockable netxlite.QUICListener.

View File

@ -1,4 +1,4 @@
package netxmocks package mocks
import ( import (
"context" "context"
@ -12,7 +12,7 @@ import (
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/lucas-clemente/quic-go" "github.com/lucas-clemente/quic-go"
"github.com/ooni/probe-cli/v3/internal/quicx" "github.com/ooni/probe-cli/v3/internal/netxlite/quicx"
) )
func TestQUICListenerListen(t *testing.T) { func TestQUICListenerListen(t *testing.T) {

View File

@ -0,0 +1,16 @@
package mocks
import "io"
// Reader allows to mock any io.Reader.
type Reader struct {
MockRead func(b []byte) (int, error)
}
// MockableReader implements an io.Reader.
var _ io.Reader = &Reader{}
// Read implements io.Reader.Read.
func (r *Reader) Read(b []byte) (int, error) {
return r.MockRead(b)
}

View File

@ -0,0 +1,23 @@
package mocks
import (
"errors"
"testing"
)
func TestReaderRead(t *testing.T) {
expected := errors.New("mocked error")
r := &Reader{
MockRead: func(b []byte) (int, error) {
return 0, expected
},
}
b := make([]byte, 128)
count, err := r.Read(b)
if !errors.Is(err, expected) {
t.Fatal("unexpected error", err)
}
if count != 0 {
t.Fatal("unexpected count", count)
}
}

View File

@ -1,4 +1,4 @@
package netxmocks package mocks
import "context" import "context"

View File

@ -1,4 +1,4 @@
package netxmocks package mocks
import ( import (
"context" "context"

View File

@ -1,4 +1,4 @@
package netxmocks package mocks
import "crypto/tls" import "crypto/tls"

View File

@ -1,4 +1,4 @@
package netxmocks package mocks
import ( import (
"crypto/tls" "crypto/tls"

View File

@ -1,4 +1,4 @@
package netxmocks package mocks
import ( import (
"context" "context"

View File

@ -1,4 +1,4 @@
package netxmocks package mocks
import ( import (
"context" "context"

View File

@ -8,7 +8,7 @@ import (
"strconv" "strconv"
"github.com/lucas-clemente/quic-go" "github.com/lucas-clemente/quic-go"
"github.com/ooni/probe-cli/v3/internal/quicx" "github.com/ooni/probe-cli/v3/internal/netxlite/quicx"
) )
// QUICContextDialer is a dialer for QUIC using Context. // QUICContextDialer is a dialer for QUIC using Context.
@ -26,18 +26,18 @@ type QUICListener interface {
Listen(addr *net.UDPAddr) (quicx.UDPLikeConn, error) Listen(addr *net.UDPAddr) (quicx.UDPLikeConn, error)
} }
// QUICListenerStdlib is a QUICListener using the standard library. // quicListenerStdlib is a QUICListener using the standard library.
type QUICListenerStdlib struct{} type quicListenerStdlib struct{}
var _ QUICListener = &QUICListenerStdlib{} var _ QUICListener = &quicListenerStdlib{}
// Listen implements QUICListener.Listen. // Listen implements QUICListener.Listen.
func (qls *QUICListenerStdlib) Listen(addr *net.UDPAddr) (quicx.UDPLikeConn, error) { func (qls *quicListenerStdlib) Listen(addr *net.UDPAddr) (quicx.UDPLikeConn, error) {
return net.ListenUDP("udp", addr) return net.ListenUDP("udp", addr)
} }
// QUICDialerQUICGo dials using the lucas-clemente/quic-go library. // quicDialerQUICGo dials using the lucas-clemente/quic-go library.
type QUICDialerQUICGo struct { type quicDialerQUICGo struct {
// QUICListener is the underlying QUICListener to use. // QUICListener is the underlying QUICListener to use.
QUICListener QUICListener QUICListener QUICListener
@ -47,7 +47,7 @@ type QUICDialerQUICGo struct {
quicConfig *quic.Config) (quic.EarlySession, error) quicConfig *quic.Config) (quic.EarlySession, error)
} }
var _ QUICContextDialer = &QUICDialerQUICGo{} var _ QUICContextDialer = &quicDialerQUICGo{}
// errInvalidIP indicates that a string is not a valid IP. // errInvalidIP indicates that a string is not a valid IP.
var errInvalidIP = errors.New("netxlite: invalid IP") var errInvalidIP = errors.New("netxlite: invalid IP")
@ -60,7 +60,7 @@ var errInvalidIP = errors.New("netxlite: invalid IP")
// //
// 2. if tlsConfig.NextProtos is empty _and_ the port is 443 or 8853, // 2. if tlsConfig.NextProtos is empty _and_ the port is 443 or 8853,
// then we configure, respectively, "h3" and "dq". // then we configure, respectively, "h3" and "dq".
func (d *QUICDialerQUICGo) DialContext(ctx context.Context, network string, func (d *quicDialerQUICGo) DialContext(ctx context.Context, network string,
address string, tlsConfig *tls.Config, quicConfig *quic.Config) ( address string, tlsConfig *tls.Config, quicConfig *quic.Config) (
quic.EarlySession, error) { quic.EarlySession, error) {
onlyhost, onlyport, err := net.SplitHostPort(address) onlyhost, onlyport, err := net.SplitHostPort(address)
@ -89,7 +89,7 @@ func (d *QUICDialerQUICGo) DialContext(ctx context.Context, network string,
return &quicSessionOwnsConn{EarlySession: sess, conn: pconn}, nil return &quicSessionOwnsConn{EarlySession: sess, conn: pconn}, nil
} }
func (d *QUICDialerQUICGo) dialEarlyContext(ctx context.Context, func (d *quicDialerQUICGo) dialEarlyContext(ctx context.Context,
pconn net.PacketConn, remoteAddr net.Addr, address string, pconn net.PacketConn, remoteAddr net.Addr, address string,
tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error) { tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error) {
if d.mockDialEarlyContext != nil { if d.mockDialEarlyContext != nil {
@ -102,7 +102,7 @@ func (d *QUICDialerQUICGo) dialEarlyContext(ctx context.Context,
// maybeApplyTLSDefaults ensures that we're using our certificate pool, if // maybeApplyTLSDefaults ensures that we're using our certificate pool, if
// needed, and that we use a suitable ALPN, if needed, for h3 and dq. // needed, and that we use a suitable ALPN, if needed, for h3 and dq.
func (d *QUICDialerQUICGo) maybeApplyTLSDefaults(config *tls.Config, port int) *tls.Config { func (d *quicDialerQUICGo) maybeApplyTLSDefaults(config *tls.Config, port int) *tls.Config {
config = config.Clone() config = config.Clone()
if config.RootCAs == nil { if config.RootCAs == nil {
config.RootCAs = defaultCertPool config.RootCAs = defaultCertPool
@ -136,9 +136,9 @@ func (sess *quicSessionOwnsConn) CloseWithError(
return err return err
} }
// QUICDialerResolver is a dialer that uses the configured Resolver // quicDialerResolver is a dialer that uses the configured Resolver
// to resolve a domain name to IP addrs. // to resolve a domain name to IP addrs.
type QUICDialerResolver struct { type quicDialerResolver struct {
// Dialer is the underlying QUIC dialer. // Dialer is the underlying QUIC dialer.
Dialer QUICContextDialer Dialer QUICContextDialer
@ -146,14 +146,14 @@ type QUICDialerResolver struct {
Resolver Resolver Resolver Resolver
} }
var _ QUICContextDialer = &QUICDialerResolver{} var _ QUICContextDialer = &quicDialerResolver{}
// DialContext implements QUICContextDialer.DialContext. This function // DialContext implements QUICContextDialer.DialContext. This function
// will apply the following TLS defaults: // will apply the following TLS defaults:
// //
// 1. if tlsConfig.ServerName is empty, we will use the hostname // 1. if tlsConfig.ServerName is empty, we will use the hostname
// contained inside of the `address` endpoint. // contained inside of the `address` endpoint.
func (d *QUICDialerResolver) DialContext( func (d *quicDialerResolver) DialContext(
ctx context.Context, network, address string, ctx context.Context, network, address string,
tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error) { tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error) {
onlyhost, onlyport, err := net.SplitHostPort(address) onlyhost, onlyport, err := net.SplitHostPort(address)
@ -183,7 +183,7 @@ func (d *QUICDialerResolver) DialContext(
} }
// maybeApplyTLSDefaults sets the SNI if it's not already configured. // maybeApplyTLSDefaults sets the SNI if it's not already configured.
func (d *QUICDialerResolver) maybeApplyTLSDefaults(config *tls.Config, host string) *tls.Config { func (d *quicDialerResolver) maybeApplyTLSDefaults(config *tls.Config, host string) *tls.Config {
config = config.Clone() config = config.Clone()
if config.ServerName == "" { if config.ServerName == "" {
config.ServerName = host config.ServerName = host
@ -192,15 +192,15 @@ func (d *QUICDialerResolver) maybeApplyTLSDefaults(config *tls.Config, host stri
} }
// lookupHost performs a domain name resolution. // lookupHost performs a domain name resolution.
func (d *QUICDialerResolver) lookupHost(ctx context.Context, hostname string) ([]string, error) { func (d *quicDialerResolver) lookupHost(ctx context.Context, hostname string) ([]string, error) {
if net.ParseIP(hostname) != nil { if net.ParseIP(hostname) != nil {
return []string{hostname}, nil return []string{hostname}, nil
} }
return d.Resolver.LookupHost(ctx, hostname) return d.Resolver.LookupHost(ctx, hostname)
} }
// QUICDialerLogger is a dialer with logging. // quicDialerLogger is a dialer with logging.
type QUICDialerLogger struct { type quicDialerLogger struct {
// Dialer is the underlying QUIC dialer. // Dialer is the underlying QUIC dialer.
Dialer QUICContextDialer Dialer QUICContextDialer
@ -208,10 +208,10 @@ type QUICDialerLogger struct {
Logger Logger Logger Logger
} }
var _ QUICContextDialer = &QUICDialerLogger{} var _ QUICContextDialer = &quicDialerLogger{}
// DialContext implements QUICContextDialer.DialContext. // DialContext implements QUICContextDialer.DialContext.
func (d *QUICDialerLogger) DialContext( func (d *quicDialerLogger) DialContext(
ctx context.Context, network, address string, ctx context.Context, network, address string,
tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error) { tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error) {
d.Logger.Debugf("quic %s/%s...", address, network) d.Logger.Debugf("quic %s/%s...", address, network)

View File

@ -11,16 +11,16 @@ import (
"github.com/apex/log" "github.com/apex/log"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/lucas-clemente/quic-go" "github.com/lucas-clemente/quic-go"
"github.com/ooni/probe-cli/v3/internal/netxmocks" "github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
"github.com/ooni/probe-cli/v3/internal/quicx" "github.com/ooni/probe-cli/v3/internal/netxlite/quicx"
) )
func TestQUICDialerQUICGoCannotSplitHostPort(t *testing.T) { func TestQUICDialerQUICGoCannotSplitHostPort(t *testing.T) {
tlsConfig := &tls.Config{ tlsConfig := &tls.Config{
ServerName: "www.google.com", ServerName: "www.google.com",
} }
systemdialer := QUICDialerQUICGo{ systemdialer := quicDialerQUICGo{
QUICListener: &QUICListenerStdlib{}, QUICListener: &quicListenerStdlib{},
} }
ctx := context.Background() ctx := context.Background()
sess, err := systemdialer.DialContext( sess, err := systemdialer.DialContext(
@ -37,8 +37,8 @@ func TestQUICDialerQUICGoInvalidPort(t *testing.T) {
tlsConfig := &tls.Config{ tlsConfig := &tls.Config{
ServerName: "www.google.com", ServerName: "www.google.com",
} }
systemdialer := QUICDialerQUICGo{ systemdialer := quicDialerQUICGo{
QUICListener: &QUICListenerStdlib{}, QUICListener: &quicListenerStdlib{},
} }
ctx := context.Background() ctx := context.Background()
sess, err := systemdialer.DialContext( sess, err := systemdialer.DialContext(
@ -55,8 +55,8 @@ func TestQUICDialerQUICGoInvalidIP(t *testing.T) {
tlsConfig := &tls.Config{ tlsConfig := &tls.Config{
ServerName: "www.google.com", ServerName: "www.google.com",
} }
systemdialer := QUICDialerQUICGo{ systemdialer := quicDialerQUICGo{
QUICListener: &QUICListenerStdlib{}, QUICListener: &quicListenerStdlib{},
} }
ctx := context.Background() ctx := context.Background()
sess, err := systemdialer.DialContext( sess, err := systemdialer.DialContext(
@ -74,8 +74,8 @@ func TestQUICDialerQUICGoCannotListen(t *testing.T) {
tlsConfig := &tls.Config{ tlsConfig := &tls.Config{
ServerName: "www.google.com", ServerName: "www.google.com",
} }
systemdialer := QUICDialerQUICGo{ systemdialer := quicDialerQUICGo{
QUICListener: &netxmocks.QUICListener{ QUICListener: &mocks.QUICListener{
MockListen: func(addr *net.UDPAddr) (quicx.UDPLikeConn, error) { MockListen: func(addr *net.UDPAddr) (quicx.UDPLikeConn, error) {
return nil, expected return nil, expected
}, },
@ -96,8 +96,8 @@ func TestQUICDialerQUICGoCannotPerformHandshake(t *testing.T) {
tlsConfig := &tls.Config{ tlsConfig := &tls.Config{
ServerName: "dns.google", ServerName: "dns.google",
} }
systemdialer := QUICDialerQUICGo{ systemdialer := quicDialerQUICGo{
QUICListener: &QUICListenerStdlib{}, QUICListener: &quicListenerStdlib{},
} }
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
cancel() // fail immediately cancel() // fail immediately
@ -115,8 +115,8 @@ func TestQUICDialerQUICGoWorksAsIntended(t *testing.T) {
tlsConfig := &tls.Config{ tlsConfig := &tls.Config{
ServerName: "dns.google", ServerName: "dns.google",
} }
systemdialer := QUICDialerQUICGo{ systemdialer := quicDialerQUICGo{
QUICListener: &QUICListenerStdlib{}, QUICListener: &quicListenerStdlib{},
} }
ctx := context.Background() ctx := context.Background()
sess, err := systemdialer.DialContext( sess, err := systemdialer.DialContext(
@ -136,8 +136,8 @@ func TestQUICDialerQUICGoTLSDefaultsForWeb(t *testing.T) {
tlsConfig := &tls.Config{ tlsConfig := &tls.Config{
ServerName: "dns.google", ServerName: "dns.google",
} }
systemdialer := QUICDialerQUICGo{ systemdialer := quicDialerQUICGo{
QUICListener: &QUICListenerStdlib{}, QUICListener: &quicListenerStdlib{},
mockDialEarlyContext: func(ctx context.Context, pconn net.PacketConn, mockDialEarlyContext: func(ctx context.Context, pconn net.PacketConn,
remoteAddr net.Addr, host string, tlsConfig *tls.Config, remoteAddr net.Addr, host string, tlsConfig *tls.Config,
quicConfig *quic.Config) (quic.EarlySession, error) { quicConfig *quic.Config) (quic.EarlySession, error) {
@ -177,8 +177,8 @@ func TestQUICDialerQUICGoTLSDefaultsForDoQ(t *testing.T) {
tlsConfig := &tls.Config{ tlsConfig := &tls.Config{
ServerName: "dns.google", ServerName: "dns.google",
} }
systemdialer := QUICDialerQUICGo{ systemdialer := quicDialerQUICGo{
QUICListener: &QUICListenerStdlib{}, QUICListener: &quicListenerStdlib{},
mockDialEarlyContext: func(ctx context.Context, pconn net.PacketConn, mockDialEarlyContext: func(ctx context.Context, pconn net.PacketConn,
remoteAddr net.Addr, host string, tlsConfig *tls.Config, remoteAddr net.Addr, host string, tlsConfig *tls.Config,
quicConfig *quic.Config) (quic.EarlySession, error) { quicConfig *quic.Config) (quic.EarlySession, error) {
@ -214,9 +214,9 @@ func TestQUICDialerQUICGoTLSDefaultsForDoQ(t *testing.T) {
func TestQUICDialerResolverSuccess(t *testing.T) { func TestQUICDialerResolverSuccess(t *testing.T) {
tlsConfig := &tls.Config{} tlsConfig := &tls.Config{}
dialer := &QUICDialerResolver{ dialer := &quicDialerResolver{
Resolver: &net.Resolver{}, Dialer: &QUICDialerQUICGo{ Resolver: &net.Resolver{}, Dialer: &quicDialerQUICGo{
QUICListener: &QUICListenerStdlib{}, QUICListener: &quicListenerStdlib{},
}} }}
sess, err := dialer.DialContext( sess, err := dialer.DialContext(
context.Background(), "udp", "www.google.com:443", context.Background(), "udp", "www.google.com:443",
@ -232,8 +232,8 @@ func TestQUICDialerResolverSuccess(t *testing.T) {
func TestQUICDialerResolverNoPort(t *testing.T) { func TestQUICDialerResolverNoPort(t *testing.T) {
tlsConfig := &tls.Config{} tlsConfig := &tls.Config{}
dialer := &QUICDialerResolver{ dialer := &quicDialerResolver{
Resolver: new(net.Resolver), Dialer: &QUICDialerQUICGo{}} Resolver: new(net.Resolver), Dialer: &quicDialerQUICGo{}}
sess, err := dialer.DialContext( sess, err := dialer.DialContext(
context.Background(), "udp", "www.google.com", context.Background(), "udp", "www.google.com",
tlsConfig, &quic.Config{}) tlsConfig, &quic.Config{})
@ -246,7 +246,7 @@ func TestQUICDialerResolverNoPort(t *testing.T) {
} }
func TestQUICDialerResolverLookupHostAddress(t *testing.T) { func TestQUICDialerResolverLookupHostAddress(t *testing.T) {
dialer := &QUICDialerResolver{Resolver: &netxmocks.Resolver{ dialer := &quicDialerResolver{Resolver: &mocks.Resolver{
MockLookupHost: func(ctx context.Context, domain string) ([]string, error) { MockLookupHost: func(ctx context.Context, domain string) ([]string, error) {
// We should not arrive here and call this function but if we do then // We should not arrive here and call this function but if we do then
// there is going to be an error that fails this test. // there is going to be an error that fails this test.
@ -265,7 +265,7 @@ func TestQUICDialerResolverLookupHostAddress(t *testing.T) {
func TestQUICDialerResolverLookupHostFailure(t *testing.T) { func TestQUICDialerResolverLookupHostFailure(t *testing.T) {
tlsConfig := &tls.Config{} tlsConfig := &tls.Config{}
expected := errors.New("mocked error") expected := errors.New("mocked error")
dialer := &QUICDialerResolver{Resolver: &netxmocks.Resolver{ dialer := &quicDialerResolver{Resolver: &mocks.Resolver{
MockLookupHost: func(ctx context.Context, domain string) ([]string, error) { MockLookupHost: func(ctx context.Context, domain string) ([]string, error) {
return nil, expected return nil, expected
}, },
@ -285,9 +285,9 @@ func TestQUICDialerResolverInvalidPort(t *testing.T) {
// This test allows us to check for the case where every attempt // This test allows us to check for the case where every attempt
// to establish a connection leads to a failure // to establish a connection leads to a failure
tlsConf := &tls.Config{} tlsConf := &tls.Config{}
dialer := &QUICDialerResolver{ dialer := &quicDialerResolver{
Resolver: new(net.Resolver), Dialer: &QUICDialerQUICGo{ Resolver: new(net.Resolver), Dialer: &quicDialerQUICGo{
QUICListener: &QUICListenerStdlib{}, QUICListener: &quicListenerStdlib{},
}} }}
sess, err := dialer.DialContext( sess, err := dialer.DialContext(
context.Background(), "udp", "www.google.com:0", context.Background(), "udp", "www.google.com:0",
@ -308,8 +308,8 @@ func TestQUICDialerResolverApplyTLSDefaults(t *testing.T) {
expected := errors.New("mocked error") expected := errors.New("mocked error")
var gotTLSConfig *tls.Config var gotTLSConfig *tls.Config
tlsConfig := &tls.Config{} tlsConfig := &tls.Config{}
dialer := &QUICDialerResolver{ dialer := &quicDialerResolver{
Resolver: new(net.Resolver), Dialer: &netxmocks.QUICContextDialer{ Resolver: new(net.Resolver), Dialer: &mocks.QUICContextDialer{
MockDialContext: func(ctx context.Context, network, address string, MockDialContext: func(ctx context.Context, network, address string,
tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error) { tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error) {
gotTLSConfig = tlsConfig gotTLSConfig = tlsConfig
@ -334,12 +334,12 @@ func TestQUICDialerResolverApplyTLSDefaults(t *testing.T) {
} }
func TestQUICDialerLoggerSuccess(t *testing.T) { func TestQUICDialerLoggerSuccess(t *testing.T) {
d := &QUICDialerLogger{ d := &quicDialerLogger{
Dialer: &netxmocks.QUICContextDialer{ Dialer: &mocks.QUICContextDialer{
MockDialContext: func(ctx context.Context, network string, MockDialContext: func(ctx context.Context, network string,
address string, tlsConfig *tls.Config, address string, tlsConfig *tls.Config,
quicConfig *quic.Config) (quic.EarlySession, error) { quicConfig *quic.Config) (quic.EarlySession, error) {
return &netxmocks.QUICEarlySession{ return &mocks.QUICEarlySession{
MockCloseWithError: func( MockCloseWithError: func(
code quic.ApplicationErrorCode, reason string) error { code quic.ApplicationErrorCode, reason string) error {
return nil return nil
@ -363,8 +363,8 @@ func TestQUICDialerLoggerSuccess(t *testing.T) {
func TestQUICDialerLoggerFailure(t *testing.T) { func TestQUICDialerLoggerFailure(t *testing.T) {
expected := errors.New("mocked error") expected := errors.New("mocked error")
d := &QUICDialerLogger{ d := &quicDialerLogger{
Dialer: &netxmocks.QUICContextDialer{ Dialer: &mocks.QUICContextDialer{
MockDialContext: func(ctx context.Context, network string, MockDialContext: func(ctx context.Context, network string,
address string, tlsConfig *tls.Config, address string, tlsConfig *tls.Config,
quicConfig *quic.Config) (quic.EarlySession, error) { quicConfig *quic.Config) (quic.EarlySession, error) {

View File

@ -3,7 +3,7 @@
// This code introduces the UDPLikeConn, whose documentation explain // This code introduces the UDPLikeConn, whose documentation explain
// why we need to introduce this new type. We could not put this // why we need to introduce this new type. We could not put this
// code inside an existing package because it's used (as of 20 Aug 2021) // code inside an existing package because it's used (as of 20 Aug 2021)
// by the netxlite package as well as by the netxmocks package. // by the netxlite package as well as by the mocks package.
package quicx package quicx
import ( import (

View File

@ -14,39 +14,39 @@ type Resolver interface {
LookupHost(ctx context.Context, hostname string) (addrs []string, err error) LookupHost(ctx context.Context, hostname string) (addrs []string, err error)
} }
// ResolverSystem is the system resolver. // resolverSystem is the system resolver.
type ResolverSystem struct{} type resolverSystem struct{}
var _ Resolver = &ResolverSystem{} var _ Resolver = &resolverSystem{}
// LookupHost implements Resolver.LookupHost. // LookupHost implements Resolver.LookupHost.
func (r *ResolverSystem) LookupHost(ctx context.Context, hostname string) ([]string, error) { func (r *resolverSystem) LookupHost(ctx context.Context, hostname string) ([]string, error) {
return net.DefaultResolver.LookupHost(ctx, hostname) return net.DefaultResolver.LookupHost(ctx, hostname)
} }
// Network implements Resolver.Network. // Network implements Resolver.Network.
func (r *ResolverSystem) Network() string { func (r *resolverSystem) Network() string {
return "system" return "system"
} }
// Address implements Resolver.Address. // Address implements Resolver.Address.
func (r *ResolverSystem) Address() string { func (r *resolverSystem) Address() string {
return "" return ""
} }
// DefaultResolver is the resolver we use by default. // DefaultResolver is the resolver we use by default.
var DefaultResolver = &ResolverSystem{} var DefaultResolver = &resolverSystem{}
// ResolverLogger is a resolver that emits events // resolverLogger is a resolver that emits events
type ResolverLogger struct { type resolverLogger struct {
Resolver Resolver
Logger Logger Logger Logger
} }
var _ Resolver = &ResolverLogger{} var _ Resolver = &resolverLogger{}
// LookupHost returns the IP addresses of a host // LookupHost returns the IP addresses of a host
func (r *ResolverLogger) LookupHost(ctx context.Context, hostname string) ([]string, error) { func (r *resolverLogger) LookupHost(ctx context.Context, hostname string) ([]string, error) {
r.Logger.Debugf("resolve %s...", hostname) r.Logger.Debugf("resolve %s...", hostname)
start := time.Now() start := time.Now()
addrs, err := r.Resolver.LookupHost(ctx, hostname) addrs, err := r.Resolver.LookupHost(ctx, hostname)
@ -64,7 +64,7 @@ type resolverNetworker interface {
} }
// Network implements Resolver.Network. // Network implements Resolver.Network.
func (r *ResolverLogger) Network() string { func (r *resolverLogger) Network() string {
if rn, ok := r.Resolver.(resolverNetworker); ok { if rn, ok := r.Resolver.(resolverNetworker); ok {
return rn.Network() return rn.Network()
} }
@ -76,22 +76,22 @@ type resolverAddresser interface {
} }
// Address implements Resolver.Address. // Address implements Resolver.Address.
func (r *ResolverLogger) Address() string { func (r *resolverLogger) Address() string {
if ra, ok := r.Resolver.(resolverAddresser); ok { if ra, ok := r.Resolver.(resolverAddresser); ok {
return ra.Address() return ra.Address()
} }
return "" return ""
} }
// ResolverIDNA supports resolving Internationalized Domain Names. // resolverIDNA supports resolving Internationalized Domain Names.
// //
// See RFC3492 for more information. // See RFC3492 for more information.
type ResolverIDNA struct { type resolverIDNA struct {
Resolver Resolver
} }
// LookupHost implements Resolver.LookupHost. // LookupHost implements Resolver.LookupHost.
func (r *ResolverIDNA) LookupHost(ctx context.Context, hostname string) ([]string, error) { func (r *resolverIDNA) LookupHost(ctx context.Context, hostname string) ([]string, error) {
host, err := idna.ToASCII(hostname) host, err := idna.ToASCII(hostname)
if err != nil { if err != nil {
return nil, err return nil, err
@ -100,7 +100,7 @@ func (r *ResolverIDNA) LookupHost(ctx context.Context, hostname string) ([]strin
} }
// Network implements Resolver.Network. // Network implements Resolver.Network.
func (r *ResolverIDNA) Network() string { func (r *resolverIDNA) Network() string {
if rn, ok := r.Resolver.(resolverNetworker); ok { if rn, ok := r.Resolver.(resolverNetworker); ok {
return rn.Network() return rn.Network()
} }
@ -108,7 +108,7 @@ func (r *ResolverIDNA) Network() string {
} }
// Address implements Resolver.Address. // Address implements Resolver.Address.
func (r *ResolverIDNA) Address() string { func (r *resolverIDNA) Address() string {
if ra, ok := r.Resolver.(resolverAddresser); ok { if ra, ok := r.Resolver.(resolverAddresser); ok {
return ra.Address() return ra.Address()
} }

Some files were not shown because too many files have changed in this diff Show More