refactor: move i/e/n/errorx to i/errorsx (#416)
Still working towards https://github.com/ooni/probe/issues/1505
This commit is contained in:
parent
6895946a34
commit
72acd175a0
|
@ -16,8 +16,8 @@ import (
|
||||||
"github.com/montanaflynn/stats"
|
"github.com/montanaflynn/stats"
|
||||||
"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/netx"
|
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
|
||||||
"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/humanize"
|
"github.com/ooni/probe-cli/v3/internal/humanize"
|
||||||
"github.com/ooni/probe-cli/v3/internal/iox"
|
"github.com/ooni/probe-cli/v3/internal/iox"
|
||||||
)
|
)
|
||||||
|
@ -172,7 +172,7 @@ func (r runner) measure(
|
||||||
// of the latest connect time. We should have one sample in most
|
// of the latest connect time. We should have one sample in most
|
||||||
// cases, because the connection should be persistent.
|
// cases, because the connection should be persistent.
|
||||||
for _, ev := range r.saver.Read() {
|
for _, ev := range r.saver.Read() {
|
||||||
if ev.Name == errorx.ConnectOperation {
|
if ev.Name == errorsx.ConnectOperation {
|
||||||
connectTime = ev.Duration.Seconds()
|
connectTime = ev.Duration.Seconds()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ import (
|
||||||
"github.com/montanaflynn/stats"
|
"github.com/montanaflynn/stats"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
"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/model"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRunnerLoopLocateFailure(t *testing.T) {
|
func TestRunnerLoopLocateFailure(t *testing.T) {
|
||||||
|
@ -108,7 +108,7 @@ func TestRunnerLoopMeasureFailure(t *testing.T) {
|
||||||
func TestRunnerLoopCollectFailure(t *testing.T) {
|
func TestRunnerLoopCollectFailure(t *testing.T) {
|
||||||
expected := errors.New("mocked error")
|
expected := errors.New("mocked error")
|
||||||
saver := new(trace.Saver)
|
saver := new(trace.Saver)
|
||||||
saver.Write(trace.Event{Name: errorx.ConnectOperation, Duration: 150 * time.Millisecond})
|
saver.Write(trace.Event{Name: errorsx.ConnectOperation, Duration: 150 * time.Millisecond})
|
||||||
r := runner{
|
r := runner{
|
||||||
callbacks: model.NewPrinterCallbacks(log.Log),
|
callbacks: model.NewPrinterCallbacks(log.Log),
|
||||||
httpClient: &http.Client{
|
httpClient: &http.Client{
|
||||||
|
@ -152,7 +152,7 @@ func TestRunnerLoopCollectFailure(t *testing.T) {
|
||||||
|
|
||||||
func TestRunnerLoopSuccess(t *testing.T) {
|
func TestRunnerLoopSuccess(t *testing.T) {
|
||||||
saver := new(trace.Saver)
|
saver := new(trace.Saver)
|
||||||
saver.Write(trace.Event{Name: errorx.ConnectOperation, Duration: 150 * time.Millisecond})
|
saver.Write(trace.Event{Name: errorsx.ConnectOperation, Duration: 150 * time.Millisecond})
|
||||||
r := runner{
|
r := runner{
|
||||||
callbacks: model.NewPrinterCallbacks(log.Log),
|
callbacks: model.NewPrinterCallbacks(log.Log),
|
||||||
httpClient: &http.Client{
|
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/experiment/urlgetter"
|
||||||
"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/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -111,7 +111,7 @@ func (tk *TestKeys) ComputeEndpointStatus(v urlgetter.MultiOutput, dns, tcp **bo
|
||||||
// start where all is unknown
|
// start where all is unknown
|
||||||
*dns, *tcp = nil, nil
|
*dns, *tcp = nil, nil
|
||||||
// process DNS first
|
// process DNS first
|
||||||
if v.TestKeys.FailedOperation != nil && *v.TestKeys.FailedOperation == errorx.ResolveOperation {
|
if v.TestKeys.FailedOperation != nil && *v.TestKeys.FailedOperation == errorsx.ResolveOperation {
|
||||||
tk.FacebookDNSBlocking = &trueValue
|
tk.FacebookDNSBlocking = &trueValue
|
||||||
*dns = &falseValue
|
*dns = &falseValue
|
||||||
return // we know that the DNS has failed
|
return // we know that the DNS has failed
|
||||||
|
@ -127,7 +127,7 @@ func (tk *TestKeys) ComputeEndpointStatus(v urlgetter.MultiOutput, dns, tcp **bo
|
||||||
}
|
}
|
||||||
*dns = &trueValue
|
*dns = &trueValue
|
||||||
// now process connect
|
// now process connect
|
||||||
if v.TestKeys.FailedOperation != nil && *v.TestKeys.FailedOperation == errorx.ConnectOperation {
|
if v.TestKeys.FailedOperation != nil && *v.TestKeys.FailedOperation == errorsx.ConnectOperation {
|
||||||
tk.FacebookTCPBlocking = &trueValue
|
tk.FacebookTCPBlocking = &trueValue
|
||||||
*tcp = &falseValue
|
*tcp = &falseValue
|
||||||
return // because connect failed
|
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/mockable"
|
||||||
"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/netx/archival"
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewExperimentMeasurer(t *testing.T) {
|
func TestNewExperimentMeasurer(t *testing.T) {
|
||||||
|
@ -162,7 +162,7 @@ func TestWithCancelledContext(t *testing.T) {
|
||||||
|
|
||||||
func TestComputeEndpointStatsTCPBlocking(t *testing.T) {
|
func TestComputeEndpointStatsTCPBlocking(t *testing.T) {
|
||||||
failure := io.EOF.Error()
|
failure := io.EOF.Error()
|
||||||
operation := errorx.ConnectOperation
|
operation := errorsx.ConnectOperation
|
||||||
tk := fbmessenger.TestKeys{}
|
tk := fbmessenger.TestKeys{}
|
||||||
tk.Update(urlgetter.MultiOutput{
|
tk.Update(urlgetter.MultiOutput{
|
||||||
Input: urlgetter.MultiInput{Target: fbmessenger.ServiceEdge},
|
Input: urlgetter.MultiInput{Target: fbmessenger.ServiceEdge},
|
||||||
|
@ -192,7 +192,7 @@ func TestComputeEndpointStatsTCPBlocking(t *testing.T) {
|
||||||
|
|
||||||
func TestComputeEndpointStatsDNSIsLying(t *testing.T) {
|
func TestComputeEndpointStatsDNSIsLying(t *testing.T) {
|
||||||
failure := io.EOF.Error()
|
failure := io.EOF.Error()
|
||||||
operation := errorx.ConnectOperation
|
operation := errorsx.ConnectOperation
|
||||||
tk := fbmessenger.TestKeys{}
|
tk := fbmessenger.TestKeys{}
|
||||||
tk.Update(urlgetter.MultiOutput{
|
tk.Update(urlgetter.MultiOutput{
|
||||||
Input: urlgetter.MultiInput{Target: fbmessenger.ServiceEdge},
|
Input: urlgetter.MultiInput{Target: fbmessenger.ServiceEdge},
|
||||||
|
|
|
@ -19,7 +19,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/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/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
"github.com/ooni/probe-cli/v3/internal/iox"
|
"github.com/ooni/probe-cli/v3/internal/iox"
|
||||||
"github.com/ooni/probe-cli/v3/internal/randx"
|
"github.com/ooni/probe-cli/v3/internal/randx"
|
||||||
)
|
)
|
||||||
|
@ -164,7 +164,7 @@ func (m Measurer) Run(
|
||||||
// parse response body
|
// parse response body
|
||||||
var jsonHeaders JSONHeaders
|
var jsonHeaders JSONHeaders
|
||||||
if err := json.Unmarshal(data, &jsonHeaders); err != nil {
|
if err := json.Unmarshal(data, &jsonHeaders); err != nil {
|
||||||
failure := errorx.FailureJSONParseError
|
failure := errorsx.FailureJSONParseError
|
||||||
tk.Failure = &failure
|
tk.Failure = &failure
|
||||||
tk.Tampering.Total = true
|
tk.Tampering.Total = true
|
||||||
return nil // measurement did not fail, we measured tampering
|
return nil // measurement did not fail, we measured tampering
|
||||||
|
@ -180,8 +180,8 @@ func Transact(txp Transport, req *http.Request,
|
||||||
callbacks model.ExperimentCallbacks) (*http.Response, []byte, error) {
|
callbacks model.ExperimentCallbacks) (*http.Response, []byte, error) {
|
||||||
// make sure that we return a wrapped error here
|
// make sure that we return a wrapped error here
|
||||||
resp, data, err := transact(txp, req, callbacks)
|
resp, data, err := transact(txp, req, callbacks)
|
||||||
err = errorx.SafeErrWrapperBuilder{
|
err = errorsx.SafeErrWrapperBuilder{
|
||||||
Error: err, Operation: errorx.TopLevelOperation}.MaybeBuild()
|
Error: err, Operation: errorsx.TopLevelOperation}.MaybeBuild()
|
||||||
return resp, data, err
|
return resp, data, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import (
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
"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/model"
|
||||||
"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/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewExperimentMeasurer(t *testing.T) {
|
func TestNewExperimentMeasurer(t *testing.T) {
|
||||||
|
@ -161,14 +161,14 @@ func TestCancelledContext(t *testing.T) {
|
||||||
if tk.Agent != "agent" {
|
if tk.Agent != "agent" {
|
||||||
t.Fatal("invalid Agent")
|
t.Fatal("invalid Agent")
|
||||||
}
|
}
|
||||||
if *tk.Failure != errorx.FailureInterrupted {
|
if *tk.Failure != errorsx.FailureInterrupted {
|
||||||
t.Fatal("invalid Failure")
|
t.Fatal("invalid Failure")
|
||||||
}
|
}
|
||||||
if len(tk.Requests) != 1 {
|
if len(tk.Requests) != 1 {
|
||||||
t.Fatal("invalid Requests")
|
t.Fatal("invalid Requests")
|
||||||
}
|
}
|
||||||
request := tk.Requests[0]
|
request := tk.Requests[0]
|
||||||
if *request.Failure != errorx.FailureInterrupted {
|
if *request.Failure != errorsx.FailureInterrupted {
|
||||||
t.Fatal("invalid Requests[0].Failure")
|
t.Fatal("invalid Requests[0].Failure")
|
||||||
}
|
}
|
||||||
if request.Request.Body.Value != "" {
|
if request.Request.Body.Value != "" {
|
||||||
|
@ -480,7 +480,7 @@ func TestInvalidJSONBody(t *testing.T) {
|
||||||
if tk.Agent != "agent" {
|
if tk.Agent != "agent" {
|
||||||
t.Fatal("invalid Agent")
|
t.Fatal("invalid Agent")
|
||||||
}
|
}
|
||||||
if *tk.Failure != errorx.FailureJSONParseError {
|
if *tk.Failure != errorsx.FailureJSONParseError {
|
||||||
t.Fatal("invalid Failure")
|
t.Fatal("invalid Failure")
|
||||||
}
|
}
|
||||||
if len(tk.Requests) != 1 {
|
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/model"
|
||||||
"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/archival"
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
"github.com/ooni/probe-cli/v3/internal/randx"
|
"github.com/ooni/probe-cli/v3/internal/randx"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ func RunMethod(ctx context.Context, config RunMethodConfig) {
|
||||||
count, err := conn.Read(data)
|
count, err := conn.Read(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// We expect this method to terminate w/ timeout
|
// We expect this method to terminate w/ timeout
|
||||||
if err.Error() == errorx.FailureGenericTimeoutError {
|
if err.Error() == errorsx.FailureGenericTimeoutError {
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
result.Err = err
|
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/model"
|
||||||
"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/archival"
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewExperimentMeasurer(t *testing.T) {
|
func TestNewExperimentMeasurer(t *testing.T) {
|
||||||
|
@ -97,7 +97,7 @@ func TestCancelledContext(t *testing.T) {
|
||||||
t.Fatal("unexpected FailureList length")
|
t.Fatal("unexpected FailureList length")
|
||||||
}
|
}
|
||||||
for _, failure := range tk.FailureList {
|
for _, failure := range tk.FailureList {
|
||||||
if *failure != errorx.FailureInterrupted {
|
if *failure != errorsx.FailureInterrupted {
|
||||||
t.Fatal("unexpected failure")
|
t.Fatal("unexpected failure")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
"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/model"
|
||||||
"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/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -270,11 +270,11 @@ func TestUpdateWithMixedResults(t *testing.T) {
|
||||||
},
|
},
|
||||||
TestKeys: urlgetter.TestKeys{
|
TestKeys: urlgetter.TestKeys{
|
||||||
FailedOperation: (func() *string {
|
FailedOperation: (func() *string {
|
||||||
s := errorx.HTTPRoundTripOperation
|
s := errorsx.HTTPRoundTripOperation
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
Failure: (func() *string {
|
Failure: (func() *string {
|
||||||
s := errorx.FailureEOFError
|
s := errorsx.FailureEOFError
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
},
|
},
|
||||||
|
@ -291,7 +291,7 @@ func TestUpdateWithMixedResults(t *testing.T) {
|
||||||
if tk.APIStatus != "blocked" {
|
if tk.APIStatus != "blocked" {
|
||||||
t.Fatal("ApiStatus should be blocked")
|
t.Fatal("ApiStatus should be blocked")
|
||||||
}
|
}
|
||||||
if *tk.APIFailure != errorx.FailureEOFError {
|
if *tk.APIFailure != errorsx.FailureEOFError {
|
||||||
t.Fatal("invalid ApiFailure")
|
t.Fatal("invalid ApiFailure")
|
||||||
}
|
}
|
||||||
if tk.FailingGateways != nil {
|
if tk.FailingGateways != nil {
|
||||||
|
@ -730,7 +730,7 @@ func generateMockGetter(requestResponse map[string]string, responseStatus map[st
|
||||||
responseBody = ""
|
responseBody = ""
|
||||||
eofError := io.EOF.Error()
|
eofError := io.EOF.Error()
|
||||||
failure = &eofError
|
failure = &eofError
|
||||||
connectOperation := errorx.ConnectOperation
|
connectOperation := errorsx.ConnectOperation
|
||||||
failedOperation = &connectOperation
|
failedOperation = &connectOperation
|
||||||
responseStatus = 0
|
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/experiment/urlgetter"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
"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/model"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewExperimentMeasurer(t *testing.T) {
|
func TestNewExperimentMeasurer(t *testing.T) {
|
||||||
|
@ -85,7 +85,7 @@ func TestUpdate(t *testing.T) {
|
||||||
},
|
},
|
||||||
TestKeys: urlgetter.TestKeys{
|
TestKeys: urlgetter.TestKeys{
|
||||||
Failure: (func() *string {
|
Failure: (func() *string {
|
||||||
s := errorx.FailureEOFError
|
s := errorsx.FailureEOFError
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
},
|
},
|
||||||
|
@ -93,7 +93,7 @@ func TestUpdate(t *testing.T) {
|
||||||
if tk.SignalBackendStatus != "blocked" {
|
if tk.SignalBackendStatus != "blocked" {
|
||||||
t.Fatal("SignalBackendStatus should be blocked")
|
t.Fatal("SignalBackendStatus should be blocked")
|
||||||
}
|
}
|
||||||
if *tk.SignalBackendFailure != errorx.FailureEOFError {
|
if *tk.SignalBackendFailure != errorsx.FailureEOFError {
|
||||||
t.Fatal("invalid SignalBackendError")
|
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/experiment/urlgetter"
|
||||||
"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/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -64,24 +64,24 @@ func (tk *TestKeys) classify() string {
|
||||||
return classSuccessGotServerHello
|
return classSuccessGotServerHello
|
||||||
}
|
}
|
||||||
switch *tk.Target.Failure {
|
switch *tk.Target.Failure {
|
||||||
case errorx.FailureConnectionRefused:
|
case errorsx.FailureConnectionRefused:
|
||||||
return classAnomalyTestHelperUnreachable
|
return classAnomalyTestHelperUnreachable
|
||||||
case errorx.FailureConnectionReset:
|
case errorsx.FailureConnectionReset:
|
||||||
return classInterferenceReset
|
return classInterferenceReset
|
||||||
case errorx.FailureDNSNXDOMAINError:
|
case errorsx.FailureDNSNXDOMAINError:
|
||||||
return classAnomalyTestHelperUnreachable
|
return classAnomalyTestHelperUnreachable
|
||||||
case errorx.FailureEOFError:
|
case errorsx.FailureEOFError:
|
||||||
return classInterferenceClosed
|
return classInterferenceClosed
|
||||||
case errorx.FailureGenericTimeoutError:
|
case errorsx.FailureGenericTimeoutError:
|
||||||
if tk.Control.Failure != nil {
|
if tk.Control.Failure != nil {
|
||||||
return classAnomalyTestHelperUnreachable
|
return classAnomalyTestHelperUnreachable
|
||||||
}
|
}
|
||||||
return classAnomalyTimeout
|
return classAnomalyTimeout
|
||||||
case errorx.FailureSSLInvalidCertificate:
|
case errorsx.FailureSSLInvalidCertificate:
|
||||||
return classInterferenceInvalidCertificate
|
return classInterferenceInvalidCertificate
|
||||||
case errorx.FailureSSLInvalidHostname:
|
case errorsx.FailureSSLInvalidHostname:
|
||||||
return classSuccessGotServerHello
|
return classSuccessGotServerHello
|
||||||
case errorx.FailureSSLUnknownAuthority:
|
case errorsx.FailureSSLUnknownAuthority:
|
||||||
return classInterferenceUnknownAuthority
|
return classInterferenceUnknownAuthority
|
||||||
}
|
}
|
||||||
return classAnomalyUnexpectedFailure
|
return classAnomalyUnexpectedFailure
|
||||||
|
@ -117,8 +117,8 @@ func (m *Measurer) measureone(
|
||||||
select {
|
select {
|
||||||
case <-time.After(sleeptime):
|
case <-time.After(sleeptime):
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
s := errorx.FailureInterrupted
|
s := errorsx.FailureInterrupted
|
||||||
failedop := errorx.TopLevelOperation
|
failedop := errorsx.TopLevelOperation
|
||||||
return Subresult{
|
return Subresult{
|
||||||
TestKeys: urlgetter.TestKeys{
|
TestKeys: urlgetter.TestKeys{
|
||||||
FailedOperation: &failedop,
|
FailedOperation: &failedop,
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
"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/model"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -29,64 +29,64 @@ func TestTestKeysClassify(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("with tk.Target.Failure == connection_refused", func(t *testing.T) {
|
t.Run("with tk.Target.Failure == connection_refused", func(t *testing.T) {
|
||||||
tk := new(TestKeys)
|
tk := new(TestKeys)
|
||||||
tk.Target.Failure = asStringPtr(errorx.FailureConnectionRefused)
|
tk.Target.Failure = asStringPtr(errorsx.FailureConnectionRefused)
|
||||||
if tk.classify() != classAnomalyTestHelperUnreachable {
|
if tk.classify() != classAnomalyTestHelperUnreachable {
|
||||||
t.Fatal("unexpected result")
|
t.Fatal("unexpected result")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
t.Run("with tk.Target.Failure == dns_nxdomain_error", func(t *testing.T) {
|
t.Run("with tk.Target.Failure == dns_nxdomain_error", func(t *testing.T) {
|
||||||
tk := new(TestKeys)
|
tk := new(TestKeys)
|
||||||
tk.Target.Failure = asStringPtr(errorx.FailureDNSNXDOMAINError)
|
tk.Target.Failure = asStringPtr(errorsx.FailureDNSNXDOMAINError)
|
||||||
if tk.classify() != classAnomalyTestHelperUnreachable {
|
if tk.classify() != classAnomalyTestHelperUnreachable {
|
||||||
t.Fatal("unexpected result")
|
t.Fatal("unexpected result")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
t.Run("with tk.Target.Failure == connection_reset", func(t *testing.T) {
|
t.Run("with tk.Target.Failure == connection_reset", func(t *testing.T) {
|
||||||
tk := new(TestKeys)
|
tk := new(TestKeys)
|
||||||
tk.Target.Failure = asStringPtr(errorx.FailureConnectionReset)
|
tk.Target.Failure = asStringPtr(errorsx.FailureConnectionReset)
|
||||||
if tk.classify() != classInterferenceReset {
|
if tk.classify() != classInterferenceReset {
|
||||||
t.Fatal("unexpected result")
|
t.Fatal("unexpected result")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
t.Run("with tk.Target.Failure == eof_error", func(t *testing.T) {
|
t.Run("with tk.Target.Failure == eof_error", func(t *testing.T) {
|
||||||
tk := new(TestKeys)
|
tk := new(TestKeys)
|
||||||
tk.Target.Failure = asStringPtr(errorx.FailureEOFError)
|
tk.Target.Failure = asStringPtr(errorsx.FailureEOFError)
|
||||||
if tk.classify() != classInterferenceClosed {
|
if tk.classify() != classInterferenceClosed {
|
||||||
t.Fatal("unexpected result")
|
t.Fatal("unexpected result")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
t.Run("with tk.Target.Failure == ssl_invalid_hostname", func(t *testing.T) {
|
t.Run("with tk.Target.Failure == ssl_invalid_hostname", func(t *testing.T) {
|
||||||
tk := new(TestKeys)
|
tk := new(TestKeys)
|
||||||
tk.Target.Failure = asStringPtr(errorx.FailureSSLInvalidHostname)
|
tk.Target.Failure = asStringPtr(errorsx.FailureSSLInvalidHostname)
|
||||||
if tk.classify() != classSuccessGotServerHello {
|
if tk.classify() != classSuccessGotServerHello {
|
||||||
t.Fatal("unexpected result")
|
t.Fatal("unexpected result")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
t.Run("with tk.Target.Failure == ssl_unknown_authority", func(t *testing.T) {
|
t.Run("with tk.Target.Failure == ssl_unknown_authority", func(t *testing.T) {
|
||||||
tk := new(TestKeys)
|
tk := new(TestKeys)
|
||||||
tk.Target.Failure = asStringPtr(errorx.FailureSSLUnknownAuthority)
|
tk.Target.Failure = asStringPtr(errorsx.FailureSSLUnknownAuthority)
|
||||||
if tk.classify() != classInterferenceUnknownAuthority {
|
if tk.classify() != classInterferenceUnknownAuthority {
|
||||||
t.Fatal("unexpected result")
|
t.Fatal("unexpected result")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
t.Run("with tk.Target.Failure == ssl_invalid_certificate", func(t *testing.T) {
|
t.Run("with tk.Target.Failure == ssl_invalid_certificate", func(t *testing.T) {
|
||||||
tk := new(TestKeys)
|
tk := new(TestKeys)
|
||||||
tk.Target.Failure = asStringPtr(errorx.FailureSSLInvalidCertificate)
|
tk.Target.Failure = asStringPtr(errorsx.FailureSSLInvalidCertificate)
|
||||||
if tk.classify() != classInterferenceInvalidCertificate {
|
if tk.classify() != classInterferenceInvalidCertificate {
|
||||||
t.Fatal("unexpected result")
|
t.Fatal("unexpected result")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
t.Run("with tk.Target.Failure == generic_timeout_error #1", func(t *testing.T) {
|
t.Run("with tk.Target.Failure == generic_timeout_error #1", func(t *testing.T) {
|
||||||
tk := new(TestKeys)
|
tk := new(TestKeys)
|
||||||
tk.Target.Failure = asStringPtr(errorx.FailureGenericTimeoutError)
|
tk.Target.Failure = asStringPtr(errorsx.FailureGenericTimeoutError)
|
||||||
if tk.classify() != classAnomalyTimeout {
|
if tk.classify() != classAnomalyTimeout {
|
||||||
t.Fatal("unexpected result")
|
t.Fatal("unexpected result")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
t.Run("with tk.Target.Failure == generic_timeout_error #2", func(t *testing.T) {
|
t.Run("with tk.Target.Failure == generic_timeout_error #2", func(t *testing.T) {
|
||||||
tk := new(TestKeys)
|
tk := new(TestKeys)
|
||||||
tk.Target.Failure = asStringPtr(errorx.FailureGenericTimeoutError)
|
tk.Target.Failure = asStringPtr(errorsx.FailureGenericTimeoutError)
|
||||||
tk.Control.Failure = asStringPtr(errorx.FailureGenericTimeoutError)
|
tk.Control.Failure = asStringPtr(errorsx.FailureGenericTimeoutError)
|
||||||
if tk.classify() != classAnomalyTestHelperUnreachable {
|
if tk.classify() != classAnomalyTestHelperUnreachable {
|
||||||
t.Fatal("unexpected result")
|
t.Fatal("unexpected result")
|
||||||
}
|
}
|
||||||
|
@ -191,10 +191,10 @@ func TestMeasureoneCancelledContext(t *testing.T) {
|
||||||
if result.DNSCache != nil {
|
if result.DNSCache != nil {
|
||||||
t.Fatal("not the expected DNSCache")
|
t.Fatal("not the expected DNSCache")
|
||||||
}
|
}
|
||||||
if result.FailedOperation == nil || *result.FailedOperation != errorx.TopLevelOperation {
|
if result.FailedOperation == nil || *result.FailedOperation != errorsx.TopLevelOperation {
|
||||||
t.Fatal("not the expected FailedOperation")
|
t.Fatal("not the expected FailedOperation")
|
||||||
}
|
}
|
||||||
if result.Failure == nil || *result.Failure != errorx.FailureInterrupted {
|
if result.Failure == nil || *result.Failure != errorsx.FailureInterrupted {
|
||||||
t.Fatal("not the expected failure")
|
t.Fatal("not the expected failure")
|
||||||
}
|
}
|
||||||
if result.NetworkEvents != nil {
|
if result.NetworkEvents != nil {
|
||||||
|
@ -295,10 +295,10 @@ func TestMeasureoneSuccess(t *testing.T) {
|
||||||
if result.DNSCache != nil {
|
if result.DNSCache != nil {
|
||||||
t.Fatal("not the expected DNSCache")
|
t.Fatal("not the expected DNSCache")
|
||||||
}
|
}
|
||||||
if result.FailedOperation == nil || *result.FailedOperation != errorx.TLSHandshakeOperation {
|
if result.FailedOperation == nil || *result.FailedOperation != errorsx.TLSHandshakeOperation {
|
||||||
t.Fatal("not the expected FailedOperation")
|
t.Fatal("not the expected FailedOperation")
|
||||||
}
|
}
|
||||||
if result.Failure == nil || *result.Failure != errorx.FailureSSLInvalidHostname {
|
if result.Failure == nil || *result.Failure != errorsx.FailureSSLInvalidHostname {
|
||||||
t.Fatal("unexpected failure")
|
t.Fatal("unexpected failure")
|
||||||
}
|
}
|
||||||
if len(result.NetworkEvents) < 1 {
|
if len(result.NetworkEvents) < 1 {
|
||||||
|
@ -348,7 +348,7 @@ func TestMeasureonewithcacheWorks(t *testing.T) {
|
||||||
if result.Cached != expected {
|
if result.Cached != expected {
|
||||||
t.Fatal("unexpected cached")
|
t.Fatal("unexpected cached")
|
||||||
}
|
}
|
||||||
if *result.Failure != errorx.FailureSSLInvalidHostname {
|
if *result.Failure != errorsx.FailureSSLInvalidHostname {
|
||||||
t.Fatal("unexpected failure")
|
t.Fatal("unexpected failure")
|
||||||
}
|
}
|
||||||
if result.SNI != "kernel.org" {
|
if result.SNI != "kernel.org" {
|
||||||
|
|
|
@ -13,8 +13,8 @@ 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/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/engine/netx/errorx"
|
|
||||||
"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/pion/stun"
|
"github.com/pion/stun"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ func (m *Measurer) ExperimentVersion() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func wrap(err error) error {
|
func wrap(err error) error {
|
||||||
return errorx.SafeErrWrapperBuilder{
|
return errorsx.SafeErrWrapperBuilder{
|
||||||
Error: err,
|
Error: err,
|
||||||
Operation: "stun",
|
Operation: "stun",
|
||||||
}.MaybeBuild()
|
}.MaybeBuild()
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/stunreachability"
|
"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/mockable"
|
||||||
"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/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
"github.com/pion/stun"
|
"github.com/pion/stun"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ func TestReadFailure(t *testing.T) {
|
||||||
t.Fatal("not the error we expected")
|
t.Fatal("not the error we expected")
|
||||||
}
|
}
|
||||||
tk := measurement.TestKeys.(*stunreachability.TestKeys)
|
tk := measurement.TestKeys.(*stunreachability.TestKeys)
|
||||||
if *tk.Failure != errorx.FailureGenericTimeoutError {
|
if *tk.Failure != errorsx.FailureGenericTimeoutError {
|
||||||
t.Fatal("expected different failure here")
|
t.Fatal("expected different failure here")
|
||||||
}
|
}
|
||||||
if tk.Endpoint != "stun.l.google.com:19302" {
|
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/experiment/urlgetter"
|
||||||
"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/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -56,7 +56,7 @@ func (tk *TestKeys) Update(v urlgetter.MultiOutput) {
|
||||||
tk.TelegramTCPBlocking = false
|
tk.TelegramTCPBlocking = false
|
||||||
return // found successful access point connection
|
return // found successful access point connection
|
||||||
}
|
}
|
||||||
if v.TestKeys.FailedOperation == nil || *v.TestKeys.FailedOperation != errorx.ConnectOperation {
|
if v.TestKeys.FailedOperation == nil || *v.TestKeys.FailedOperation != errorsx.ConnectOperation {
|
||||||
tk.TelegramTCPBlocking = false
|
tk.TelegramTCPBlocking = false
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
"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/mockable"
|
||||||
"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/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewExperimentMeasurer(t *testing.T) {
|
func TestNewExperimentMeasurer(t *testing.T) {
|
||||||
|
@ -94,7 +94,7 @@ func TestUpdateWithNoAccessPointsBlocking(t *testing.T) {
|
||||||
},
|
},
|
||||||
TestKeys: urlgetter.TestKeys{
|
TestKeys: urlgetter.TestKeys{
|
||||||
Failure: (func() *string {
|
Failure: (func() *string {
|
||||||
s := errorx.FailureEOFError
|
s := errorsx.FailureEOFError
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
},
|
},
|
||||||
|
@ -125,7 +125,7 @@ func TestUpdateWithNilFailedOperation(t *testing.T) {
|
||||||
},
|
},
|
||||||
TestKeys: urlgetter.TestKeys{
|
TestKeys: urlgetter.TestKeys{
|
||||||
Failure: (func() *string {
|
Failure: (func() *string {
|
||||||
s := errorx.FailureEOFError
|
s := errorsx.FailureEOFError
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
},
|
},
|
||||||
|
@ -137,7 +137,7 @@ func TestUpdateWithNilFailedOperation(t *testing.T) {
|
||||||
},
|
},
|
||||||
TestKeys: urlgetter.TestKeys{
|
TestKeys: urlgetter.TestKeys{
|
||||||
Failure: (func() *string {
|
Failure: (func() *string {
|
||||||
s := errorx.FailureEOFError
|
s := errorsx.FailureEOFError
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
},
|
},
|
||||||
|
@ -159,11 +159,11 @@ func TestUpdateWithNonConnectFailedOperation(t *testing.T) {
|
||||||
},
|
},
|
||||||
TestKeys: urlgetter.TestKeys{
|
TestKeys: urlgetter.TestKeys{
|
||||||
FailedOperation: (func() *string {
|
FailedOperation: (func() *string {
|
||||||
s := errorx.ConnectOperation
|
s := errorsx.ConnectOperation
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
Failure: (func() *string {
|
Failure: (func() *string {
|
||||||
s := errorx.FailureEOFError
|
s := errorsx.FailureEOFError
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
},
|
},
|
||||||
|
@ -175,11 +175,11 @@ func TestUpdateWithNonConnectFailedOperation(t *testing.T) {
|
||||||
},
|
},
|
||||||
TestKeys: urlgetter.TestKeys{
|
TestKeys: urlgetter.TestKeys{
|
||||||
FailedOperation: (func() *string {
|
FailedOperation: (func() *string {
|
||||||
s := errorx.HTTPRoundTripOperation
|
s := errorsx.HTTPRoundTripOperation
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
Failure: (func() *string {
|
Failure: (func() *string {
|
||||||
s := errorx.FailureEOFError
|
s := errorsx.FailureEOFError
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
},
|
},
|
||||||
|
@ -201,11 +201,11 @@ func TestUpdateWithAllConnectsFailed(t *testing.T) {
|
||||||
},
|
},
|
||||||
TestKeys: urlgetter.TestKeys{
|
TestKeys: urlgetter.TestKeys{
|
||||||
FailedOperation: (func() *string {
|
FailedOperation: (func() *string {
|
||||||
s := errorx.ConnectOperation
|
s := errorsx.ConnectOperation
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
Failure: (func() *string {
|
Failure: (func() *string {
|
||||||
s := errorx.FailureEOFError
|
s := errorsx.FailureEOFError
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
},
|
},
|
||||||
|
@ -217,11 +217,11 @@ func TestUpdateWithAllConnectsFailed(t *testing.T) {
|
||||||
},
|
},
|
||||||
TestKeys: urlgetter.TestKeys{
|
TestKeys: urlgetter.TestKeys{
|
||||||
FailedOperation: (func() *string {
|
FailedOperation: (func() *string {
|
||||||
s := errorx.ConnectOperation
|
s := errorsx.ConnectOperation
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
Failure: (func() *string {
|
Failure: (func() *string {
|
||||||
s := errorx.FailureEOFError
|
s := errorsx.FailureEOFError
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
},
|
},
|
||||||
|
@ -243,11 +243,11 @@ func TestUpdateWebWithMixedResults(t *testing.T) {
|
||||||
},
|
},
|
||||||
TestKeys: urlgetter.TestKeys{
|
TestKeys: urlgetter.TestKeys{
|
||||||
FailedOperation: (func() *string {
|
FailedOperation: (func() *string {
|
||||||
s := errorx.HTTPRoundTripOperation
|
s := errorsx.HTTPRoundTripOperation
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
Failure: (func() *string {
|
Failure: (func() *string {
|
||||||
s := errorx.FailureEOFError
|
s := errorsx.FailureEOFError
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
},
|
},
|
||||||
|
@ -265,7 +265,7 @@ func TestUpdateWebWithMixedResults(t *testing.T) {
|
||||||
if tk.TelegramWebStatus != "blocked" {
|
if tk.TelegramWebStatus != "blocked" {
|
||||||
t.Fatal("TelegramWebStatus should be blocked")
|
t.Fatal("TelegramWebStatus should be blocked")
|
||||||
}
|
}
|
||||||
if *tk.TelegramWebFailure != errorx.FailureEOFError {
|
if *tk.TelegramWebFailure != errorsx.FailureEOFError {
|
||||||
t.Fatal("invalid TelegramWebFailure")
|
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/oonidatamodel"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/oonitemplates"
|
"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/engine/model"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||||
"github.com/ooni/probe-cli/v3/internal/scrubber"
|
"github.com/ooni/probe-cli/v3/internal/scrubber"
|
||||||
)
|
)
|
||||||
|
@ -77,7 +77,7 @@ func (tr *TargetResults) fillSummary() {
|
||||||
if len(tr.TCPConnect) < 1 {
|
if len(tr.TCPConnect) < 1 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tr.Summary[errorx.ConnectOperation] = Summary{
|
tr.Summary[errorsx.ConnectOperation] = Summary{
|
||||||
Failure: tr.TCPConnect[0].Status.Failure,
|
Failure: tr.TCPConnect[0].Status.Failure,
|
||||||
}
|
}
|
||||||
switch tr.TargetProtocol {
|
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/legacy/oonitemplates"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
"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/model"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
"github.com/ooni/probe-cli/v3/internal/scrubber"
|
"github.com/ooni/probe-cli/v3/internal/scrubber"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ func TestSummary(t *testing.T) {
|
||||||
if len(tr.Summary) != 1 {
|
if len(tr.Summary) != 1 {
|
||||||
t.Fatal("cannot find expected entry")
|
t.Fatal("cannot find expected entry")
|
||||||
}
|
}
|
||||||
if *tr.Summary[errorx.ConnectOperation].Failure != failure {
|
if *tr.Summary[errorsx.ConnectOperation].Failure != failure {
|
||||||
t.Fatal("invalid failure")
|
t.Fatal("invalid failure")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -465,7 +465,7 @@ func TestSummary(t *testing.T) {
|
||||||
if len(tr.Summary) != 2 {
|
if len(tr.Summary) != 2 {
|
||||||
t.Fatal("cannot find expected entry")
|
t.Fatal("cannot find expected entry")
|
||||||
}
|
}
|
||||||
if tr.Summary[errorx.ConnectOperation].Failure != nil {
|
if tr.Summary[errorsx.ConnectOperation].Failure != nil {
|
||||||
t.Fatal("invalid failure")
|
t.Fatal("invalid failure")
|
||||||
}
|
}
|
||||||
if *tr.Summary["handshake"].Failure != failure {
|
if *tr.Summary["handshake"].Failure != failure {
|
||||||
|
@ -489,7 +489,7 @@ func TestSummary(t *testing.T) {
|
||||||
if len(tr.Summary) < 1 {
|
if len(tr.Summary) < 1 {
|
||||||
t.Fatal("cannot find expected entry")
|
t.Fatal("cannot find expected entry")
|
||||||
}
|
}
|
||||||
if tr.Summary[errorx.ConnectOperation].Failure != nil {
|
if tr.Summary[errorsx.ConnectOperation].Failure != nil {
|
||||||
t.Fatal("invalid failure")
|
t.Fatal("invalid failure")
|
||||||
}
|
}
|
||||||
if handshake == nil {
|
if handshake == nil {
|
||||||
|
|
|
@ -8,8 +8,8 @@ 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/netx/archival"
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
|
||||||
"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/tunnel"
|
"github.com/ooni/probe-cli/v3/internal/tunnel"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -54,9 +54,9 @@ func (g Getter) Get(ctx context.Context) (TestKeys, error) {
|
||||||
tk, err := g.get(ctx, saver)
|
tk, err := g.get(ctx, saver)
|
||||||
// Make sure we have an operation in cases where we fail before
|
// Make sure we have an operation in cases where we fail before
|
||||||
// hitting our httptransport that does error wrapping.
|
// hitting our httptransport that does error wrapping.
|
||||||
err = errorx.SafeErrWrapperBuilder{
|
err = errorsx.SafeErrWrapperBuilder{
|
||||||
Error: err,
|
Error: err,
|
||||||
Operation: errorx.TopLevelOperation,
|
Operation: errorsx.TopLevelOperation,
|
||||||
}.MaybeBuild()
|
}.MaybeBuild()
|
||||||
tk.FailedOperation = archival.NewFailedOperation(err)
|
tk.FailedOperation = archival.NewFailedOperation(err)
|
||||||
tk.Failure = archival.NewFailure(err)
|
tk.Failure = archival.NewFailure(err)
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
"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/mockable"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetterWithVeryShortTimeout(t *testing.T) {
|
func TestGetterWithVeryShortTimeout(t *testing.T) {
|
||||||
|
@ -31,7 +31,7 @@ func TestGetterWithVeryShortTimeout(t *testing.T) {
|
||||||
if tk.BootstrapTime != 0 {
|
if tk.BootstrapTime != 0 {
|
||||||
t.Fatal("not the BootstrapTime we expected")
|
t.Fatal("not the BootstrapTime we expected")
|
||||||
}
|
}
|
||||||
if tk.FailedOperation == nil || *tk.FailedOperation != errorx.TopLevelOperation {
|
if tk.FailedOperation == nil || *tk.FailedOperation != errorsx.TopLevelOperation {
|
||||||
t.Fatal("not the FailedOperation we expected")
|
t.Fatal("not the FailedOperation we expected")
|
||||||
}
|
}
|
||||||
if tk.Failure == nil || *tk.Failure != "generic_timeout_error" {
|
if tk.Failure == nil || *tk.Failure != "generic_timeout_error" {
|
||||||
|
@ -98,7 +98,7 @@ func TestGetterWithCancelledContextVanilla(t *testing.T) {
|
||||||
if tk.BootstrapTime != 0 {
|
if tk.BootstrapTime != 0 {
|
||||||
t.Fatal("not the BootstrapTime we expected")
|
t.Fatal("not the BootstrapTime we expected")
|
||||||
}
|
}
|
||||||
if tk.FailedOperation == nil || *tk.FailedOperation != errorx.TopLevelOperation {
|
if tk.FailedOperation == nil || *tk.FailedOperation != errorsx.TopLevelOperation {
|
||||||
t.Fatal("not the FailedOperation we expected")
|
t.Fatal("not the FailedOperation we expected")
|
||||||
}
|
}
|
||||||
if tk.Failure == nil || !strings.HasSuffix(*tk.Failure, "interrupted") {
|
if tk.Failure == nil || !strings.HasSuffix(*tk.Failure, "interrupted") {
|
||||||
|
@ -166,7 +166,7 @@ func TestGetterWithCancelledContextAndMethod(t *testing.T) {
|
||||||
if tk.BootstrapTime != 0 {
|
if tk.BootstrapTime != 0 {
|
||||||
t.Fatal("not the BootstrapTime we expected")
|
t.Fatal("not the BootstrapTime we expected")
|
||||||
}
|
}
|
||||||
if tk.FailedOperation == nil || *tk.FailedOperation != errorx.TopLevelOperation {
|
if tk.FailedOperation == nil || *tk.FailedOperation != errorsx.TopLevelOperation {
|
||||||
t.Fatal("not the FailedOperation we expected")
|
t.Fatal("not the FailedOperation we expected")
|
||||||
}
|
}
|
||||||
if tk.Failure == nil || !strings.HasSuffix(*tk.Failure, "interrupted") {
|
if tk.Failure == nil || !strings.HasSuffix(*tk.Failure, "interrupted") {
|
||||||
|
@ -236,7 +236,7 @@ func TestGetterWithCancelledContextNoFollowRedirects(t *testing.T) {
|
||||||
if tk.BootstrapTime != 0 {
|
if tk.BootstrapTime != 0 {
|
||||||
t.Fatal("not the BootstrapTime we expected")
|
t.Fatal("not the BootstrapTime we expected")
|
||||||
}
|
}
|
||||||
if tk.FailedOperation == nil || *tk.FailedOperation != errorx.TopLevelOperation {
|
if tk.FailedOperation == nil || *tk.FailedOperation != errorsx.TopLevelOperation {
|
||||||
t.Fatal("not the FailedOperation we expected")
|
t.Fatal("not the FailedOperation we expected")
|
||||||
}
|
}
|
||||||
if tk.Failure == nil || !strings.HasSuffix(*tk.Failure, "interrupted") {
|
if tk.Failure == nil || !strings.HasSuffix(*tk.Failure, "interrupted") {
|
||||||
|
@ -306,7 +306,7 @@ func TestGetterWithCancelledContextCannotStartTunnel(t *testing.T) {
|
||||||
if tk.BootstrapTime != 0 {
|
if tk.BootstrapTime != 0 {
|
||||||
t.Fatal("not the BootstrapTime we expected")
|
t.Fatal("not the BootstrapTime we expected")
|
||||||
}
|
}
|
||||||
if tk.FailedOperation == nil || *tk.FailedOperation != errorx.TopLevelOperation {
|
if tk.FailedOperation == nil || *tk.FailedOperation != errorsx.TopLevelOperation {
|
||||||
t.Fatal("not the FailedOperation we expected")
|
t.Fatal("not the FailedOperation we expected")
|
||||||
}
|
}
|
||||||
if tk.Failure == nil || *tk.Failure != "interrupted" {
|
if tk.Failure == nil || *tk.Failure != "interrupted" {
|
||||||
|
@ -361,7 +361,7 @@ func TestGetterWithCancelledContextUnknownResolverURL(t *testing.T) {
|
||||||
if tk.BootstrapTime != 0 {
|
if tk.BootstrapTime != 0 {
|
||||||
t.Fatal("not the BootstrapTime we expected")
|
t.Fatal("not the BootstrapTime we expected")
|
||||||
}
|
}
|
||||||
if tk.FailedOperation == nil || *tk.FailedOperation != errorx.TopLevelOperation {
|
if tk.FailedOperation == nil || *tk.FailedOperation != errorsx.TopLevelOperation {
|
||||||
t.Fatal("not the FailedOperation we expected")
|
t.Fatal("not the FailedOperation we expected")
|
||||||
}
|
}
|
||||||
if tk.Failure == nil || *tk.Failure != "unknown_failure: unsupported resolver scheme" {
|
if tk.Failure == nil || *tk.Failure != "unknown_failure: unsupported resolver scheme" {
|
||||||
|
@ -446,7 +446,7 @@ func TestGetterIntegrationHTTPS(t *testing.T) {
|
||||||
resolveStart = true
|
resolveStart = true
|
||||||
case "resolve_done":
|
case "resolve_done":
|
||||||
resolveDone = true
|
resolveDone = true
|
||||||
case errorx.ConnectOperation:
|
case errorsx.ConnectOperation:
|
||||||
connect = true
|
connect = true
|
||||||
case "tls_handshake_start":
|
case "tls_handshake_start":
|
||||||
tlsHandshakeStart = true
|
tlsHandshakeStart = true
|
||||||
|
@ -587,7 +587,7 @@ func TestGetterIntegrationTLSHandshake(t *testing.T) {
|
||||||
resolveStart = true
|
resolveStart = true
|
||||||
case "resolve_done":
|
case "resolve_done":
|
||||||
resolveDone = true
|
resolveDone = true
|
||||||
case errorx.ConnectOperation:
|
case errorsx.ConnectOperation:
|
||||||
connect = true
|
connect = true
|
||||||
case "tls_handshake_start":
|
case "tls_handshake_start":
|
||||||
tlsHandshakeStart = true
|
tlsHandshakeStart = true
|
||||||
|
@ -705,7 +705,7 @@ func TestGetterHTTPSWithTunnel(t *testing.T) {
|
||||||
resolveStart = true
|
resolveStart = true
|
||||||
case "resolve_done":
|
case "resolve_done":
|
||||||
resolveDone = true
|
resolveDone = true
|
||||||
case errorx.ConnectOperation:
|
case errorsx.ConnectOperation:
|
||||||
connect = true
|
connect = true
|
||||||
case "tls_handshake_start":
|
case "tls_handshake_start":
|
||||||
tlsHandshakeStart = true
|
tlsHandshakeStart = true
|
||||||
|
|
|
@ -11,7 +11,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/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
"github.com/ooni/probe-cli/v3/internal/iox"
|
"github.com/ooni/probe-cli/v3/internal/iox"
|
||||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||||
)
|
)
|
||||||
|
@ -19,9 +19,9 @@ import (
|
||||||
const httpRequestFailed = "http_request_failed"
|
const httpRequestFailed = "http_request_failed"
|
||||||
|
|
||||||
// ErrHTTPRequestFailed indicates that the HTTP request failed.
|
// ErrHTTPRequestFailed indicates that the HTTP request failed.
|
||||||
var ErrHTTPRequestFailed = &errorx.ErrWrapper{
|
var ErrHTTPRequestFailed = &errorsx.ErrWrapper{
|
||||||
Failure: httpRequestFailed,
|
Failure: httpRequestFailed,
|
||||||
Operation: errorx.TopLevelOperation,
|
Operation: errorsx.TopLevelOperation,
|
||||||
WrappedErr: errors.New(httpRequestFailed),
|
WrappedErr: errors.New(httpRequestFailed),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,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/httpx"
|
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
|
||||||
"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/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ControlRequest is the request that we send to the control
|
// ControlRequest is the request that we send to the control
|
||||||
|
@ -59,9 +59,9 @@ func Control(
|
||||||
}
|
}
|
||||||
sess.Logger().Infof("control for %s...", creq.HTTPRequest)
|
sess.Logger().Infof("control for %s...", creq.HTTPRequest)
|
||||||
// make sure error is wrapped
|
// make sure error is wrapped
|
||||||
err = errorx.SafeErrWrapperBuilder{
|
err = errorsx.SafeErrWrapperBuilder{
|
||||||
Error: clnt.PostJSON(ctx, "/", creq, &out),
|
Error: clnt.PostJSON(ctx, "/", creq, &out),
|
||||||
Operation: errorx.TopLevelOperation,
|
Operation: errorsx.TopLevelOperation,
|
||||||
}.MaybeBuild()
|
}.MaybeBuild()
|
||||||
sess.Logger().Infof("control for %s... %+v", creq.HTTPRequest, err)
|
sess.Logger().Infof("control for %s... %+v", creq.HTTPRequest, err)
|
||||||
(&out.DNS).FillASNs(sess)
|
(&out.DNS).FillASNs(sess)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DNSAnalysisResult contains the results of analysing comparing
|
// DNSAnalysisResult contains the results of analysing comparing
|
||||||
|
@ -44,7 +44,7 @@ func DNSAnalysis(URL *url.URL, measurement DNSLookupResult,
|
||||||
switch *control.DNS.Failure {
|
switch *control.DNS.Failure {
|
||||||
case DNSNameError: // the control returns this on NXDOMAIN error
|
case DNSNameError: // the control returns this on NXDOMAIN error
|
||||||
switch *measurement.Failure {
|
switch *measurement.Failure {
|
||||||
case errorx.FailureDNSNXDOMAINError:
|
case errorsx.FailureDNSNXDOMAINError:
|
||||||
out.DNSConsistency = &DNSConsistent
|
out.DNSConsistency = &DNSConsistent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,11 @@ import (
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"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/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDNSAnalysis(t *testing.T) {
|
func TestDNSAnalysis(t *testing.T) {
|
||||||
measurementFailure := errorx.FailureDNSNXDOMAINError
|
measurementFailure := errorsx.FailureDNSNXDOMAINError
|
||||||
controlFailure := webconnectivity.DNSNameError
|
controlFailure := webconnectivity.DNSNameError
|
||||||
eofFailure := io.EOF.Error()
|
eofFailure := io.EOF.Error()
|
||||||
type args struct {
|
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/experiment/webconnectivity/internal"
|
||||||
"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/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The following set of status flags identifies in a more nuanced way the
|
// 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
|
// If DNS failed with NXDOMAIN and the control DNS is consistent, then it
|
||||||
// means this website does not exist anymore.
|
// means this website does not exist anymore.
|
||||||
if tk.DNSExperimentFailure != nil &&
|
if tk.DNSExperimentFailure != nil &&
|
||||||
*tk.DNSExperimentFailure == errorx.FailureDNSNXDOMAINError &&
|
*tk.DNSExperimentFailure == errorsx.FailureDNSNXDOMAINError &&
|
||||||
tk.DNSConsistency != nil && *tk.DNSConsistency == DNSConsistent {
|
tk.DNSConsistency != nil && *tk.DNSConsistency == DNSConsistent {
|
||||||
// TODO(bassosimone): MK flags this as accessible. This result is debatable. We
|
// 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.
|
// 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.
|
// Otherwise, if DNS failed with NXDOMAIN, it's DNS based blocking.
|
||||||
// TODO(bassosimone): do we wanna include other errors here? Like timeout?
|
// TODO(bassosimone): do we wanna include other errors here? Like timeout?
|
||||||
if tk.DNSExperimentFailure != nil &&
|
if tk.DNSExperimentFailure != nil &&
|
||||||
*tk.DNSExperimentFailure == errorx.FailureDNSNXDOMAINError {
|
*tk.DNSExperimentFailure == errorsx.FailureDNSNXDOMAINError {
|
||||||
out.Accessible = &inaccessible
|
out.Accessible = &inaccessible
|
||||||
out.BlockingReason = &dns
|
out.BlockingReason = &dns
|
||||||
out.Status |= StatusAnomalyDNS | StatusExperimentDNS
|
out.Status |= StatusAnomalyDNS | StatusExperimentDNS
|
||||||
|
@ -184,41 +184,41 @@ func Summarize(tk *TestKeys) (out Summary) {
|
||||||
if tk.Requests[0].Failure != nil {
|
if tk.Requests[0].Failure != nil {
|
||||||
out.Status |= StatusExperimentHTTP
|
out.Status |= StatusExperimentHTTP
|
||||||
switch *tk.Requests[0].Failure {
|
switch *tk.Requests[0].Failure {
|
||||||
case errorx.FailureConnectionRefused:
|
case errorsx.FailureConnectionRefused:
|
||||||
// This is possibly because a subsequent connection to some
|
// This is possibly because a subsequent connection to some
|
||||||
// other endpoint has been blocked. We call this http-failure
|
// other endpoint has been blocked. We call this http-failure
|
||||||
// because this is what MK would actually do.
|
// because this is what MK would actually do.
|
||||||
out.BlockingReason = &httpFailure
|
out.BlockingReason = &httpFailure
|
||||||
out.Accessible = &inaccessible
|
out.Accessible = &inaccessible
|
||||||
out.Status |= StatusAnomalyConnect
|
out.Status |= StatusAnomalyConnect
|
||||||
case errorx.FailureConnectionReset:
|
case errorsx.FailureConnectionReset:
|
||||||
// We don't currently support TLS failures and we don't have a
|
// 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
|
// way to know if it was during TLS or later. So, for now we are
|
||||||
// going to call this error condition an http-failure.
|
// going to call this error condition an http-failure.
|
||||||
out.BlockingReason = &httpFailure
|
out.BlockingReason = &httpFailure
|
||||||
out.Accessible = &inaccessible
|
out.Accessible = &inaccessible
|
||||||
out.Status |= StatusAnomalyReadWrite
|
out.Status |= StatusAnomalyReadWrite
|
||||||
case errorx.FailureDNSNXDOMAINError:
|
case errorsx.FailureDNSNXDOMAINError:
|
||||||
// This is possibly because a subsequent resolution to
|
// This is possibly because a subsequent resolution to
|
||||||
// some other domain name has been blocked.
|
// some other domain name has been blocked.
|
||||||
out.BlockingReason = &dns
|
out.BlockingReason = &dns
|
||||||
out.Accessible = &inaccessible
|
out.Accessible = &inaccessible
|
||||||
out.Status |= StatusAnomalyDNS
|
out.Status |= StatusAnomalyDNS
|
||||||
case errorx.FailureEOFError:
|
case errorsx.FailureEOFError:
|
||||||
// We have seen this happening with TLS handshakes as well as
|
// We have seen this happening with TLS handshakes as well as
|
||||||
// sometimes with HTTP blocking. So http-failure.
|
// sometimes with HTTP blocking. So http-failure.
|
||||||
out.BlockingReason = &httpFailure
|
out.BlockingReason = &httpFailure
|
||||||
out.Accessible = &inaccessible
|
out.Accessible = &inaccessible
|
||||||
out.Status |= StatusAnomalyReadWrite
|
out.Status |= StatusAnomalyReadWrite
|
||||||
case errorx.FailureGenericTimeoutError:
|
case errorsx.FailureGenericTimeoutError:
|
||||||
// Alas, here we don't know whether it's connect or whether it's
|
// 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.
|
// perhaps the TLS handshake. So use the same classification used by MK.
|
||||||
out.BlockingReason = &httpFailure
|
out.BlockingReason = &httpFailure
|
||||||
out.Accessible = &inaccessible
|
out.Accessible = &inaccessible
|
||||||
out.Status |= StatusAnomalyUnknown
|
out.Status |= StatusAnomalyUnknown
|
||||||
case errorx.FailureSSLInvalidHostname,
|
case errorsx.FailureSSLInvalidHostname,
|
||||||
errorx.FailureSSLInvalidCertificate,
|
errorsx.FailureSSLInvalidCertificate,
|
||||||
errorx.FailureSSLUnknownAuthority:
|
errorsx.FailureSSLUnknownAuthority:
|
||||||
// We treat these three cases equally. Misconfiguration is a bit
|
// We treat these three cases equally. Misconfiguration is a bit
|
||||||
// less likely since we also checked with the control. Since there
|
// less likely since we also checked with the control. Since there
|
||||||
// is no TLS, for now we're going to call this http-failure.
|
// 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/google/go-cmp/cmp"
|
||||||
"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/netx/archival"
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSummarize(t *testing.T) {
|
func TestSummarize(t *testing.T) {
|
||||||
|
@ -18,14 +18,14 @@ func TestSummarize(t *testing.T) {
|
||||||
httpDiff = "http-diff"
|
httpDiff = "http-diff"
|
||||||
httpFailure = "http-failure"
|
httpFailure = "http-failure"
|
||||||
nilstring *string
|
nilstring *string
|
||||||
probeConnectionRefused = errorx.FailureConnectionRefused
|
probeConnectionRefused = errorsx.FailureConnectionRefused
|
||||||
probeConnectionReset = errorx.FailureConnectionReset
|
probeConnectionReset = errorsx.FailureConnectionReset
|
||||||
probeEOFError = errorx.FailureEOFError
|
probeEOFError = errorsx.FailureEOFError
|
||||||
probeNXDOMAIN = errorx.FailureDNSNXDOMAINError
|
probeNXDOMAIN = errorsx.FailureDNSNXDOMAINError
|
||||||
probeTimeout = errorx.FailureGenericTimeoutError
|
probeTimeout = errorsx.FailureGenericTimeoutError
|
||||||
probeSSLInvalidHost = errorx.FailureSSLInvalidHostname
|
probeSSLInvalidHost = errorsx.FailureSSLInvalidHostname
|
||||||
probeSSLInvalidCert = errorx.FailureSSLInvalidCertificate
|
probeSSLInvalidCert = errorsx.FailureSSLInvalidCertificate
|
||||||
probeSSLUnknownAuth = errorx.FailureSSLUnknownAuthority
|
probeSSLUnknownAuth = errorsx.FailureSSLUnknownAuthority
|
||||||
tcpIP = "tcp_ip"
|
tcpIP = "tcp_ip"
|
||||||
trueValue = true
|
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/experiment/webconnectivity"
|
||||||
"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/netx/archival"
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewExperimentMeasurer(t *testing.T) {
|
func TestNewExperimentMeasurer(t *testing.T) {
|
||||||
|
@ -69,10 +69,10 @@ func TestMeasureWithCancelledContext(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
tk := measurement.TestKeys.(*webconnectivity.TestKeys)
|
tk := measurement.TestKeys.(*webconnectivity.TestKeys)
|
||||||
if *tk.ControlFailure != errorx.FailureInterrupted {
|
if *tk.ControlFailure != errorsx.FailureInterrupted {
|
||||||
t.Fatal("unexpected control_failure")
|
t.Fatal("unexpected control_failure")
|
||||||
}
|
}
|
||||||
if *tk.DNSExperimentFailure != errorx.FailureInterrupted {
|
if *tk.DNSExperimentFailure != errorsx.FailureInterrupted {
|
||||||
t.Fatal("unexpected dns_experiment_failure")
|
t.Fatal("unexpected dns_experiment_failure")
|
||||||
}
|
}
|
||||||
if tk.HTTPExperimentFailure != nil {
|
if tk.HTTPExperimentFailure != nil {
|
||||||
|
|
|
@ -8,7 +8,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/engine/legacy/netx/oldhttptransport"
|
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/oldhttptransport"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
"golang.org/x/net/http2"
|
"golang.org/x/net/http2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -81,10 +81,10 @@ func (t *HTTPTransport) RoundTrip(
|
||||||
resp, err = t.roundTripper.RoundTrip(req)
|
resp, err = t.roundTripper.RoundTrip(req)
|
||||||
// For safety wrap the error as modelx.HTTPRoundTripOperation but this
|
// For safety wrap the error as modelx.HTTPRoundTripOperation but this
|
||||||
// will only be used if the error chain does not contain any
|
// will only be used if the error chain does not contain any
|
||||||
// other major operation failure. See errorx.ErrWrapper.
|
// other major operation failure. See errorsx.ErrWrapper.
|
||||||
err = errorx.SafeErrWrapperBuilder{
|
err = errorsx.SafeErrWrapperBuilder{
|
||||||
Error: err,
|
Error: err,
|
||||||
Operation: errorx.HTTPRoundTripOperation,
|
Operation: errorsx.HTTPRoundTripOperation,
|
||||||
}.MaybeBuild()
|
}.MaybeBuild()
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"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/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
"github.com/ooni/probe-cli/v3/internal/iox"
|
"github.com/ooni/probe-cli/v3/internal/iox"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ func TestHTTPTransportTimeout(t *testing.T) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("expected an error here")
|
t.Fatal("expected an error here")
|
||||||
}
|
}
|
||||||
if !strings.HasSuffix(err.Error(), errorx.FailureGenericTimeoutError) {
|
if !strings.HasSuffix(err.Error(), errorsx.FailureGenericTimeoutError) {
|
||||||
t.Fatal("not the error we expected")
|
t.Fatal("not the error we expected")
|
||||||
}
|
}
|
||||||
if resp != nil {
|
if resp != nil {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewTLSConnectionState(t *testing.T) {
|
func TestNewTLSConnectionState(t *testing.T) {
|
||||||
|
@ -61,7 +61,7 @@ func TestMeasurementRootWithMeasurementRootPanic(t *testing.T) {
|
||||||
|
|
||||||
func TestErrWrapperPublicAPI(t *testing.T) {
|
func TestErrWrapperPublicAPI(t *testing.T) {
|
||||||
child := errors.New("mocked error")
|
child := errors.New("mocked error")
|
||||||
wrapper := &errorx.ErrWrapper{
|
wrapper := &errorsx.ErrWrapper{
|
||||||
Failure: "moobar",
|
Failure: "moobar",
|
||||||
WrappedErr: child,
|
WrappedErr: child,
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,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/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
"github.com/ooni/probe-cli/v3/internal/iox"
|
"github.com/ooni/probe-cli/v3/internal/iox"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ func (t *TraceTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
majorOp = errorx.HTTPRoundTripOperation
|
majorOp = errorsx.HTTPRoundTripOperation
|
||||||
majorOpMu sync.Mutex
|
majorOpMu sync.Mutex
|
||||||
requestBody []byte
|
requestBody []byte
|
||||||
requestHeaders = http.Header{}
|
requestHeaders = http.Header{}
|
||||||
|
@ -103,7 +103,7 @@ func (t *TraceTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
tracer := &httptrace.ClientTrace{
|
tracer := &httptrace.ClientTrace{
|
||||||
TLSHandshakeStart: func() {
|
TLSHandshakeStart: func() {
|
||||||
majorOpMu.Lock()
|
majorOpMu.Lock()
|
||||||
majorOp = errorx.TLSHandshakeOperation
|
majorOp = errorsx.TLSHandshakeOperation
|
||||||
majorOpMu.Unlock()
|
majorOpMu.Unlock()
|
||||||
// Event emitted by net/http when DialTLS is not
|
// Event emitted by net/http when DialTLS is not
|
||||||
// configured in the http.Transport
|
// configured in the http.Transport
|
||||||
|
@ -116,9 +116,9 @@ func (t *TraceTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
TLSHandshakeDone: func(state tls.ConnectionState, err error) {
|
TLSHandshakeDone: func(state tls.ConnectionState, err error) {
|
||||||
// Wrapping the error even if we're not returning it because it may
|
// Wrapping the error even if we're not returning it because it may
|
||||||
// less confusing to users to see the wrapped name
|
// less confusing to users to see the wrapped name
|
||||||
err = errorx.SafeErrWrapperBuilder{
|
err = errorsx.SafeErrWrapperBuilder{
|
||||||
Error: err,
|
Error: err,
|
||||||
Operation: errorx.TLSHandshakeOperation,
|
Operation: errorsx.TLSHandshakeOperation,
|
||||||
}.MaybeBuild()
|
}.MaybeBuild()
|
||||||
durationSinceBeginning := time.Since(root.Beginning)
|
durationSinceBeginning := time.Since(root.Beginning)
|
||||||
// Event emitted by net/http when DialTLS is not
|
// Event emitted by net/http when DialTLS is not
|
||||||
|
@ -133,7 +133,7 @@ func (t *TraceTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
},
|
},
|
||||||
GotConn: func(info httptrace.GotConnInfo) {
|
GotConn: func(info httptrace.GotConnInfo) {
|
||||||
majorOpMu.Lock()
|
majorOpMu.Lock()
|
||||||
majorOp = errorx.HTTPRoundTripOperation
|
majorOp = errorsx.HTTPRoundTripOperation
|
||||||
majorOpMu.Unlock()
|
majorOpMu.Unlock()
|
||||||
root.Handler.OnMeasurement(modelx.Measurement{
|
root.Handler.OnMeasurement(modelx.Measurement{
|
||||||
HTTPConnectionReady: &modelx.HTTPConnectionReadyEvent{
|
HTTPConnectionReady: &modelx.HTTPConnectionReadyEvent{
|
||||||
|
@ -171,9 +171,9 @@ func (t *TraceTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
WroteRequest: func(info httptrace.WroteRequestInfo) {
|
WroteRequest: func(info httptrace.WroteRequestInfo) {
|
||||||
// Wrapping the error even if we're not returning it because it may
|
// Wrapping the error even if we're not returning it because it may
|
||||||
// less confusing to users to see the wrapped name
|
// less confusing to users to see the wrapped name
|
||||||
err := errorx.SafeErrWrapperBuilder{
|
err := errorsx.SafeErrWrapperBuilder{
|
||||||
Error: info.Err,
|
Error: info.Err,
|
||||||
Operation: errorx.HTTPRoundTripOperation,
|
Operation: errorsx.HTTPRoundTripOperation,
|
||||||
}.MaybeBuild()
|
}.MaybeBuild()
|
||||||
root.Handler.OnMeasurement(modelx.Measurement{
|
root.Handler.OnMeasurement(modelx.Measurement{
|
||||||
HTTPRequestDone: &modelx.HTTPRequestDoneEvent{
|
HTTPRequestDone: &modelx.HTTPRequestDoneEvent{
|
||||||
|
@ -207,7 +207,7 @@ func (t *TraceTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := t.roundTripper.RoundTrip(req)
|
resp, err := t.roundTripper.RoundTrip(req)
|
||||||
err = errorx.SafeErrWrapperBuilder{
|
err = errorsx.SafeErrWrapperBuilder{
|
||||||
Error: err,
|
Error: err,
|
||||||
Operation: majorOp,
|
Operation: majorOp,
|
||||||
}.MaybeBuild()
|
}.MaybeBuild()
|
||||||
|
|
|
@ -19,7 +19,7 @@ import (
|
||||||
"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/engine/legacy/oonitemplates"
|
"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/engine/model"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -418,7 +418,7 @@ func NewNetworkEventsList(results oonitemplates.Results) NetworkEventsList {
|
||||||
out = append(out, &NetworkEvent{
|
out = append(out, &NetworkEvent{
|
||||||
Address: in.Connect.RemoteAddress,
|
Address: in.Connect.RemoteAddress,
|
||||||
Failure: makeFailure(in.Connect.Error),
|
Failure: makeFailure(in.Connect.Error),
|
||||||
Operation: errorx.ConnectOperation,
|
Operation: errorsx.ConnectOperation,
|
||||||
T: in.Connect.DurationSinceBeginning.Seconds(),
|
T: in.Connect.DurationSinceBeginning.Seconds(),
|
||||||
})
|
})
|
||||||
// fallthrough
|
// fallthrough
|
||||||
|
@ -426,7 +426,7 @@ func NewNetworkEventsList(results oonitemplates.Results) NetworkEventsList {
|
||||||
if in.Read != nil {
|
if in.Read != nil {
|
||||||
out = append(out, &NetworkEvent{
|
out = append(out, &NetworkEvent{
|
||||||
Failure: makeFailure(in.Read.Error),
|
Failure: makeFailure(in.Read.Error),
|
||||||
Operation: errorx.ReadOperation,
|
Operation: errorsx.ReadOperation,
|
||||||
NumBytes: in.Read.NumBytes,
|
NumBytes: in.Read.NumBytes,
|
||||||
T: in.Read.DurationSinceBeginning.Seconds(),
|
T: in.Read.DurationSinceBeginning.Seconds(),
|
||||||
})
|
})
|
||||||
|
@ -435,7 +435,7 @@ func NewNetworkEventsList(results oonitemplates.Results) NetworkEventsList {
|
||||||
if in.Write != nil {
|
if in.Write != nil {
|
||||||
out = append(out, &NetworkEvent{
|
out = append(out, &NetworkEvent{
|
||||||
Failure: makeFailure(in.Write.Error),
|
Failure: makeFailure(in.Write.Error),
|
||||||
Operation: errorx.WriteOperation,
|
Operation: errorsx.WriteOperation,
|
||||||
NumBytes: in.Write.NumBytes,
|
NumBytes: in.Write.NumBytes,
|
||||||
T: in.Write.DurationSinceBeginning.Seconds(),
|
T: in.Write.DurationSinceBeginning.Seconds(),
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
|
|
||||||
"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/engine/legacy/oonitemplates"
|
"github.com/ooni/probe-cli/v3/internal/engine/legacy/oonitemplates"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewTCPConnectListEmpty(t *testing.T) {
|
func TestNewTCPConnectListEmpty(t *testing.T) {
|
||||||
|
@ -67,7 +67,7 @@ func TestNewTCPConnectListFailure(t *testing.T) {
|
||||||
Connects: []*modelx.ConnectEvent{
|
Connects: []*modelx.ConnectEvent{
|
||||||
{
|
{
|
||||||
RemoteAddress: "8.8.8.8:53",
|
RemoteAddress: "8.8.8.8:53",
|
||||||
Error: errors.New(errorx.FailureConnectionReset),
|
Error: errors.New(errorsx.FailureConnectionReset),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -80,7 +80,7 @@ func TestNewTCPConnectListFailure(t *testing.T) {
|
||||||
if out[0].Port != 53 {
|
if out[0].Port != 53 {
|
||||||
t.Fatal("unexpected out[0].Port")
|
t.Fatal("unexpected out[0].Port")
|
||||||
}
|
}
|
||||||
if *out[0].Status.Failure != errorx.FailureConnectionReset {
|
if *out[0].Status.Failure != errorsx.FailureConnectionReset {
|
||||||
t.Fatal("unexpected out[0].Failure")
|
t.Fatal("unexpected out[0].Failure")
|
||||||
}
|
}
|
||||||
if out[0].Status.Success != false {
|
if out[0].Status.Success != false {
|
||||||
|
@ -93,7 +93,7 @@ func TestNewTCPConnectListInvalidInput(t *testing.T) {
|
||||||
Connects: []*modelx.ConnectEvent{
|
Connects: []*modelx.ConnectEvent{
|
||||||
{
|
{
|
||||||
RemoteAddress: "8.8.8.8",
|
RemoteAddress: "8.8.8.8",
|
||||||
Error: errors.New(errorx.FailureConnectionReset),
|
Error: errors.New(errorsx.FailureConnectionReset),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -106,7 +106,7 @@ func TestNewTCPConnectListInvalidInput(t *testing.T) {
|
||||||
if out[0].Port != 0 {
|
if out[0].Port != 0 {
|
||||||
t.Fatal("unexpected out[0].Port")
|
t.Fatal("unexpected out[0].Port")
|
||||||
}
|
}
|
||||||
if *out[0].Status.Failure != errorx.FailureConnectionReset {
|
if *out[0].Status.Failure != errorsx.FailureConnectionReset {
|
||||||
t.Fatal("unexpected out[0].Failure")
|
t.Fatal("unexpected out[0].Failure")
|
||||||
}
|
}
|
||||||
if out[0].Status.Success != false {
|
if out[0].Status.Success != false {
|
||||||
|
@ -649,7 +649,7 @@ func TestNewDNSQueriesListSuccess(t *testing.T) {
|
||||||
TransportNetwork: "system",
|
TransportNetwork: "system",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Error: errors.New(errorx.FailureDNSNXDOMAINError),
|
Error: errors.New(errorsx.FailureDNSNXDOMAINError),
|
||||||
Hostname: "dns.googlex",
|
Hostname: "dns.googlex",
|
||||||
TransportNetwork: "system",
|
TransportNetwork: "system",
|
||||||
},
|
},
|
||||||
|
@ -768,7 +768,7 @@ func dnscheckbad(e DNSQueryEntry) error {
|
||||||
if e.Engine != "system" {
|
if e.Engine != "system" {
|
||||||
return errors.New("invalid engine")
|
return errors.New("invalid engine")
|
||||||
}
|
}
|
||||||
if *e.Failure != errorx.FailureDNSNXDOMAINError {
|
if *e.Failure != errorsx.FailureDNSNXDOMAINError {
|
||||||
return errors.New("invalid failure")
|
return errors.New("invalid failure")
|
||||||
}
|
}
|
||||||
if e.Hostname != "dns.googlex" {
|
if e.Hostname != "dns.googlex" {
|
||||||
|
@ -854,7 +854,7 @@ func TestNewNetworkEventsListGood(t *testing.T) {
|
||||||
if out[0].NumBytes != 0 {
|
if out[0].NumBytes != 0 {
|
||||||
t.Fatal("wrong out[0].NumBytes")
|
t.Fatal("wrong out[0].NumBytes")
|
||||||
}
|
}
|
||||||
if out[0].Operation != errorx.ConnectOperation {
|
if out[0].Operation != errorsx.ConnectOperation {
|
||||||
t.Fatal("wrong out[0].Operation")
|
t.Fatal("wrong out[0].Operation")
|
||||||
}
|
}
|
||||||
if !floatEquals(out[0].T, 0.010) {
|
if !floatEquals(out[0].T, 0.010) {
|
||||||
|
@ -870,7 +870,7 @@ func TestNewNetworkEventsListGood(t *testing.T) {
|
||||||
if out[1].NumBytes != 1789 {
|
if out[1].NumBytes != 1789 {
|
||||||
t.Fatal("wrong out[1].NumBytes")
|
t.Fatal("wrong out[1].NumBytes")
|
||||||
}
|
}
|
||||||
if out[1].Operation != errorx.ReadOperation {
|
if out[1].Operation != errorsx.ReadOperation {
|
||||||
t.Fatal("wrong out[1].Operation")
|
t.Fatal("wrong out[1].Operation")
|
||||||
}
|
}
|
||||||
if !floatEquals(out[1].T, 0.020) {
|
if !floatEquals(out[1].T, 0.020) {
|
||||||
|
@ -886,7 +886,7 @@ func TestNewNetworkEventsListGood(t *testing.T) {
|
||||||
if out[2].NumBytes != 17714 {
|
if out[2].NumBytes != 17714 {
|
||||||
t.Fatal("wrong out[2].NumBytes")
|
t.Fatal("wrong out[2].NumBytes")
|
||||||
}
|
}
|
||||||
if out[2].Operation != errorx.WriteOperation {
|
if out[2].Operation != errorsx.WriteOperation {
|
||||||
t.Fatal("wrong out[2].Operation")
|
t.Fatal("wrong out[2].Operation")
|
||||||
}
|
}
|
||||||
if !floatEquals(out[2].T, 0.030) {
|
if !floatEquals(out[2].T, 0.030) {
|
||||||
|
@ -933,7 +933,7 @@ func TestNewNetworkEventsListGoodUDPAndErrors(t *testing.T) {
|
||||||
if out[0].NumBytes != 0 {
|
if out[0].NumBytes != 0 {
|
||||||
t.Fatal("wrong out[0].NumBytes")
|
t.Fatal("wrong out[0].NumBytes")
|
||||||
}
|
}
|
||||||
if out[0].Operation != errorx.ConnectOperation {
|
if out[0].Operation != errorsx.ConnectOperation {
|
||||||
t.Fatal("wrong out[0].Operation")
|
t.Fatal("wrong out[0].Operation")
|
||||||
}
|
}
|
||||||
if !floatEquals(out[0].T, 0.010) {
|
if !floatEquals(out[0].T, 0.010) {
|
||||||
|
@ -949,7 +949,7 @@ func TestNewNetworkEventsListGoodUDPAndErrors(t *testing.T) {
|
||||||
if out[1].NumBytes != 1789 {
|
if out[1].NumBytes != 1789 {
|
||||||
t.Fatal("wrong out[1].NumBytes")
|
t.Fatal("wrong out[1].NumBytes")
|
||||||
}
|
}
|
||||||
if out[1].Operation != errorx.ReadOperation {
|
if out[1].Operation != errorsx.ReadOperation {
|
||||||
t.Fatal("wrong out[1].Operation")
|
t.Fatal("wrong out[1].Operation")
|
||||||
}
|
}
|
||||||
if !floatEquals(out[1].T, 0.020) {
|
if !floatEquals(out[1].T, 0.020) {
|
||||||
|
@ -965,7 +965,7 @@ func TestNewNetworkEventsListGoodUDPAndErrors(t *testing.T) {
|
||||||
if out[2].NumBytes != 17714 {
|
if out[2].NumBytes != 17714 {
|
||||||
t.Fatal("wrong out[2].NumBytes")
|
t.Fatal("wrong out[2].NumBytes")
|
||||||
}
|
}
|
||||||
if out[2].Operation != errorx.WriteOperation {
|
if out[2].Operation != errorsx.WriteOperation {
|
||||||
t.Fatal("wrong out[2].Operation")
|
t.Fatal("wrong out[2].Operation")
|
||||||
}
|
}
|
||||||
if !floatEquals(out[2].T, 0.030) {
|
if !floatEquals(out[2].T, 0.030) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
goptlib "git.torproject.org/pluggable-transports/goptlib.git"
|
goptlib "git.torproject.org/pluggable-transports/goptlib.git"
|
||||||
"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/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
@ -55,7 +55,7 @@ func TestDNSLookupCancellation(t *testing.T) {
|
||||||
if results.Error == nil {
|
if results.Error == nil {
|
||||||
t.Fatal("expected an error here")
|
t.Fatal("expected an error here")
|
||||||
}
|
}
|
||||||
if results.Error.Error() != errorx.FailureGenericTimeoutError {
|
if results.Error.Error() != errorsx.FailureGenericTimeoutError {
|
||||||
t.Fatal("not the error we expected")
|
t.Fatal("not the error we expected")
|
||||||
}
|
}
|
||||||
if len(results.Addresses) > 0 {
|
if len(results.Addresses) > 0 {
|
||||||
|
@ -170,7 +170,7 @@ func TestTLSConnectCancellation(t *testing.T) {
|
||||||
if results.Error == nil {
|
if results.Error == nil {
|
||||||
t.Fatal("expected an error here")
|
t.Fatal("expected an error here")
|
||||||
}
|
}
|
||||||
if results.Error.Error() != errorx.FailureGenericTimeoutError {
|
if results.Error.Error() != errorsx.FailureGenericTimeoutError {
|
||||||
t.Fatal("not the error we expected")
|
t.Fatal("not the error we expected")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ 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/netx/errorx"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExtSpec describes a data format extension
|
// ExtSpec describes a data format extension
|
||||||
|
@ -80,7 +80,7 @@ type TCPConnectEntry struct {
|
||||||
func NewTCPConnectList(begin time.Time, events []trace.Event) []TCPConnectEntry {
|
func NewTCPConnectList(begin time.Time, events []trace.Event) []TCPConnectEntry {
|
||||||
var out []TCPConnectEntry
|
var out []TCPConnectEntry
|
||||||
for _, event := range events {
|
for _, event := range events {
|
||||||
if event.Name != errorx.ConnectOperation {
|
if event.Name != errorsx.ConnectOperation {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if event.Proto != "tcp" {
|
if event.Proto != "tcp" {
|
||||||
|
@ -110,11 +110,11 @@ func NewFailure(err error) *string {
|
||||||
// The following code guarantees that the error is always wrapped even
|
// The following code guarantees that the error is always wrapped even
|
||||||
// when we could not actually hit our code that does the wrapping. A case
|
// when we could not actually hit our code that does the wrapping. A case
|
||||||
// in which this happen is with context deadline for HTTP.
|
// in which this happen is with context deadline for HTTP.
|
||||||
err = errorx.SafeErrWrapperBuilder{
|
err = errorsx.SafeErrWrapperBuilder{
|
||||||
Error: err,
|
Error: err,
|
||||||
Operation: errorx.TopLevelOperation,
|
Operation: errorsx.TopLevelOperation,
|
||||||
}.MaybeBuild()
|
}.MaybeBuild()
|
||||||
errWrapper := err.(*errorx.ErrWrapper)
|
errWrapper := err.(*errorsx.ErrWrapper)
|
||||||
s := errWrapper.Failure
|
s := errWrapper.Failure
|
||||||
if s == "" {
|
if s == "" {
|
||||||
s = "unknown_failure: errWrapper.Failure is empty"
|
s = "unknown_failure: errWrapper.Failure is empty"
|
||||||
|
@ -128,8 +128,8 @@ func NewFailedOperation(err error) *string {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
errWrapper *errorx.ErrWrapper
|
errWrapper *errorsx.ErrWrapper
|
||||||
s = errorx.UnknownOperation
|
s = errorsx.UnknownOperation
|
||||||
)
|
)
|
||||||
if errors.As(err, &errWrapper) && errWrapper.Operation != "" {
|
if errors.As(err, &errWrapper) && errWrapper.Operation != "" {
|
||||||
s = errWrapper.Operation
|
s = errWrapper.Operation
|
||||||
|
@ -474,7 +474,7 @@ type NetworkEvent struct {
|
||||||
func NewNetworkEventsList(begin time.Time, events []trace.Event) []NetworkEvent {
|
func NewNetworkEventsList(begin time.Time, events []trace.Event) []NetworkEvent {
|
||||||
var out []NetworkEvent
|
var out []NetworkEvent
|
||||||
for _, ev := range events {
|
for _, ev := range events {
|
||||||
if ev.Name == errorx.ConnectOperation {
|
if ev.Name == errorsx.ConnectOperation {
|
||||||
out = append(out, NetworkEvent{
|
out = append(out, NetworkEvent{
|
||||||
Address: ev.Address,
|
Address: ev.Address,
|
||||||
Failure: NewFailure(ev.Err),
|
Failure: NewFailure(ev.Err),
|
||||||
|
@ -484,7 +484,7 @@ func NewNetworkEventsList(begin time.Time, events []trace.Event) []NetworkEvent
|
||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if ev.Name == errorx.ReadOperation {
|
if ev.Name == errorsx.ReadOperation {
|
||||||
out = append(out, NetworkEvent{
|
out = append(out, NetworkEvent{
|
||||||
Failure: NewFailure(ev.Err),
|
Failure: NewFailure(ev.Err),
|
||||||
Operation: ev.Name,
|
Operation: ev.Name,
|
||||||
|
@ -493,7 +493,7 @@ func NewNetworkEventsList(begin time.Time, events []trace.Event) []NetworkEvent
|
||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if ev.Name == errorx.WriteOperation {
|
if ev.Name == errorsx.WriteOperation {
|
||||||
out = append(out, NetworkEvent{
|
out = append(out, NetworkEvent{
|
||||||
Failure: NewFailure(ev.Err),
|
Failure: NewFailure(ev.Err),
|
||||||
Operation: ev.Name,
|
Operation: ev.Name,
|
||||||
|
@ -502,7 +502,7 @@ func NewNetworkEventsList(begin time.Time, events []trace.Event) []NetworkEvent
|
||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if ev.Name == errorx.ReadFromOperation {
|
if ev.Name == errorsx.ReadFromOperation {
|
||||||
out = append(out, NetworkEvent{
|
out = append(out, NetworkEvent{
|
||||||
Address: ev.Address,
|
Address: ev.Address,
|
||||||
Failure: NewFailure(ev.Err),
|
Failure: NewFailure(ev.Err),
|
||||||
|
@ -512,7 +512,7 @@ func NewNetworkEventsList(begin time.Time, events []trace.Event) []NetworkEvent
|
||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if ev.Name == errorx.WriteToOperation {
|
if ev.Name == errorsx.WriteToOperation {
|
||||||
out = append(out, NetworkEvent{
|
out = append(out, NetworkEvent{
|
||||||
Address: ev.Address,
|
Address: ev.Address,
|
||||||
Failure: NewFailure(ev.Err),
|
Failure: NewFailure(ev.Err),
|
||||||
|
|
|
@ -14,8 +14,8 @@ import (
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"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/netx/archival"
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewTCPConnectList(t *testing.T) {
|
func TestNewTCPConnectList(t *testing.T) {
|
||||||
|
@ -47,20 +47,20 @@ func TestNewTCPConnectList(t *testing.T) {
|
||||||
}, {
|
}, {
|
||||||
Address: "8.8.8.8:853",
|
Address: "8.8.8.8:853",
|
||||||
Duration: 30 * time.Millisecond,
|
Duration: 30 * time.Millisecond,
|
||||||
Name: errorx.ConnectOperation,
|
Name: errorsx.ConnectOperation,
|
||||||
Proto: "tcp",
|
Proto: "tcp",
|
||||||
Time: begin.Add(130 * time.Millisecond),
|
Time: begin.Add(130 * time.Millisecond),
|
||||||
}, {
|
}, {
|
||||||
Address: "8.8.8.8:853",
|
Address: "8.8.8.8:853",
|
||||||
Duration: 55 * time.Millisecond,
|
Duration: 55 * time.Millisecond,
|
||||||
Name: errorx.ConnectOperation,
|
Name: errorsx.ConnectOperation,
|
||||||
Proto: "udp",
|
Proto: "udp",
|
||||||
Time: begin.Add(130 * time.Millisecond),
|
Time: begin.Add(130 * time.Millisecond),
|
||||||
}, {
|
}, {
|
||||||
Address: "8.8.4.4:53",
|
Address: "8.8.4.4:53",
|
||||||
Duration: 50 * time.Millisecond,
|
Duration: 50 * time.Millisecond,
|
||||||
Err: io.EOF,
|
Err: io.EOF,
|
||||||
Name: errorx.ConnectOperation,
|
Name: errorsx.ConnectOperation,
|
||||||
Proto: "tcp",
|
Proto: "tcp",
|
||||||
Time: begin.Add(180 * time.Millisecond),
|
Time: begin.Add(180 * time.Millisecond),
|
||||||
}},
|
}},
|
||||||
|
@ -314,14 +314,14 @@ func TestNewDNSQueriesList(t *testing.T) {
|
||||||
}, {
|
}, {
|
||||||
Address: "8.8.8.8:853",
|
Address: "8.8.8.8:853",
|
||||||
Duration: 30 * time.Millisecond,
|
Duration: 30 * time.Millisecond,
|
||||||
Name: errorx.ConnectOperation,
|
Name: errorsx.ConnectOperation,
|
||||||
Proto: "tcp",
|
Proto: "tcp",
|
||||||
Time: begin.Add(130 * time.Millisecond),
|
Time: begin.Add(130 * time.Millisecond),
|
||||||
}, {
|
}, {
|
||||||
Address: "8.8.4.4:53",
|
Address: "8.8.4.4:53",
|
||||||
Duration: 50 * time.Millisecond,
|
Duration: 50 * time.Millisecond,
|
||||||
Err: io.EOF,
|
Err: io.EOF,
|
||||||
Name: errorx.ConnectOperation,
|
Name: errorsx.ConnectOperation,
|
||||||
Proto: "tcp",
|
Proto: "tcp",
|
||||||
Time: begin.Add(180 * time.Millisecond),
|
Time: begin.Add(180 * time.Millisecond),
|
||||||
}},
|
}},
|
||||||
|
@ -371,7 +371,7 @@ func TestNewDNSQueriesList(t *testing.T) {
|
||||||
args: args{
|
args: args{
|
||||||
begin: begin,
|
begin: begin,
|
||||||
events: []trace.Event{{
|
events: []trace.Event{{
|
||||||
Err: &errorx.ErrWrapper{Failure: errorx.FailureDNSNXDOMAINError},
|
Err: &errorsx.ErrWrapper{Failure: errorsx.FailureDNSNXDOMAINError},
|
||||||
Hostname: "dns.google.com",
|
Hostname: "dns.google.com",
|
||||||
Name: "resolve_done",
|
Name: "resolve_done",
|
||||||
Time: begin.Add(200 * time.Millisecond),
|
Time: begin.Add(200 * time.Millisecond),
|
||||||
|
@ -380,14 +380,14 @@ func TestNewDNSQueriesList(t *testing.T) {
|
||||||
want: []archival.DNSQueryEntry{{
|
want: []archival.DNSQueryEntry{{
|
||||||
Answers: nil,
|
Answers: nil,
|
||||||
Failure: archival.NewFailure(
|
Failure: archival.NewFailure(
|
||||||
&errorx.ErrWrapper{Failure: errorx.FailureDNSNXDOMAINError}),
|
&errorsx.ErrWrapper{Failure: errorsx.FailureDNSNXDOMAINError}),
|
||||||
Hostname: "dns.google.com",
|
Hostname: "dns.google.com",
|
||||||
QueryType: "A",
|
QueryType: "A",
|
||||||
T: 0.2,
|
T: 0.2,
|
||||||
}, {
|
}, {
|
||||||
Answers: nil,
|
Answers: nil,
|
||||||
Failure: archival.NewFailure(
|
Failure: archival.NewFailure(
|
||||||
&errorx.ErrWrapper{Failure: errorx.FailureDNSNXDOMAINError}),
|
&errorsx.ErrWrapper{Failure: errorsx.FailureDNSNXDOMAINError}),
|
||||||
Hostname: "dns.google.com",
|
Hostname: "dns.google.com",
|
||||||
QueryType: "AAAA",
|
QueryType: "AAAA",
|
||||||
T: 0.2,
|
T: 0.2,
|
||||||
|
@ -425,35 +425,35 @@ func TestNewNetworkEventsList(t *testing.T) {
|
||||||
args: args{
|
args: args{
|
||||||
begin: begin,
|
begin: begin,
|
||||||
events: []trace.Event{{
|
events: []trace.Event{{
|
||||||
Name: errorx.ConnectOperation,
|
Name: errorsx.ConnectOperation,
|
||||||
Address: "8.8.8.8:853",
|
Address: "8.8.8.8:853",
|
||||||
Err: io.EOF,
|
Err: io.EOF,
|
||||||
Proto: "tcp",
|
Proto: "tcp",
|
||||||
Time: begin.Add(7 * time.Millisecond),
|
Time: begin.Add(7 * time.Millisecond),
|
||||||
}, {
|
}, {
|
||||||
Name: errorx.ReadOperation,
|
Name: errorsx.ReadOperation,
|
||||||
Err: context.Canceled,
|
Err: context.Canceled,
|
||||||
NumBytes: 7117,
|
NumBytes: 7117,
|
||||||
Time: begin.Add(11 * time.Millisecond),
|
Time: begin.Add(11 * time.Millisecond),
|
||||||
}, {
|
}, {
|
||||||
Address: "8.8.8.8:853",
|
Address: "8.8.8.8:853",
|
||||||
Name: errorx.ReadFromOperation,
|
Name: errorsx.ReadFromOperation,
|
||||||
Err: context.Canceled,
|
Err: context.Canceled,
|
||||||
NumBytes: 7117,
|
NumBytes: 7117,
|
||||||
Time: begin.Add(11 * time.Millisecond),
|
Time: begin.Add(11 * time.Millisecond),
|
||||||
}, {
|
}, {
|
||||||
Name: errorx.WriteOperation,
|
Name: errorsx.WriteOperation,
|
||||||
Err: websocket.ErrBadHandshake,
|
Err: websocket.ErrBadHandshake,
|
||||||
NumBytes: 4114,
|
NumBytes: 4114,
|
||||||
Time: begin.Add(14 * time.Millisecond),
|
Time: begin.Add(14 * time.Millisecond),
|
||||||
}, {
|
}, {
|
||||||
Address: "8.8.8.8:853",
|
Address: "8.8.8.8:853",
|
||||||
Name: errorx.WriteToOperation,
|
Name: errorsx.WriteToOperation,
|
||||||
Err: websocket.ErrBadHandshake,
|
Err: websocket.ErrBadHandshake,
|
||||||
NumBytes: 4114,
|
NumBytes: 4114,
|
||||||
Time: begin.Add(14 * time.Millisecond),
|
Time: begin.Add(14 * time.Millisecond),
|
||||||
}, {
|
}, {
|
||||||
Name: errorx.CloseOperation,
|
Name: errorsx.CloseOperation,
|
||||||
Err: websocket.ErrReadLimit,
|
Err: websocket.ErrReadLimit,
|
||||||
Time: begin.Add(17 * time.Millisecond),
|
Time: begin.Add(17 * time.Millisecond),
|
||||||
}},
|
}},
|
||||||
|
@ -461,34 +461,34 @@ func TestNewNetworkEventsList(t *testing.T) {
|
||||||
want: []archival.NetworkEvent{{
|
want: []archival.NetworkEvent{{
|
||||||
Address: "8.8.8.8:853",
|
Address: "8.8.8.8:853",
|
||||||
Failure: archival.NewFailure(io.EOF),
|
Failure: archival.NewFailure(io.EOF),
|
||||||
Operation: errorx.ConnectOperation,
|
Operation: errorsx.ConnectOperation,
|
||||||
Proto: "tcp",
|
Proto: "tcp",
|
||||||
T: 0.007,
|
T: 0.007,
|
||||||
}, {
|
}, {
|
||||||
Failure: archival.NewFailure(context.Canceled),
|
Failure: archival.NewFailure(context.Canceled),
|
||||||
NumBytes: 7117,
|
NumBytes: 7117,
|
||||||
Operation: errorx.ReadOperation,
|
Operation: errorsx.ReadOperation,
|
||||||
T: 0.011,
|
T: 0.011,
|
||||||
}, {
|
}, {
|
||||||
Address: "8.8.8.8:853",
|
Address: "8.8.8.8:853",
|
||||||
Failure: archival.NewFailure(context.Canceled),
|
Failure: archival.NewFailure(context.Canceled),
|
||||||
NumBytes: 7117,
|
NumBytes: 7117,
|
||||||
Operation: errorx.ReadFromOperation,
|
Operation: errorsx.ReadFromOperation,
|
||||||
T: 0.011,
|
T: 0.011,
|
||||||
}, {
|
}, {
|
||||||
Failure: archival.NewFailure(websocket.ErrBadHandshake),
|
Failure: archival.NewFailure(websocket.ErrBadHandshake),
|
||||||
NumBytes: 4114,
|
NumBytes: 4114,
|
||||||
Operation: errorx.WriteOperation,
|
Operation: errorsx.WriteOperation,
|
||||||
T: 0.014,
|
T: 0.014,
|
||||||
}, {
|
}, {
|
||||||
Address: "8.8.8.8:853",
|
Address: "8.8.8.8:853",
|
||||||
Failure: archival.NewFailure(websocket.ErrBadHandshake),
|
Failure: archival.NewFailure(websocket.ErrBadHandshake),
|
||||||
NumBytes: 4114,
|
NumBytes: 4114,
|
||||||
Operation: errorx.WriteToOperation,
|
Operation: errorsx.WriteToOperation,
|
||||||
T: 0.014,
|
T: 0.014,
|
||||||
}, {
|
}, {
|
||||||
Failure: archival.NewFailure(websocket.ErrReadLimit),
|
Failure: archival.NewFailure(websocket.ErrReadLimit),
|
||||||
Operation: errorx.CloseOperation,
|
Operation: errorsx.CloseOperation,
|
||||||
T: 0.017,
|
T: 0.017,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
|
@ -523,7 +523,7 @@ func TestNewTLSHandshakesList(t *testing.T) {
|
||||||
args: args{
|
args: args{
|
||||||
begin: begin,
|
begin: begin,
|
||||||
events: []trace.Event{{
|
events: []trace.Event{{
|
||||||
Name: errorx.CloseOperation,
|
Name: errorsx.CloseOperation,
|
||||||
Err: websocket.ErrReadLimit,
|
Err: websocket.ErrReadLimit,
|
||||||
Time: begin.Add(17 * time.Millisecond),
|
Time: begin.Add(17 * time.Millisecond),
|
||||||
}, {
|
}, {
|
||||||
|
@ -929,18 +929,18 @@ func TestNewFailure(t *testing.T) {
|
||||||
}, {
|
}, {
|
||||||
name: "when error is wrapped and failure meaningful",
|
name: "when error is wrapped and failure meaningful",
|
||||||
args: args{
|
args: args{
|
||||||
err: &errorx.ErrWrapper{
|
err: &errorsx.ErrWrapper{
|
||||||
Failure: errorx.FailureConnectionRefused,
|
Failure: errorsx.FailureConnectionRefused,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
want: func() *string {
|
want: func() *string {
|
||||||
s := errorx.FailureConnectionRefused
|
s := errorsx.FailureConnectionRefused
|
||||||
return &s
|
return &s
|
||||||
}(),
|
}(),
|
||||||
}, {
|
}, {
|
||||||
name: "when error is wrapped and failure is not meaningful",
|
name: "when error is wrapped and failure is not meaningful",
|
||||||
args: args{
|
args: args{
|
||||||
err: &errorx.ErrWrapper{},
|
err: &errorsx.ErrWrapper{},
|
||||||
},
|
},
|
||||||
want: func() *string {
|
want: func() *string {
|
||||||
s := "unknown_failure: errWrapper.Failure is empty"
|
s := "unknown_failure: errWrapper.Failure is empty"
|
||||||
|
@ -1002,24 +1002,24 @@ func TestNewFailedOperation(t *testing.T) {
|
||||||
}, {
|
}, {
|
||||||
name: "With wrapped error and non-empty operation",
|
name: "With wrapped error and non-empty operation",
|
||||||
args: args{
|
args: args{
|
||||||
err: &errorx.ErrWrapper{
|
err: &errorsx.ErrWrapper{
|
||||||
Failure: errorx.FailureConnectionRefused,
|
Failure: errorsx.FailureConnectionRefused,
|
||||||
Operation: errorx.ConnectOperation,
|
Operation: errorsx.ConnectOperation,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
want: (func() *string {
|
want: (func() *string {
|
||||||
s := errorx.ConnectOperation
|
s := errorsx.ConnectOperation
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
}, {
|
}, {
|
||||||
name: "With wrapped error and empty operation",
|
name: "With wrapped error and empty operation",
|
||||||
args: args{
|
args: args{
|
||||||
err: &errorx.ErrWrapper{
|
err: &errorsx.ErrWrapper{
|
||||||
Failure: errorx.FailureConnectionRefused,
|
Failure: errorsx.FailureConnectionRefused,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
want: (func() *string {
|
want: (func() *string {
|
||||||
s := errorx.UnknownOperation
|
s := errorsx.UnknownOperation
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
}, {
|
}, {
|
||||||
|
@ -1028,7 +1028,7 @@ func TestNewFailedOperation(t *testing.T) {
|
||||||
err: io.EOF,
|
err: io.EOF,
|
||||||
},
|
},
|
||||||
want: (func() *string {
|
want: (func() *string {
|
||||||
s := errorx.UnknownOperation
|
s := errorsx.UnknownOperation
|
||||||
return &s
|
return &s
|
||||||
})(),
|
})(),
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
// errorWrapperDialer is a dialer that performs err wrapping
|
// errorWrapperDialer is a dialer that performs err wrapping
|
||||||
|
@ -15,9 +15,9 @@ type errorWrapperDialer struct {
|
||||||
// DialContext implements Dialer.DialContext
|
// DialContext implements Dialer.DialContext
|
||||||
func (d *errorWrapperDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
|
func (d *errorWrapperDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
|
||||||
conn, err := d.Dialer.DialContext(ctx, network, address)
|
conn, err := d.Dialer.DialContext(ctx, network, address)
|
||||||
err = errorx.SafeErrWrapperBuilder{
|
err = errorsx.SafeErrWrapperBuilder{
|
||||||
Error: err,
|
Error: err,
|
||||||
Operation: errorx.ConnectOperation,
|
Operation: errorsx.ConnectOperation,
|
||||||
}.MaybeBuild()
|
}.MaybeBuild()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -33,9 +33,9 @@ type errorWrapperConn struct {
|
||||||
// Read implements net.Conn.Read
|
// Read implements net.Conn.Read
|
||||||
func (c *errorWrapperConn) Read(b []byte) (n int, err error) {
|
func (c *errorWrapperConn) Read(b []byte) (n int, err error) {
|
||||||
n, err = c.Conn.Read(b)
|
n, err = c.Conn.Read(b)
|
||||||
err = errorx.SafeErrWrapperBuilder{
|
err = errorsx.SafeErrWrapperBuilder{
|
||||||
Error: err,
|
Error: err,
|
||||||
Operation: errorx.ReadOperation,
|
Operation: errorsx.ReadOperation,
|
||||||
}.MaybeBuild()
|
}.MaybeBuild()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -43,9 +43,9 @@ func (c *errorWrapperConn) Read(b []byte) (n int, err error) {
|
||||||
// Write implements net.Conn.Write
|
// Write implements net.Conn.Write
|
||||||
func (c *errorWrapperConn) Write(b []byte) (n int, err error) {
|
func (c *errorWrapperConn) Write(b []byte) (n int, err error) {
|
||||||
n, err = c.Conn.Write(b)
|
n, err = c.Conn.Write(b)
|
||||||
err = errorx.SafeErrWrapperBuilder{
|
err = errorsx.SafeErrWrapperBuilder{
|
||||||
Error: err,
|
Error: err,
|
||||||
Operation: errorx.WriteOperation,
|
Operation: errorsx.WriteOperation,
|
||||||
}.MaybeBuild()
|
}.MaybeBuild()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,9 @@ func (c *errorWrapperConn) Write(b []byte) (n int, err error) {
|
||||||
// Close implements net.Conn.Close
|
// Close implements net.Conn.Close
|
||||||
func (c *errorWrapperConn) Close() (err error) {
|
func (c *errorWrapperConn) Close() (err error) {
|
||||||
err = c.Conn.Close()
|
err = c.Conn.Close()
|
||||||
err = errorx.SafeErrWrapperBuilder{
|
err = errorsx.SafeErrWrapperBuilder{
|
||||||
Error: err,
|
Error: err,
|
||||||
Operation: errorx.CloseOperation,
|
Operation: errorsx.CloseOperation,
|
||||||
}.MaybeBuild()
|
}.MaybeBuild()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
"github.com/ooni/probe-cli/v3/internal/netxmocks"
|
"github.com/ooni/probe-cli/v3/internal/netxmocks"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -22,21 +22,21 @@ func TestErrorWrapperFailure(t *testing.T) {
|
||||||
if conn != nil {
|
if conn != nil {
|
||||||
t.Fatal("expected a nil conn here")
|
t.Fatal("expected a nil conn here")
|
||||||
}
|
}
|
||||||
errorWrapperCheckErr(t, err, errorx.ConnectOperation)
|
errorWrapperCheckErr(t, err, errorsx.ConnectOperation)
|
||||||
}
|
}
|
||||||
|
|
||||||
func errorWrapperCheckErr(t *testing.T, err error, op string) {
|
func errorWrapperCheckErr(t *testing.T, err error, op string) {
|
||||||
if !errors.Is(err, io.EOF) {
|
if !errors.Is(err, io.EOF) {
|
||||||
t.Fatal("expected another error here")
|
t.Fatal("expected another error here")
|
||||||
}
|
}
|
||||||
var errWrapper *errorx.ErrWrapper
|
var errWrapper *errorsx.ErrWrapper
|
||||||
if !errors.As(err, &errWrapper) {
|
if !errors.As(err, &errWrapper) {
|
||||||
t.Fatal("cannot cast to ErrWrapper")
|
t.Fatal("cannot cast to ErrWrapper")
|
||||||
}
|
}
|
||||||
if errWrapper.Operation != op {
|
if errWrapper.Operation != op {
|
||||||
t.Fatal("unexpected Operation")
|
t.Fatal("unexpected Operation")
|
||||||
}
|
}
|
||||||
if errWrapper.Failure != errorx.FailureEOFError {
|
if errWrapper.Failure != errorsx.FailureEOFError {
|
||||||
t.Fatal("unexpected failure")
|
t.Fatal("unexpected failure")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,11 +69,11 @@ func TestErrorWrapperSuccess(t *testing.T) {
|
||||||
t.Fatal("expected non-nil conn here")
|
t.Fatal("expected non-nil conn here")
|
||||||
}
|
}
|
||||||
count, err := conn.Read(nil)
|
count, err := conn.Read(nil)
|
||||||
errorWrapperCheckIOResult(t, count, err, errorx.ReadOperation)
|
errorWrapperCheckIOResult(t, count, err, errorsx.ReadOperation)
|
||||||
count, err = conn.Write(nil)
|
count, err = conn.Write(nil)
|
||||||
errorWrapperCheckIOResult(t, count, err, errorx.WriteOperation)
|
errorWrapperCheckIOResult(t, count, err, errorsx.WriteOperation)
|
||||||
err = conn.Close()
|
err = conn.Close()
|
||||||
errorWrapperCheckErr(t, err, errorx.CloseOperation)
|
errorWrapperCheckErr(t, err, errorsx.CloseOperation)
|
||||||
}
|
}
|
||||||
|
|
||||||
func errorWrapperCheckIOResult(t *testing.T, count int, err error, op string) {
|
func errorWrapperCheckIOResult(t *testing.T, count int, err error, op string) {
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
// saverDialer saves events occurring during the dial
|
// saverDialer saves events occurring during the dial
|
||||||
|
@ -24,7 +24,7 @@ func (d *saverDialer) DialContext(ctx context.Context, network, address string)
|
||||||
Address: address,
|
Address: address,
|
||||||
Duration: stop.Sub(start),
|
Duration: stop.Sub(start),
|
||||||
Err: err,
|
Err: err,
|
||||||
Name: errorx.ConnectOperation,
|
Name: errorsx.ConnectOperation,
|
||||||
Proto: network,
|
Proto: network,
|
||||||
Time: stop,
|
Time: stop,
|
||||||
})
|
})
|
||||||
|
@ -61,7 +61,7 @@ func (c *saverConn) Read(p []byte) (int, error) {
|
||||||
Duration: stop.Sub(start),
|
Duration: stop.Sub(start),
|
||||||
Err: err,
|
Err: err,
|
||||||
NumBytes: count,
|
NumBytes: count,
|
||||||
Name: errorx.ReadOperation,
|
Name: errorsx.ReadOperation,
|
||||||
Time: stop,
|
Time: stop,
|
||||||
})
|
})
|
||||||
return count, err
|
return count, err
|
||||||
|
@ -76,7 +76,7 @@ func (c *saverConn) Write(p []byte) (int, error) {
|
||||||
Duration: stop.Sub(start),
|
Duration: stop.Sub(start),
|
||||||
Err: err,
|
Err: err,
|
||||||
NumBytes: count,
|
NumBytes: count,
|
||||||
Name: errorx.WriteOperation,
|
Name: errorsx.WriteOperation,
|
||||||
Time: stop,
|
Time: stop,
|
||||||
})
|
})
|
||||||
return count, err
|
return count, err
|
||||||
|
|
|
@ -8,8 +8,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
|
||||||
"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/netxmocks"
|
"github.com/ooni/probe-cli/v3/internal/netxmocks"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ func TestSaverDialerFailure(t *testing.T) {
|
||||||
if !errors.Is(ev[0].Err, expected) {
|
if !errors.Is(ev[0].Err, expected) {
|
||||||
t.Fatal("unexpected Err")
|
t.Fatal("unexpected Err")
|
||||||
}
|
}
|
||||||
if ev[0].Name != errorx.ConnectOperation {
|
if ev[0].Name != errorsx.ConnectOperation {
|
||||||
t.Fatal("unexpected Name")
|
t.Fatal("unexpected Name")
|
||||||
}
|
}
|
||||||
if ev[0].Proto != "tcp" {
|
if ev[0].Proto != "tcp" {
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
"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"
|
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
|
||||||
"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/iox"
|
"github.com/ooni/probe-cli/v3/internal/iox"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -78,10 +78,10 @@ func TestBogonResolutionNotBroken(t *testing.T) {
|
||||||
Logger: log.Log,
|
Logger: log.Log,
|
||||||
})
|
})
|
||||||
addrs, err := r.LookupHost(context.Background(), "www.google.com")
|
addrs, err := r.LookupHost(context.Background(), "www.google.com")
|
||||||
if !errors.Is(err, errorx.ErrDNSBogon) {
|
if !errors.Is(err, errorsx.ErrDNSBogon) {
|
||||||
t.Fatal("not the error we expected")
|
t.Fatal("not the error we expected")
|
||||||
}
|
}
|
||||||
if err.Error() != errorx.FailureDNSBogonError {
|
if err.Error() != errorsx.FailureDNSBogonError {
|
||||||
t.Fatal("error not correctly wrapped")
|
t.Fatal("error not correctly wrapped")
|
||||||
}
|
}
|
||||||
if len(addrs) > 0 {
|
if len(addrs) > 0 {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go"
|
"github.com/lucas-clemente/quic-go"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrorWrapperDialer is a dialer that performs quic err wrapping
|
// ErrorWrapperDialer is a dialer that performs quic err wrapping
|
||||||
|
@ -18,10 +18,10 @@ func (d ErrorWrapperDialer) DialContext(
|
||||||
ctx context.Context, network string, host string,
|
ctx context.Context, network string, host string,
|
||||||
tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlySession, error) {
|
tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlySession, error) {
|
||||||
sess, err := d.Dialer.DialContext(ctx, network, host, tlsCfg, cfg)
|
sess, err := d.Dialer.DialContext(ctx, network, host, tlsCfg, cfg)
|
||||||
err = errorx.SafeErrWrapperBuilder{
|
err = errorsx.SafeErrWrapperBuilder{
|
||||||
Classifier: errorx.ClassifyQUICFailure,
|
Classifier: errorsx.ClassifyQUICFailure,
|
||||||
Error: err,
|
Error: err,
|
||||||
Operation: errorx.QUICHandshakeOperation,
|
Operation: errorsx.QUICHandshakeOperation,
|
||||||
}.MaybeBuild()
|
}.MaybeBuild()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -8,8 +8,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go"
|
"github.com/lucas-clemente/quic-go"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/quicdialer"
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/quicdialer"
|
||||||
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -22,21 +22,21 @@ func TestErrorWrapperFailure(t *testing.T) {
|
||||||
if sess != nil {
|
if sess != nil {
|
||||||
t.Fatal("expected a nil sess here")
|
t.Fatal("expected a nil sess here")
|
||||||
}
|
}
|
||||||
errorWrapperCheckErr(t, err, errorx.QUICHandshakeOperation)
|
errorWrapperCheckErr(t, err, errorsx.QUICHandshakeOperation)
|
||||||
}
|
}
|
||||||
|
|
||||||
func errorWrapperCheckErr(t *testing.T, err error, op string) {
|
func errorWrapperCheckErr(t *testing.T, err error, op string) {
|
||||||
if !errors.Is(err, io.EOF) {
|
if !errors.Is(err, io.EOF) {
|
||||||
t.Fatal("expected another error here")
|
t.Fatal("expected another error here")
|
||||||
}
|
}
|
||||||
var errWrapper *errorx.ErrWrapper
|
var errWrapper *errorsx.ErrWrapper
|
||||||
if !errors.As(err, &errWrapper) {
|
if !errors.As(err, &errWrapper) {
|
||||||
t.Fatal("cannot cast to ErrWrapper")
|
t.Fatal("cannot cast to ErrWrapper")
|
||||||
}
|
}
|
||||||
if errWrapper.Operation != op {
|
if errWrapper.Operation != op {
|
||||||
t.Fatal("unexpected Operation")
|
t.Fatal("unexpected Operation")
|
||||||
}
|
}
|
||||||
if errWrapper.Failure != errorx.FailureEOFError {
|
if errWrapper.Failure != errorsx.FailureEOFError {
|
||||||
t.Fatal("unexpected failure")
|
t.Fatal("unexpected failure")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ func TestErrorWrapperInvalidCertificate(t *testing.T) {
|
||||||
if sess != nil {
|
if sess != nil {
|
||||||
t.Fatal("expected nil sess here")
|
t.Fatal("expected nil sess here")
|
||||||
}
|
}
|
||||||
if err.Error() != errorx.FailureSSLInvalidCertificate {
|
if err.Error() != errorsx.FailureSSLInvalidCertificate {
|
||||||
t.Fatal("unexpected failure")
|
t.Fatal("unexpected failure")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
// QUICListener listens for QUIC connections.
|
// QUICListener listens for QUIC connections.
|
||||||
|
@ -53,7 +53,7 @@ func (c saverUDPConn) WriteTo(p []byte, addr net.Addr) (int, error) {
|
||||||
Duration: stop.Sub(start),
|
Duration: stop.Sub(start),
|
||||||
Err: err,
|
Err: err,
|
||||||
NumBytes: count,
|
NumBytes: count,
|
||||||
Name: errorx.WriteToOperation,
|
Name: errorsx.WriteToOperation,
|
||||||
Time: stop,
|
Time: stop,
|
||||||
})
|
})
|
||||||
return count, err
|
return count, err
|
||||||
|
@ -73,7 +73,7 @@ func (c saverUDPConn) ReadMsgUDP(b, oob []byte) (int, int, int, *net.UDPAddr, er
|
||||||
Duration: stop.Sub(start),
|
Duration: stop.Sub(start),
|
||||||
Err: err,
|
Err: err,
|
||||||
NumBytes: n,
|
NumBytes: n,
|
||||||
Name: errorx.ReadFromOperation,
|
Name: errorsx.ReadFromOperation,
|
||||||
Time: stop,
|
Time: stop,
|
||||||
})
|
})
|
||||||
return n, oobn, flags, addr, err
|
return n, oobn, flags, addr, err
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go"
|
"github.com/lucas-clemente/quic-go"
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/quicdialer"
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/quicdialer"
|
||||||
"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/netxlite"
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ func TestSystemDialerSuccessWithReadWrite(t *testing.T) {
|
||||||
t.Fatal("unexpected NumBytes")
|
t.Fatal("unexpected NumBytes")
|
||||||
}
|
}
|
||||||
switch ev[idx].Name {
|
switch ev[idx].Name {
|
||||||
case errorx.ReadFromOperation, errorx.WriteToOperation:
|
case errorsx.ReadFromOperation, errorsx.WriteToOperation:
|
||||||
default:
|
default:
|
||||||
t.Fatal("unexpected Name")
|
t.Fatal("unexpected Name")
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ func (r BogonResolver) LookupHost(ctx context.Context, hostname string) ([]strin
|
||||||
addrs, err := r.Resolver.LookupHost(ctx, hostname)
|
addrs, err := r.Resolver.LookupHost(ctx, hostname)
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
if IsBogon(addr) {
|
if IsBogon(addr) {
|
||||||
return nil, errorx.ErrDNSBogon
|
return nil, errorsx.ErrDNSBogon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return addrs, err
|
return addrs, err
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/resolver"
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/resolver"
|
||||||
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestResolverIsBogon(t *testing.T) {
|
func TestResolverIsBogon(t *testing.T) {
|
||||||
|
@ -29,7 +29,7 @@ func TestBogonAwareResolverWithBogon(t *testing.T) {
|
||||||
Resolver: resolver.NewFakeResolverWithResult([]string{"127.0.0.1"}),
|
Resolver: resolver.NewFakeResolverWithResult([]string{"127.0.0.1"}),
|
||||||
}
|
}
|
||||||
addrs, err := r.LookupHost(context.Background(), "dns.google.com")
|
addrs, err := r.LookupHost(context.Background(), "dns.google.com")
|
||||||
if !errors.Is(err, errorx.ErrDNSBogon) {
|
if !errors.Is(err, errorsx.ErrDNSBogon) {
|
||||||
t.Fatal("not the error we expected")
|
t.Fatal("not the error we expected")
|
||||||
}
|
}
|
||||||
if len(addrs) > 0 {
|
if len(addrs) > 0 {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package resolver
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrorWrapperResolver is a Resolver that knows about wrapping errors.
|
// ErrorWrapperResolver is a Resolver that knows about wrapping errors.
|
||||||
|
@ -14,10 +14,10 @@ type ErrorWrapperResolver struct {
|
||||||
// LookupHost implements Resolver.LookupHost
|
// LookupHost implements Resolver.LookupHost
|
||||||
func (r ErrorWrapperResolver) LookupHost(ctx context.Context, hostname string) ([]string, error) {
|
func (r ErrorWrapperResolver) LookupHost(ctx context.Context, hostname string) ([]string, error) {
|
||||||
addrs, err := r.Resolver.LookupHost(ctx, hostname)
|
addrs, err := r.Resolver.LookupHost(ctx, hostname)
|
||||||
err = errorx.SafeErrWrapperBuilder{
|
err = errorsx.SafeErrWrapperBuilder{
|
||||||
Classifier: errorx.ClassifyResolveFailure,
|
Classifier: errorsx.ClassifyResolveFailure,
|
||||||
Error: err,
|
Error: err,
|
||||||
Operation: errorx.ResolveOperation,
|
Operation: errorsx.ResolveOperation,
|
||||||
}.MaybeBuild()
|
}.MaybeBuild()
|
||||||
return addrs, err
|
return addrs, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/resolver"
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/resolver"
|
||||||
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestErrorWrapperSuccess(t *testing.T) {
|
func TestErrorWrapperSuccess(t *testing.T) {
|
||||||
|
@ -32,14 +32,14 @@ func TestErrorWrapperFailure(t *testing.T) {
|
||||||
if addrs != nil {
|
if addrs != nil {
|
||||||
t.Fatal("expected nil addr here")
|
t.Fatal("expected nil addr here")
|
||||||
}
|
}
|
||||||
var errWrapper *errorx.ErrWrapper
|
var errWrapper *errorsx.ErrWrapper
|
||||||
if !errors.As(err, &errWrapper) {
|
if !errors.As(err, &errWrapper) {
|
||||||
t.Fatal("cannot properly cast the returned error")
|
t.Fatal("cannot properly cast the returned error")
|
||||||
}
|
}
|
||||||
if errWrapper.Failure != errorx.FailureDNSNXDOMAINError {
|
if errWrapper.Failure != errorsx.FailureDNSNXDOMAINError {
|
||||||
t.Fatal("unexpected failure")
|
t.Fatal("unexpected failure")
|
||||||
}
|
}
|
||||||
if errWrapper.Operation != errorx.ResolveOperation {
|
if errWrapper.Operation != errorsx.ResolveOperation {
|
||||||
t.Fatal("unexpected Operation")
|
t.Fatal("unexpected Operation")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,9 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"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/engine/netx/errorx"
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tlsdialer"
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/tlsdialer"
|
||||||
"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/netxlite"
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ func TestSaverTLSHandshakerSuccessWithReadWrite(t *testing.T) {
|
||||||
t.Fatal("unexpected NumBytes")
|
t.Fatal("unexpected NumBytes")
|
||||||
}
|
}
|
||||||
switch ev[idx].Name {
|
switch ev[idx].Name {
|
||||||
case errorx.ReadOperation, errorx.WriteOperation:
|
case errorsx.ReadOperation, errorsx.WriteOperation:
|
||||||
default:
|
default:
|
||||||
t.Fatal("unexpected Name")
|
t.Fatal("unexpected Name")
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"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/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UnderlyingDialer is the underlying dialer type.
|
// UnderlyingDialer is the underlying dialer type.
|
||||||
|
@ -32,10 +32,10 @@ func (h ErrorWrapperTLSHandshaker) Handshake(
|
||||||
ctx context.Context, conn net.Conn, config *tls.Config,
|
ctx context.Context, conn net.Conn, config *tls.Config,
|
||||||
) (net.Conn, tls.ConnectionState, error) {
|
) (net.Conn, tls.ConnectionState, error) {
|
||||||
tlsconn, state, err := h.TLSHandshaker.Handshake(ctx, conn, config)
|
tlsconn, state, err := h.TLSHandshaker.Handshake(ctx, conn, config)
|
||||||
err = errorx.SafeErrWrapperBuilder{
|
err = errorsx.SafeErrWrapperBuilder{
|
||||||
Classifier: errorx.ClassifyTLSFailure,
|
Classifier: errorsx.ClassifyTLSFailure,
|
||||||
Error: err,
|
Error: err,
|
||||||
Operation: errorx.TLSHandshakeOperation,
|
Operation: errorsx.TLSHandshakeOperation,
|
||||||
}.MaybeBuild()
|
}.MaybeBuild()
|
||||||
return tlsconn, state, err
|
return tlsconn, state, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@ 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/engine/netx/errorx"
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tlsdialer"
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/tlsdialer"
|
||||||
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -48,14 +48,14 @@ func TestErrorWrapperTLSHandshakerFailure(t *testing.T) {
|
||||||
if conn != nil {
|
if conn != nil {
|
||||||
t.Fatal("expected nil con here")
|
t.Fatal("expected nil con here")
|
||||||
}
|
}
|
||||||
var errWrapper *errorx.ErrWrapper
|
var errWrapper *errorsx.ErrWrapper
|
||||||
if !errors.As(err, &errWrapper) {
|
if !errors.As(err, &errWrapper) {
|
||||||
t.Fatal("cannot cast to ErrWrapper")
|
t.Fatal("cannot cast to ErrWrapper")
|
||||||
}
|
}
|
||||||
if errWrapper.Failure != errorx.FailureEOFError {
|
if errWrapper.Failure != errorsx.FailureEOFError {
|
||||||
t.Fatal("unexpected Failure")
|
t.Fatal("unexpected Failure")
|
||||||
}
|
}
|
||||||
if errWrapper.Operation != errorx.TLSHandshakeOperation {
|
if errWrapper.Operation != errorsx.TLSHandshakeOperation {
|
||||||
t.Fatal("unexpected Operation")
|
t.Fatal("unexpected Operation")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package errorx
|
package errorsx
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
import "golang.org/x/sys/unix"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package errorx
|
package errorsx
|
||||||
|
|
||||||
import "golang.org/x/sys/windows"
|
import "golang.org/x/sys/windows"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Package errorx contains error extensions
|
// Package errorsx contains error extensions.
|
||||||
package errorx
|
package errorsx
|
||||||
|
|
||||||
// TODO: eventually we want to re-structure the error classification code by clearly separating the layers where the error occur:
|
// TODO: eventually we want to re-structure the error classification code by clearly separating the layers where the error occur:
|
||||||
//
|
//
|
|
@ -1,4 +1,4 @@
|
||||||
package errorx
|
package errorsx
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
// reduceErrors finds a known error in a list of errors since
|
// reduceErrors finds a known error in a list of errors since
|
||||||
|
@ -27,7 +27,7 @@ func reduceErrors(errorslist []error) error {
|
||||||
// the user has no IPv6 connectivity, an IPv6 error is going to
|
// the user has no IPv6 connectivity, an IPv6 error is going to
|
||||||
// appear later in the list of errors.
|
// appear later in the list of errors.
|
||||||
for _, err := range errorslist {
|
for _, err := range errorslist {
|
||||||
var wrapper *errorx.ErrWrapper
|
var wrapper *errorsx.ErrWrapper
|
||||||
if errors.As(err, &wrapper) && !strings.HasPrefix(
|
if errors.As(err, &wrapper) && !strings.HasPrefix(
|
||||||
err.Error(), "unknown_failure",
|
err.Error(), "unknown_failure",
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestReduceErrors(t *testing.T) {
|
func TestReduceErrors(t *testing.T) {
|
||||||
|
@ -31,15 +31,15 @@ func TestReduceErrors(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("multiple errors with meaningful ones", func(t *testing.T) {
|
t.Run("multiple errors with meaningful ones", func(t *testing.T) {
|
||||||
err1 := errors.New("mocked error #1")
|
err1 := errors.New("mocked error #1")
|
||||||
err2 := &errorx.ErrWrapper{
|
err2 := &errorsx.ErrWrapper{
|
||||||
Failure: "unknown_failure: antani",
|
Failure: "unknown_failure: antani",
|
||||||
}
|
}
|
||||||
err3 := &errorx.ErrWrapper{
|
err3 := &errorsx.ErrWrapper{
|
||||||
Failure: errorx.FailureConnectionRefused,
|
Failure: errorsx.FailureConnectionRefused,
|
||||||
}
|
}
|
||||||
err4 := errors.New("mocked error #3")
|
err4 := errors.New("mocked error #3")
|
||||||
result := reduceErrors([]error{err1, err2, err3, err4})
|
result := reduceErrors([]error{err1, err2, err3, err4})
|
||||||
if result.Error() != errorx.FailureConnectionRefused {
|
if result.Error() != errorsx.FailureConnectionRefused {
|
||||||
t.Fatal("wrong result")
|
t.Fatal("wrong result")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user