cleanup: remove unnecessary legacy interfaces (#656)
This diff addresses another point of https://github.com/ooni/probe/issues/1956: > - [ ] observe that we're still using a bunch of private interfaces for common interfaces such as the `Dialer`, so we can get rid of these private interfaces and always use the ones in `model`, which allows us to remove a bunch of legacy wrappers Additional cleanups may still be possible. The more I cleanup, the more I see there's extra legacy code we can dispose of (which seems good?).
This commit is contained in:
parent
1c057d322d
commit
566c6b246a
76 changed files with 326 additions and 734 deletions
|
|
@ -5,8 +5,8 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ type CtrlDNSResult = webconnectivity.ControlDNSResult
|
|||
type DNSConfig struct {
|
||||
Domain string
|
||||
Out chan CtrlDNSResult
|
||||
Resolver netx.Resolver
|
||||
Resolver model.Resolver
|
||||
Wg *sync.WaitGroup
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@ package webconnectivity
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/atomicx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
@ -49,7 +50,13 @@ func (c FakeResolver) Address() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
var _ netx.Resolver = FakeResolver{}
|
||||
func (c FakeResolver) CloseIdleConnections() {}
|
||||
|
||||
func (c FakeResolver) LookupHTTPS(ctx context.Context, domain string) (*model.HTTPSSvc, error) {
|
||||
return nil, errors.New("not implemented")
|
||||
}
|
||||
|
||||
var _ model.Resolver = FakeResolver{}
|
||||
|
||||
type FakeTransport struct {
|
||||
Err error
|
||||
|
|
@ -75,7 +82,7 @@ func (txp FakeTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||
|
||||
func (txp FakeTransport) CloseIdleConnections() {}
|
||||
|
||||
var _ netx.HTTPRoundTripper = FakeTransport{}
|
||||
var _ model.HTTPTransport = FakeTransport{}
|
||||
|
||||
type FakeBody struct {
|
||||
Data []byte
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
type (
|
||||
|
|
@ -22,9 +22,9 @@ type (
|
|||
// MeasureConfig contains configuration for Measure.
|
||||
type MeasureConfig struct {
|
||||
Client *http.Client
|
||||
Dialer netx.Dialer
|
||||
Dialer model.Dialer
|
||||
MaxAcceptableBody int64
|
||||
Resolver netx.Resolver
|
||||
Resolver model.Resolver
|
||||
}
|
||||
|
||||
// Measure performs the measurement described by the request and
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ type TCPResultPair struct {
|
|||
|
||||
// TCPConfig configures the TCP connect check.
|
||||
type TCPConfig struct {
|
||||
Dialer netx.Dialer
|
||||
Dialer model.Dialer
|
||||
Endpoint string
|
||||
Out chan TCPResultPair
|
||||
Wg *sync.WaitGroup
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
"github.com/ooni/probe-cli/v3/internal/version"
|
||||
|
|
@ -15,9 +15,9 @@ import (
|
|||
// Handler implements the Web Connectivity test helper HTTP API.
|
||||
type Handler struct {
|
||||
Client *http.Client
|
||||
Dialer netx.Dialer
|
||||
Dialer model.Dialer
|
||||
MaxAcceptableBody int64
|
||||
Resolver netx.Resolver
|
||||
Resolver model.Resolver
|
||||
}
|
||||
|
||||
func (h Handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
|
|
@ -52,7 +51,7 @@ const requestWithoutDomainName = `{
|
|||
func TestWorkingAsIntended(t *testing.T) {
|
||||
handler := Handler{
|
||||
Client: http.DefaultClient,
|
||||
Dialer: new(net.Dialer),
|
||||
Dialer: netxlite.DefaultDialer,
|
||||
MaxAcceptableBody: 1 << 24,
|
||||
Resolver: &netxlite.ResolverSystem{},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue