refactor: merge dnsx and errorsx into netxlite (#517)
When preparing a tutorial for netxlite, I figured it is easier to tell people "hey, this is the package you should use for all low-level networking stuff" rather than introducing people to a set of packages working together where some piece of functionality is here and some other piece is there. Part of https://github.com/ooni/probe/issues/1591
This commit is contained in:
@@ -18,8 +18,7 @@ import (
|
||||
"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/humanize"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/iox"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -87,7 +86,7 @@ func (r runner) NewHTTPRequest(meth, url string, body io.Reader) (*http.Request,
|
||||
}
|
||||
|
||||
func (r runner) ReadAllContext(ctx context.Context, reader io.Reader) ([]byte, error) {
|
||||
return iox.ReadAllContext(ctx, reader)
|
||||
return netxlite.ReadAllContext(ctx, reader)
|
||||
}
|
||||
|
||||
func (r runner) Scheme() string {
|
||||
@@ -172,7 +171,7 @@ func (r runner) measure(
|
||||
// of the latest connect time. We should have one sample in most
|
||||
// cases, because the connection should be persistent.
|
||||
for _, ev := range r.saver.Read() {
|
||||
if ev.Name == errorsx.ConnectOperation {
|
||||
if ev.Name == netxlite.ConnectOperation {
|
||||
connectTime = ev.Duration.Seconds()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
func TestRunnerLoopLocateFailure(t *testing.T) {
|
||||
@@ -108,7 +108,7 @@ func TestRunnerLoopMeasureFailure(t *testing.T) {
|
||||
func TestRunnerLoopCollectFailure(t *testing.T) {
|
||||
expected := errors.New("mocked error")
|
||||
saver := new(trace.Saver)
|
||||
saver.Write(trace.Event{Name: errorsx.ConnectOperation, Duration: 150 * time.Millisecond})
|
||||
saver.Write(trace.Event{Name: netxlite.ConnectOperation, Duration: 150 * time.Millisecond})
|
||||
r := runner{
|
||||
callbacks: model.NewPrinterCallbacks(log.Log),
|
||||
httpClient: &http.Client{
|
||||
@@ -152,7 +152,7 @@ func TestRunnerLoopCollectFailure(t *testing.T) {
|
||||
|
||||
func TestRunnerLoopSuccess(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver.Write(trace.Event{Name: errorsx.ConnectOperation, Duration: 150 * time.Millisecond})
|
||||
saver.Write(trace.Event{Name: netxlite.ConnectOperation, Duration: 150 * time.Millisecond})
|
||||
r := runner{
|
||||
callbacks: model.NewPrinterCallbacks(log.Log),
|
||||
httpClient: &http.Client{
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -111,7 +111,7 @@ func (tk *TestKeys) ComputeEndpointStatus(v urlgetter.MultiOutput, dns, tcp **bo
|
||||
// start where all is unknown
|
||||
*dns, *tcp = nil, nil
|
||||
// process DNS first
|
||||
if v.TestKeys.FailedOperation != nil && *v.TestKeys.FailedOperation == errorsx.ResolveOperation {
|
||||
if v.TestKeys.FailedOperation != nil && *v.TestKeys.FailedOperation == netxlite.ResolveOperation {
|
||||
tk.FacebookDNSBlocking = &trueValue
|
||||
*dns = &falseValue
|
||||
return // we know that the DNS has failed
|
||||
@@ -127,7 +127,7 @@ func (tk *TestKeys) ComputeEndpointStatus(v urlgetter.MultiOutput, dns, tcp **bo
|
||||
}
|
||||
*dns = &trueValue
|
||||
// now process connect
|
||||
if v.TestKeys.FailedOperation != nil && *v.TestKeys.FailedOperation == errorsx.ConnectOperation {
|
||||
if v.TestKeys.FailedOperation != nil && *v.TestKeys.FailedOperation == netxlite.ConnectOperation {
|
||||
tk.FacebookTCPBlocking = &trueValue
|
||||
*tcp = &falseValue
|
||||
return // because connect failed
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
func TestNewExperimentMeasurer(t *testing.T) {
|
||||
@@ -162,7 +162,7 @@ func TestWithCancelledContext(t *testing.T) {
|
||||
|
||||
func TestComputeEndpointStatsTCPBlocking(t *testing.T) {
|
||||
failure := io.EOF.Error()
|
||||
operation := errorsx.ConnectOperation
|
||||
operation := netxlite.ConnectOperation
|
||||
tk := fbmessenger.TestKeys{}
|
||||
tk.Update(urlgetter.MultiOutput{
|
||||
Input: urlgetter.MultiInput{Target: fbmessenger.ServiceEdge},
|
||||
@@ -192,7 +192,7 @@ func TestComputeEndpointStatsTCPBlocking(t *testing.T) {
|
||||
|
||||
func TestComputeEndpointStatsDNSIsLying(t *testing.T) {
|
||||
failure := io.EOF.Error()
|
||||
operation := errorsx.ConnectOperation
|
||||
operation := netxlite.ConnectOperation
|
||||
tk := fbmessenger.TestKeys{}
|
||||
tk.Update(urlgetter.MultiOutput{
|
||||
Input: urlgetter.MultiInput{Target: fbmessenger.ServiceEdge},
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/iox"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
type FakeDialer struct {
|
||||
@@ -31,7 +31,7 @@ func (txp FakeTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
return txp.Func(req)
|
||||
}
|
||||
if req.Body != nil {
|
||||
iox.ReadAllContext(req.Context(), req.Body)
|
||||
netxlite.ReadAllContext(req.Context(), req.Body)
|
||||
req.Body.Close()
|
||||
}
|
||||
if txp.Err != nil {
|
||||
|
||||
@@ -20,8 +20,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"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/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/iox"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/randx"
|
||||
)
|
||||
|
||||
@@ -165,7 +164,7 @@ func (m Measurer) Run(
|
||||
// parse response body
|
||||
var jsonHeaders JSONHeaders
|
||||
if err := json.Unmarshal(data, &jsonHeaders); err != nil {
|
||||
failure := errorsx.FailureJSONParseError
|
||||
failure := netxlite.FailureJSONParseError
|
||||
tk.Failure = &failure
|
||||
tk.Tampering.Total = true
|
||||
return nil // measurement did not fail, we measured tampering
|
||||
@@ -182,7 +181,7 @@ func Transact(txp Transport, req *http.Request,
|
||||
// make sure that we return a wrapped error here
|
||||
resp, data, err := transact(txp, req, callbacks)
|
||||
err = errorsxlegacy.SafeErrWrapperBuilder{
|
||||
Error: err, Operation: errorsx.TopLevelOperation}.MaybeBuild()
|
||||
Error: err, Operation: netxlite.TopLevelOperation}.MaybeBuild()
|
||||
return resp, data, err
|
||||
}
|
||||
|
||||
@@ -199,7 +198,7 @@ func transact(txp Transport, req *http.Request,
|
||||
return nil, nil, urlgetter.ErrHTTPRequestFailed
|
||||
}
|
||||
callbacks.OnProgress(0.75, "reading response body...")
|
||||
data, err := iox.ReadAllContext(req.Context(), resp.Body)
|
||||
data, err := netxlite.ReadAllContext(req.Context(), resp.Body)
|
||||
callbacks.OnProgress(1.00, fmt.Sprintf("got reseponse body... %+v", err))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
func TestNewExperimentMeasurer(t *testing.T) {
|
||||
@@ -161,14 +161,14 @@ func TestCancelledContext(t *testing.T) {
|
||||
if tk.Agent != "agent" {
|
||||
t.Fatal("invalid Agent")
|
||||
}
|
||||
if *tk.Failure != errorsx.FailureInterrupted {
|
||||
if *tk.Failure != netxlite.FailureInterrupted {
|
||||
t.Fatal("invalid Failure")
|
||||
}
|
||||
if len(tk.Requests) != 1 {
|
||||
t.Fatal("invalid Requests")
|
||||
}
|
||||
request := tk.Requests[0]
|
||||
if *request.Failure != errorsx.FailureInterrupted {
|
||||
if *request.Failure != netxlite.FailureInterrupted {
|
||||
t.Fatal("invalid Requests[0].Failure")
|
||||
}
|
||||
if request.Request.Body.Value != "" {
|
||||
@@ -480,7 +480,7 @@ func TestInvalidJSONBody(t *testing.T) {
|
||||
if tk.Agent != "agent" {
|
||||
t.Fatal("invalid Agent")
|
||||
}
|
||||
if *tk.Failure != errorsx.FailureJSONParseError {
|
||||
if *tk.Failure != netxlite.FailureJSONParseError {
|
||||
t.Fatal("invalid Failure")
|
||||
}
|
||||
if len(tk.Requests) != 1 {
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"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/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/randx"
|
||||
)
|
||||
|
||||
@@ -293,7 +293,7 @@ func RunMethod(ctx context.Context, config RunMethodConfig) {
|
||||
count, err := conn.Read(data)
|
||||
if err != nil {
|
||||
// We expect this method to terminate w/ timeout
|
||||
if err.Error() == errorsx.FailureGenericTimeoutError {
|
||||
if err.Error() == netxlite.FailureGenericTimeoutError {
|
||||
err = nil
|
||||
}
|
||||
result.Err = err
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"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/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
func TestNewExperimentMeasurer(t *testing.T) {
|
||||
@@ -97,7 +97,7 @@ func TestCancelledContext(t *testing.T) {
|
||||
t.Fatal("unexpected FailureList length")
|
||||
}
|
||||
for _, failure := range tk.FailureList {
|
||||
if *failure != errorsx.FailureInterrupted {
|
||||
if *failure != netxlite.FailureInterrupted {
|
||||
t.Fatal("unexpected failure")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/iox"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
type downloadManager struct {
|
||||
@@ -46,7 +46,7 @@ func (mgr downloadManager) run(ctx context.Context) error {
|
||||
// we used to return `nil` on context errors, this function is
|
||||
// here to keep the previous behavior by filtering the error
|
||||
// returned when reading messages, given that now reading messages
|
||||
// can fail midway because we use iox.ReadAllContext.
|
||||
// can fail midway because we use netxlite.ReadAllContext.
|
||||
func (mgr downloadManager) reduceErr(err error) error {
|
||||
if errors.Is(err, context.Canceled) {
|
||||
return nil
|
||||
@@ -72,7 +72,7 @@ func (mgr downloadManager) doRun(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
if kind == websocket.TextMessage {
|
||||
data, err := iox.ReadAllContext(ctx, reader)
|
||||
data, err := netxlite.ReadAllContext(ctx, reader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -82,7 +82,7 @@ func (mgr downloadManager) doRun(ctx context.Context) error {
|
||||
}
|
||||
continue
|
||||
}
|
||||
n, err := iox.CopyContext(ctx, io.Discard, reader)
|
||||
n, err := netxlite.CopyContext(ctx, io.Discard, reader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -270,11 +270,11 @@ func TestUpdateWithMixedResults(t *testing.T) {
|
||||
},
|
||||
TestKeys: urlgetter.TestKeys{
|
||||
FailedOperation: (func() *string {
|
||||
s := errorsx.HTTPRoundTripOperation
|
||||
s := netxlite.HTTPRoundTripOperation
|
||||
return &s
|
||||
})(),
|
||||
Failure: (func() *string {
|
||||
s := errorsx.FailureEOFError
|
||||
s := netxlite.FailureEOFError
|
||||
return &s
|
||||
})(),
|
||||
},
|
||||
@@ -291,7 +291,7 @@ func TestUpdateWithMixedResults(t *testing.T) {
|
||||
if tk.APIStatus != "blocked" {
|
||||
t.Fatal("ApiStatus should be blocked")
|
||||
}
|
||||
if *tk.APIFailure != errorsx.FailureEOFError {
|
||||
if *tk.APIFailure != netxlite.FailureEOFError {
|
||||
t.Fatal("invalid ApiFailure")
|
||||
}
|
||||
if tk.FailingGateways != nil {
|
||||
@@ -730,7 +730,7 @@ func generateMockGetter(requestResponse map[string]string, responseStatus map[st
|
||||
responseBody = ""
|
||||
eofError := io.EOF.Error()
|
||||
failure = &eofError
|
||||
connectOperation := errorsx.ConnectOperation
|
||||
connectOperation := netxlite.ConnectOperation
|
||||
failedOperation = &connectOperation
|
||||
responseStatus = 0
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
func TestNewExperimentMeasurer(t *testing.T) {
|
||||
@@ -85,7 +85,7 @@ func TestUpdate(t *testing.T) {
|
||||
},
|
||||
TestKeys: urlgetter.TestKeys{
|
||||
Failure: (func() *string {
|
||||
s := errorsx.FailureEOFError
|
||||
s := netxlite.FailureEOFError
|
||||
return &s
|
||||
})(),
|
||||
},
|
||||
@@ -93,7 +93,7 @@ func TestUpdate(t *testing.T) {
|
||||
if tk.SignalBackendStatus != "blocked" {
|
||||
t.Fatal("SignalBackendStatus should be blocked")
|
||||
}
|
||||
if *tk.SignalBackendFailure != errorsx.FailureEOFError {
|
||||
if *tk.SignalBackendFailure != netxlite.FailureEOFError {
|
||||
t.Fatal("invalid SignalBackendError")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -64,24 +64,24 @@ func (tk *TestKeys) classify() string {
|
||||
return classSuccessGotServerHello
|
||||
}
|
||||
switch *tk.Target.Failure {
|
||||
case errorsx.FailureConnectionRefused:
|
||||
case netxlite.FailureConnectionRefused:
|
||||
return classAnomalyTestHelperUnreachable
|
||||
case errorsx.FailureConnectionReset:
|
||||
case netxlite.FailureConnectionReset:
|
||||
return classInterferenceReset
|
||||
case errorsx.FailureDNSNXDOMAINError:
|
||||
case netxlite.FailureDNSNXDOMAINError:
|
||||
return classAnomalyTestHelperUnreachable
|
||||
case errorsx.FailureEOFError:
|
||||
case netxlite.FailureEOFError:
|
||||
return classInterferenceClosed
|
||||
case errorsx.FailureGenericTimeoutError:
|
||||
case netxlite.FailureGenericTimeoutError:
|
||||
if tk.Control.Failure != nil {
|
||||
return classAnomalyTestHelperUnreachable
|
||||
}
|
||||
return classAnomalyTimeout
|
||||
case errorsx.FailureSSLInvalidCertificate:
|
||||
case netxlite.FailureSSLInvalidCertificate:
|
||||
return classInterferenceInvalidCertificate
|
||||
case errorsx.FailureSSLInvalidHostname:
|
||||
case netxlite.FailureSSLInvalidHostname:
|
||||
return classSuccessGotServerHello
|
||||
case errorsx.FailureSSLUnknownAuthority:
|
||||
case netxlite.FailureSSLUnknownAuthority:
|
||||
return classInterferenceUnknownAuthority
|
||||
}
|
||||
return classAnomalyUnexpectedFailure
|
||||
@@ -117,8 +117,8 @@ func (m *Measurer) measureone(
|
||||
select {
|
||||
case <-time.After(sleeptime):
|
||||
case <-ctx.Done():
|
||||
s := errorsx.FailureInterrupted
|
||||
failedop := errorsx.TopLevelOperation
|
||||
s := netxlite.FailureInterrupted
|
||||
failedop := netxlite.TopLevelOperation
|
||||
return Subresult{
|
||||
TestKeys: urlgetter.TestKeys{
|
||||
FailedOperation: &failedop,
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -29,64 +29,64 @@ func TestTestKeysClassify(t *testing.T) {
|
||||
})
|
||||
t.Run("with tk.Target.Failure == connection_refused", func(t *testing.T) {
|
||||
tk := new(TestKeys)
|
||||
tk.Target.Failure = asStringPtr(errorsx.FailureConnectionRefused)
|
||||
tk.Target.Failure = asStringPtr(netxlite.FailureConnectionRefused)
|
||||
if tk.classify() != classAnomalyTestHelperUnreachable {
|
||||
t.Fatal("unexpected result")
|
||||
}
|
||||
})
|
||||
t.Run("with tk.Target.Failure == dns_nxdomain_error", func(t *testing.T) {
|
||||
tk := new(TestKeys)
|
||||
tk.Target.Failure = asStringPtr(errorsx.FailureDNSNXDOMAINError)
|
||||
tk.Target.Failure = asStringPtr(netxlite.FailureDNSNXDOMAINError)
|
||||
if tk.classify() != classAnomalyTestHelperUnreachable {
|
||||
t.Fatal("unexpected result")
|
||||
}
|
||||
})
|
||||
t.Run("with tk.Target.Failure == connection_reset", func(t *testing.T) {
|
||||
tk := new(TestKeys)
|
||||
tk.Target.Failure = asStringPtr(errorsx.FailureConnectionReset)
|
||||
tk.Target.Failure = asStringPtr(netxlite.FailureConnectionReset)
|
||||
if tk.classify() != classInterferenceReset {
|
||||
t.Fatal("unexpected result")
|
||||
}
|
||||
})
|
||||
t.Run("with tk.Target.Failure == eof_error", func(t *testing.T) {
|
||||
tk := new(TestKeys)
|
||||
tk.Target.Failure = asStringPtr(errorsx.FailureEOFError)
|
||||
tk.Target.Failure = asStringPtr(netxlite.FailureEOFError)
|
||||
if tk.classify() != classInterferenceClosed {
|
||||
t.Fatal("unexpected result")
|
||||
}
|
||||
})
|
||||
t.Run("with tk.Target.Failure == ssl_invalid_hostname", func(t *testing.T) {
|
||||
tk := new(TestKeys)
|
||||
tk.Target.Failure = asStringPtr(errorsx.FailureSSLInvalidHostname)
|
||||
tk.Target.Failure = asStringPtr(netxlite.FailureSSLInvalidHostname)
|
||||
if tk.classify() != classSuccessGotServerHello {
|
||||
t.Fatal("unexpected result")
|
||||
}
|
||||
})
|
||||
t.Run("with tk.Target.Failure == ssl_unknown_authority", func(t *testing.T) {
|
||||
tk := new(TestKeys)
|
||||
tk.Target.Failure = asStringPtr(errorsx.FailureSSLUnknownAuthority)
|
||||
tk.Target.Failure = asStringPtr(netxlite.FailureSSLUnknownAuthority)
|
||||
if tk.classify() != classInterferenceUnknownAuthority {
|
||||
t.Fatal("unexpected result")
|
||||
}
|
||||
})
|
||||
t.Run("with tk.Target.Failure == ssl_invalid_certificate", func(t *testing.T) {
|
||||
tk := new(TestKeys)
|
||||
tk.Target.Failure = asStringPtr(errorsx.FailureSSLInvalidCertificate)
|
||||
tk.Target.Failure = asStringPtr(netxlite.FailureSSLInvalidCertificate)
|
||||
if tk.classify() != classInterferenceInvalidCertificate {
|
||||
t.Fatal("unexpected result")
|
||||
}
|
||||
})
|
||||
t.Run("with tk.Target.Failure == generic_timeout_error #1", func(t *testing.T) {
|
||||
tk := new(TestKeys)
|
||||
tk.Target.Failure = asStringPtr(errorsx.FailureGenericTimeoutError)
|
||||
tk.Target.Failure = asStringPtr(netxlite.FailureGenericTimeoutError)
|
||||
if tk.classify() != classAnomalyTimeout {
|
||||
t.Fatal("unexpected result")
|
||||
}
|
||||
})
|
||||
t.Run("with tk.Target.Failure == generic_timeout_error #2", func(t *testing.T) {
|
||||
tk := new(TestKeys)
|
||||
tk.Target.Failure = asStringPtr(errorsx.FailureGenericTimeoutError)
|
||||
tk.Control.Failure = asStringPtr(errorsx.FailureGenericTimeoutError)
|
||||
tk.Target.Failure = asStringPtr(netxlite.FailureGenericTimeoutError)
|
||||
tk.Control.Failure = asStringPtr(netxlite.FailureGenericTimeoutError)
|
||||
if tk.classify() != classAnomalyTestHelperUnreachable {
|
||||
t.Fatal("unexpected result")
|
||||
}
|
||||
@@ -191,10 +191,10 @@ func TestMeasureoneCancelledContext(t *testing.T) {
|
||||
if result.DNSCache != nil {
|
||||
t.Fatal("not the expected DNSCache")
|
||||
}
|
||||
if result.FailedOperation == nil || *result.FailedOperation != errorsx.TopLevelOperation {
|
||||
if result.FailedOperation == nil || *result.FailedOperation != netxlite.TopLevelOperation {
|
||||
t.Fatal("not the expected FailedOperation")
|
||||
}
|
||||
if result.Failure == nil || *result.Failure != errorsx.FailureInterrupted {
|
||||
if result.Failure == nil || *result.Failure != netxlite.FailureInterrupted {
|
||||
t.Fatal("not the expected failure")
|
||||
}
|
||||
if result.NetworkEvents != nil {
|
||||
@@ -295,10 +295,10 @@ func TestMeasureoneSuccess(t *testing.T) {
|
||||
if result.DNSCache != nil {
|
||||
t.Fatal("not the expected DNSCache")
|
||||
}
|
||||
if result.FailedOperation == nil || *result.FailedOperation != errorsx.TLSHandshakeOperation {
|
||||
if result.FailedOperation == nil || *result.FailedOperation != netxlite.TLSHandshakeOperation {
|
||||
t.Fatal("not the expected FailedOperation")
|
||||
}
|
||||
if result.Failure == nil || *result.Failure != errorsx.FailureSSLInvalidHostname {
|
||||
if result.Failure == nil || *result.Failure != netxlite.FailureSSLInvalidHostname {
|
||||
t.Fatal("unexpected failure")
|
||||
}
|
||||
if len(result.NetworkEvents) < 1 {
|
||||
@@ -348,7 +348,7 @@ func TestMeasureonewithcacheWorks(t *testing.T) {
|
||||
if result.Cached != expected {
|
||||
t.Fatal("unexpected cached")
|
||||
}
|
||||
if *result.Failure != errorsx.FailureSSLInvalidHostname {
|
||||
if *result.Failure != netxlite.FailureSSLInvalidHostname {
|
||||
t.Fatal("unexpected failure")
|
||||
}
|
||||
if result.SNI != "kernel.org" {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/stunreachability"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/pion/stun"
|
||||
)
|
||||
|
||||
@@ -213,7 +213,7 @@ func TestReadFailure(t *testing.T) {
|
||||
t.Fatal("not the error we expected")
|
||||
}
|
||||
tk := measurement.TestKeys.(*stunreachability.TestKeys)
|
||||
if *tk.Failure != errorsx.FailureGenericTimeoutError {
|
||||
if *tk.Failure != netxlite.FailureGenericTimeoutError {
|
||||
t.Fatal("expected different failure here")
|
||||
}
|
||||
if tk.Endpoint != "stun.l.google.com:19302" {
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -56,7 +56,7 @@ func (tk *TestKeys) Update(v urlgetter.MultiOutput) {
|
||||
tk.TelegramTCPBlocking = false
|
||||
return // found successful access point connection
|
||||
}
|
||||
if v.TestKeys.FailedOperation == nil || *v.TestKeys.FailedOperation != errorsx.ConnectOperation {
|
||||
if v.TestKeys.FailedOperation == nil || *v.TestKeys.FailedOperation != netxlite.ConnectOperation {
|
||||
tk.TelegramTCPBlocking = false
|
||||
}
|
||||
return
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
func TestNewExperimentMeasurer(t *testing.T) {
|
||||
@@ -94,7 +94,7 @@ func TestUpdateWithNoAccessPointsBlocking(t *testing.T) {
|
||||
},
|
||||
TestKeys: urlgetter.TestKeys{
|
||||
Failure: (func() *string {
|
||||
s := errorsx.FailureEOFError
|
||||
s := netxlite.FailureEOFError
|
||||
return &s
|
||||
})(),
|
||||
},
|
||||
@@ -125,7 +125,7 @@ func TestUpdateWithNilFailedOperation(t *testing.T) {
|
||||
},
|
||||
TestKeys: urlgetter.TestKeys{
|
||||
Failure: (func() *string {
|
||||
s := errorsx.FailureEOFError
|
||||
s := netxlite.FailureEOFError
|
||||
return &s
|
||||
})(),
|
||||
},
|
||||
@@ -137,7 +137,7 @@ func TestUpdateWithNilFailedOperation(t *testing.T) {
|
||||
},
|
||||
TestKeys: urlgetter.TestKeys{
|
||||
Failure: (func() *string {
|
||||
s := errorsx.FailureEOFError
|
||||
s := netxlite.FailureEOFError
|
||||
return &s
|
||||
})(),
|
||||
},
|
||||
@@ -159,11 +159,11 @@ func TestUpdateWithNonConnectFailedOperation(t *testing.T) {
|
||||
},
|
||||
TestKeys: urlgetter.TestKeys{
|
||||
FailedOperation: (func() *string {
|
||||
s := errorsx.ConnectOperation
|
||||
s := netxlite.ConnectOperation
|
||||
return &s
|
||||
})(),
|
||||
Failure: (func() *string {
|
||||
s := errorsx.FailureEOFError
|
||||
s := netxlite.FailureEOFError
|
||||
return &s
|
||||
})(),
|
||||
},
|
||||
@@ -175,11 +175,11 @@ func TestUpdateWithNonConnectFailedOperation(t *testing.T) {
|
||||
},
|
||||
TestKeys: urlgetter.TestKeys{
|
||||
FailedOperation: (func() *string {
|
||||
s := errorsx.HTTPRoundTripOperation
|
||||
s := netxlite.HTTPRoundTripOperation
|
||||
return &s
|
||||
})(),
|
||||
Failure: (func() *string {
|
||||
s := errorsx.FailureEOFError
|
||||
s := netxlite.FailureEOFError
|
||||
return &s
|
||||
})(),
|
||||
},
|
||||
@@ -201,11 +201,11 @@ func TestUpdateWithAllConnectsFailed(t *testing.T) {
|
||||
},
|
||||
TestKeys: urlgetter.TestKeys{
|
||||
FailedOperation: (func() *string {
|
||||
s := errorsx.ConnectOperation
|
||||
s := netxlite.ConnectOperation
|
||||
return &s
|
||||
})(),
|
||||
Failure: (func() *string {
|
||||
s := errorsx.FailureEOFError
|
||||
s := netxlite.FailureEOFError
|
||||
return &s
|
||||
})(),
|
||||
},
|
||||
@@ -217,11 +217,11 @@ func TestUpdateWithAllConnectsFailed(t *testing.T) {
|
||||
},
|
||||
TestKeys: urlgetter.TestKeys{
|
||||
FailedOperation: (func() *string {
|
||||
s := errorsx.ConnectOperation
|
||||
s := netxlite.ConnectOperation
|
||||
return &s
|
||||
})(),
|
||||
Failure: (func() *string {
|
||||
s := errorsx.FailureEOFError
|
||||
s := netxlite.FailureEOFError
|
||||
return &s
|
||||
})(),
|
||||
},
|
||||
@@ -243,11 +243,11 @@ func TestUpdateWebWithMixedResults(t *testing.T) {
|
||||
},
|
||||
TestKeys: urlgetter.TestKeys{
|
||||
FailedOperation: (func() *string {
|
||||
s := errorsx.HTTPRoundTripOperation
|
||||
s := netxlite.HTTPRoundTripOperation
|
||||
return &s
|
||||
})(),
|
||||
Failure: (func() *string {
|
||||
s := errorsx.FailureEOFError
|
||||
s := netxlite.FailureEOFError
|
||||
return &s
|
||||
})(),
|
||||
},
|
||||
@@ -265,7 +265,7 @@ func TestUpdateWebWithMixedResults(t *testing.T) {
|
||||
if tk.TelegramWebStatus != "blocked" {
|
||||
t.Fatal("TelegramWebStatus should be blocked")
|
||||
}
|
||||
if *tk.TelegramWebFailure != errorsx.FailureEOFError {
|
||||
if *tk.TelegramWebFailure != netxlite.FailureEOFError {
|
||||
t.Fatal("invalid TelegramWebFailure")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/oonidatamodel"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/oonitemplates"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
"github.com/ooni/probe-cli/v3/internal/scrubber"
|
||||
)
|
||||
@@ -77,7 +77,7 @@ func (tr *TargetResults) fillSummary() {
|
||||
if len(tr.TCPConnect) < 1 {
|
||||
return
|
||||
}
|
||||
tr.Summary[errorsx.ConnectOperation] = Summary{
|
||||
tr.Summary[netxlite.ConnectOperation] = Summary{
|
||||
Failure: tr.TCPConnect[0].Status.Failure,
|
||||
}
|
||||
switch tr.TargetProtocol {
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/oonitemplates"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/scrubber"
|
||||
)
|
||||
|
||||
@@ -446,7 +446,7 @@ func TestSummary(t *testing.T) {
|
||||
if len(tr.Summary) != 1 {
|
||||
t.Fatal("cannot find expected entry")
|
||||
}
|
||||
if *tr.Summary[errorsx.ConnectOperation].Failure != failure {
|
||||
if *tr.Summary[netxlite.ConnectOperation].Failure != failure {
|
||||
t.Fatal("invalid failure")
|
||||
}
|
||||
})
|
||||
@@ -465,7 +465,7 @@ func TestSummary(t *testing.T) {
|
||||
if len(tr.Summary) != 2 {
|
||||
t.Fatal("cannot find expected entry")
|
||||
}
|
||||
if tr.Summary[errorsx.ConnectOperation].Failure != nil {
|
||||
if tr.Summary[netxlite.ConnectOperation].Failure != nil {
|
||||
t.Fatal("invalid failure")
|
||||
}
|
||||
if *tr.Summary["handshake"].Failure != failure {
|
||||
@@ -489,7 +489,7 @@ func TestSummary(t *testing.T) {
|
||||
if len(tr.Summary) < 1 {
|
||||
t.Fatal("cannot find expected entry")
|
||||
}
|
||||
if tr.Summary[errorsx.ConnectOperation].Failure != nil {
|
||||
if tr.Summary[netxlite.ConnectOperation].Failure != nil {
|
||||
t.Fatal("invalid failure")
|
||||
}
|
||||
if handshake == nil {
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/tunnel"
|
||||
)
|
||||
|
||||
@@ -57,7 +57,7 @@ func (g Getter) Get(ctx context.Context) (TestKeys, error) {
|
||||
// hitting our httptransport that does error wrapping.
|
||||
err = legacyerrorsx.SafeErrWrapperBuilder{
|
||||
Error: err,
|
||||
Operation: errorsx.TopLevelOperation,
|
||||
Operation: netxlite.TopLevelOperation,
|
||||
}.MaybeBuild()
|
||||
tk.FailedOperation = archival.NewFailedOperation(err)
|
||||
tk.Failure = archival.NewFailure(err)
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
func TestGetterWithVeryShortTimeout(t *testing.T) {
|
||||
@@ -31,7 +31,7 @@ func TestGetterWithVeryShortTimeout(t *testing.T) {
|
||||
if tk.BootstrapTime != 0 {
|
||||
t.Fatal("not the BootstrapTime we expected")
|
||||
}
|
||||
if tk.FailedOperation == nil || *tk.FailedOperation != errorsx.TopLevelOperation {
|
||||
if tk.FailedOperation == nil || *tk.FailedOperation != netxlite.TopLevelOperation {
|
||||
t.Fatal("not the FailedOperation we expected")
|
||||
}
|
||||
if tk.Failure == nil || *tk.Failure != "generic_timeout_error" {
|
||||
@@ -98,7 +98,7 @@ func TestGetterWithCancelledContextVanilla(t *testing.T) {
|
||||
if tk.BootstrapTime != 0 {
|
||||
t.Fatal("not the BootstrapTime we expected")
|
||||
}
|
||||
if tk.FailedOperation == nil || *tk.FailedOperation != errorsx.TopLevelOperation {
|
||||
if tk.FailedOperation == nil || *tk.FailedOperation != netxlite.TopLevelOperation {
|
||||
t.Fatal("not the FailedOperation we expected")
|
||||
}
|
||||
if tk.Failure == nil || !strings.HasSuffix(*tk.Failure, "interrupted") {
|
||||
@@ -166,7 +166,7 @@ func TestGetterWithCancelledContextAndMethod(t *testing.T) {
|
||||
if tk.BootstrapTime != 0 {
|
||||
t.Fatal("not the BootstrapTime we expected")
|
||||
}
|
||||
if tk.FailedOperation == nil || *tk.FailedOperation != errorsx.TopLevelOperation {
|
||||
if tk.FailedOperation == nil || *tk.FailedOperation != netxlite.TopLevelOperation {
|
||||
t.Fatal("not the FailedOperation we expected")
|
||||
}
|
||||
if tk.Failure == nil || !strings.HasSuffix(*tk.Failure, "interrupted") {
|
||||
@@ -236,7 +236,7 @@ func TestGetterWithCancelledContextNoFollowRedirects(t *testing.T) {
|
||||
if tk.BootstrapTime != 0 {
|
||||
t.Fatal("not the BootstrapTime we expected")
|
||||
}
|
||||
if tk.FailedOperation == nil || *tk.FailedOperation != errorsx.TopLevelOperation {
|
||||
if tk.FailedOperation == nil || *tk.FailedOperation != netxlite.TopLevelOperation {
|
||||
t.Fatal("not the FailedOperation we expected")
|
||||
}
|
||||
if tk.Failure == nil || !strings.HasSuffix(*tk.Failure, "interrupted") {
|
||||
@@ -306,7 +306,7 @@ func TestGetterWithCancelledContextCannotStartTunnel(t *testing.T) {
|
||||
if tk.BootstrapTime != 0 {
|
||||
t.Fatal("not the BootstrapTime we expected")
|
||||
}
|
||||
if tk.FailedOperation == nil || *tk.FailedOperation != errorsx.TopLevelOperation {
|
||||
if tk.FailedOperation == nil || *tk.FailedOperation != netxlite.TopLevelOperation {
|
||||
t.Fatal("not the FailedOperation we expected")
|
||||
}
|
||||
if tk.Failure == nil || *tk.Failure != "interrupted" {
|
||||
@@ -361,7 +361,7 @@ func TestGetterWithCancelledContextUnknownResolverURL(t *testing.T) {
|
||||
if tk.BootstrapTime != 0 {
|
||||
t.Fatal("not the BootstrapTime we expected")
|
||||
}
|
||||
if tk.FailedOperation == nil || *tk.FailedOperation != errorsx.TopLevelOperation {
|
||||
if tk.FailedOperation == nil || *tk.FailedOperation != netxlite.TopLevelOperation {
|
||||
t.Fatal("not the FailedOperation we expected")
|
||||
}
|
||||
if tk.Failure == nil || *tk.Failure != "unknown_failure: unsupported resolver scheme" {
|
||||
@@ -446,7 +446,7 @@ func TestGetterIntegrationHTTPS(t *testing.T) {
|
||||
resolveStart = true
|
||||
case "resolve_done":
|
||||
resolveDone = true
|
||||
case errorsx.ConnectOperation:
|
||||
case netxlite.ConnectOperation:
|
||||
connect = true
|
||||
case "tls_handshake_start":
|
||||
tlsHandshakeStart = true
|
||||
@@ -587,7 +587,7 @@ func TestGetterIntegrationTLSHandshake(t *testing.T) {
|
||||
resolveStart = true
|
||||
case "resolve_done":
|
||||
resolveDone = true
|
||||
case errorsx.ConnectOperation:
|
||||
case netxlite.ConnectOperation:
|
||||
connect = true
|
||||
case "tls_handshake_start":
|
||||
tlsHandshakeStart = true
|
||||
@@ -705,7 +705,7 @@ func TestGetterHTTPSWithTunnel(t *testing.T) {
|
||||
resolveStart = true
|
||||
case "resolve_done":
|
||||
resolveDone = true
|
||||
case errorsx.ConnectOperation:
|
||||
case netxlite.ConnectOperation:
|
||||
connect = true
|
||||
case "tls_handshake_start":
|
||||
tlsHandshakeStart = true
|
||||
|
||||
@@ -11,17 +11,16 @@ import (
|
||||
|
||||
"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/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/iox"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
)
|
||||
|
||||
const httpRequestFailed = "http_request_failed"
|
||||
|
||||
// ErrHTTPRequestFailed indicates that the HTTP request failed.
|
||||
var ErrHTTPRequestFailed = &errorsx.ErrWrapper{
|
||||
var ErrHTTPRequestFailed = &netxlite.ErrWrapper{
|
||||
Failure: httpRequestFailed,
|
||||
Operation: errorsx.TopLevelOperation,
|
||||
Operation: netxlite.TopLevelOperation,
|
||||
WrappedErr: errors.New(httpRequestFailed),
|
||||
}
|
||||
|
||||
@@ -92,7 +91,7 @@ func (r Runner) httpGet(ctx context.Context, url string) error {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if _, err = iox.CopyContext(ctx, io.Discard, resp.Body); err != nil {
|
||||
if _, err = netxlite.CopyContext(ctx, io.Discard, resp.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
// Implementation note: we shall check for this error once we have read the
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
|
||||
legacyerrorsx "github.com/ooni/probe-cli/v3/internal/engine/legacy/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
// ControlRequest is the request that we send to the control
|
||||
@@ -62,7 +62,7 @@ func Control(
|
||||
// make sure error is wrapped
|
||||
err = legacyerrorsx.SafeErrWrapperBuilder{
|
||||
Error: clnt.PostJSON(ctx, "/", creq, &out),
|
||||
Operation: errorsx.TopLevelOperation,
|
||||
Operation: netxlite.TopLevelOperation,
|
||||
}.MaybeBuild()
|
||||
sess.Logger().Infof("control for %s... %+v", creq.HTTPRequest, err)
|
||||
(&out.DNS).FillASNs(sess)
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"net"
|
||||
"net/url"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
// DNSAnalysisResult contains the results of analysing comparing
|
||||
@@ -44,7 +44,7 @@ func DNSAnalysis(URL *url.URL, measurement DNSLookupResult,
|
||||
switch *control.DNS.Failure {
|
||||
case DNSNameError: // the control returns this on NXDOMAIN error
|
||||
switch *measurement.Failure {
|
||||
case errorsx.FailureDNSNXDOMAINError:
|
||||
case netxlite.FailureDNSNXDOMAINError:
|
||||
out.DNSConsistency = &DNSConsistent
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
func TestDNSAnalysis(t *testing.T) {
|
||||
measurementFailure := errorsx.FailureDNSNXDOMAINError
|
||||
measurementFailure := netxlite.FailureDNSNXDOMAINError
|
||||
controlFailure := webconnectivity.DNSNameError
|
||||
eofFailure := io.EOF.Error()
|
||||
type args struct {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity/internal"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
// The following set of status flags identifies in a more nuanced way the
|
||||
@@ -127,7 +127,7 @@ func Summarize(tk *TestKeys) (out Summary) {
|
||||
// If DNS failed with NXDOMAIN and the control DNS is consistent, then it
|
||||
// means this website does not exist anymore.
|
||||
if tk.DNSExperimentFailure != nil &&
|
||||
*tk.DNSExperimentFailure == errorsx.FailureDNSNXDOMAINError &&
|
||||
*tk.DNSExperimentFailure == netxlite.FailureDNSNXDOMAINError &&
|
||||
tk.DNSConsistency != nil && *tk.DNSConsistency == DNSConsistent {
|
||||
// TODO(bassosimone): MK flags this as accessible. This result is debatable. We
|
||||
// are doing what MK does. But we most likely want to make it better later.
|
||||
@@ -140,7 +140,7 @@ func Summarize(tk *TestKeys) (out Summary) {
|
||||
// Otherwise, if DNS failed with NXDOMAIN, it's DNS based blocking.
|
||||
// TODO(bassosimone): do we wanna include other errors here? Like timeout?
|
||||
if tk.DNSExperimentFailure != nil &&
|
||||
*tk.DNSExperimentFailure == errorsx.FailureDNSNXDOMAINError {
|
||||
*tk.DNSExperimentFailure == netxlite.FailureDNSNXDOMAINError {
|
||||
out.Accessible = &inaccessible
|
||||
out.BlockingReason = &dns
|
||||
out.Status |= StatusAnomalyDNS | StatusExperimentDNS
|
||||
@@ -184,41 +184,41 @@ func Summarize(tk *TestKeys) (out Summary) {
|
||||
if tk.Requests[0].Failure != nil {
|
||||
out.Status |= StatusExperimentHTTP
|
||||
switch *tk.Requests[0].Failure {
|
||||
case errorsx.FailureConnectionRefused:
|
||||
case netxlite.FailureConnectionRefused:
|
||||
// This is possibly because a subsequent connection to some
|
||||
// other endpoint has been blocked. We call this http-failure
|
||||
// because this is what MK would actually do.
|
||||
out.BlockingReason = &httpFailure
|
||||
out.Accessible = &inaccessible
|
||||
out.Status |= StatusAnomalyConnect
|
||||
case errorsx.FailureConnectionReset:
|
||||
case netxlite.FailureConnectionReset:
|
||||
// We don't currently support TLS failures and we don't have a
|
||||
// way to know if it was during TLS or later. So, for now we are
|
||||
// going to call this error condition an http-failure.
|
||||
out.BlockingReason = &httpFailure
|
||||
out.Accessible = &inaccessible
|
||||
out.Status |= StatusAnomalyReadWrite
|
||||
case errorsx.FailureDNSNXDOMAINError:
|
||||
case netxlite.FailureDNSNXDOMAINError:
|
||||
// This is possibly because a subsequent resolution to
|
||||
// some other domain name has been blocked.
|
||||
out.BlockingReason = &dns
|
||||
out.Accessible = &inaccessible
|
||||
out.Status |= StatusAnomalyDNS
|
||||
case errorsx.FailureEOFError:
|
||||
case netxlite.FailureEOFError:
|
||||
// We have seen this happening with TLS handshakes as well as
|
||||
// sometimes with HTTP blocking. So http-failure.
|
||||
out.BlockingReason = &httpFailure
|
||||
out.Accessible = &inaccessible
|
||||
out.Status |= StatusAnomalyReadWrite
|
||||
case errorsx.FailureGenericTimeoutError:
|
||||
case netxlite.FailureGenericTimeoutError:
|
||||
// Alas, here we don't know whether it's connect or whether it's
|
||||
// perhaps the TLS handshake. So use the same classification used by MK.
|
||||
out.BlockingReason = &httpFailure
|
||||
out.Accessible = &inaccessible
|
||||
out.Status |= StatusAnomalyUnknown
|
||||
case errorsx.FailureSSLInvalidHostname,
|
||||
errorsx.FailureSSLInvalidCertificate,
|
||||
errorsx.FailureSSLUnknownAuthority:
|
||||
case netxlite.FailureSSLInvalidHostname,
|
||||
netxlite.FailureSSLInvalidCertificate,
|
||||
netxlite.FailureSSLUnknownAuthority:
|
||||
// We treat these three cases equally. Misconfiguration is a bit
|
||||
// less likely since we also checked with the control. Since there
|
||||
// is no TLS, for now we're going to call this http-failure.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
func TestSummarize(t *testing.T) {
|
||||
@@ -18,14 +18,14 @@ func TestSummarize(t *testing.T) {
|
||||
httpDiff = "http-diff"
|
||||
httpFailure = "http-failure"
|
||||
nilstring *string
|
||||
probeConnectionRefused = errorsx.FailureConnectionRefused
|
||||
probeConnectionReset = errorsx.FailureConnectionReset
|
||||
probeEOFError = errorsx.FailureEOFError
|
||||
probeNXDOMAIN = errorsx.FailureDNSNXDOMAINError
|
||||
probeTimeout = errorsx.FailureGenericTimeoutError
|
||||
probeSSLInvalidHost = errorsx.FailureSSLInvalidHostname
|
||||
probeSSLInvalidCert = errorsx.FailureSSLInvalidCertificate
|
||||
probeSSLUnknownAuth = errorsx.FailureSSLUnknownAuthority
|
||||
probeConnectionRefused = netxlite.FailureConnectionRefused
|
||||
probeConnectionReset = netxlite.FailureConnectionReset
|
||||
probeEOFError = netxlite.FailureEOFError
|
||||
probeNXDOMAIN = netxlite.FailureDNSNXDOMAINError
|
||||
probeTimeout = netxlite.FailureGenericTimeoutError
|
||||
probeSSLInvalidHost = netxlite.FailureSSLInvalidHostname
|
||||
probeSSLInvalidCert = netxlite.FailureSSLInvalidCertificate
|
||||
probeSSLUnknownAuth = netxlite.FailureSSLUnknownAuthority
|
||||
tcpIP = "tcp_ip"
|
||||
trueValue = true
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
func TestNewExperimentMeasurer(t *testing.T) {
|
||||
@@ -69,10 +69,10 @@ func TestMeasureWithCancelledContext(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tk := measurement.TestKeys.(*webconnectivity.TestKeys)
|
||||
if *tk.ControlFailure != errorsx.FailureInterrupted {
|
||||
if *tk.ControlFailure != netxlite.FailureInterrupted {
|
||||
t.Fatal("unexpected control_failure")
|
||||
}
|
||||
if *tk.DNSExperimentFailure != errorsx.FailureInterrupted {
|
||||
if *tk.DNSExperimentFailure != netxlite.FailureInterrupted {
|
||||
t.Fatal("unexpected dns_experiment_failure")
|
||||
}
|
||||
if tk.HTTPExperimentFailure != nil {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
|
||||
errorsxlegacy "github.com/ooni/probe-cli/v3/internal/engine/legacy/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
// Control performs the control request and returns the response.
|
||||
@@ -21,7 +21,7 @@ func Control(
|
||||
// make sure error is wrapped
|
||||
err = errorsxlegacy.SafeErrWrapperBuilder{
|
||||
Error: clnt.PostJSON(ctx, resourcePath, creq, &out),
|
||||
Operation: errorsx.TopLevelOperation,
|
||||
Operation: netxlite.TopLevelOperation,
|
||||
}.MaybeBuild()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user