refactor(netx): merge archival, trace, and the savers (#772)
This diff creates a new package under netx called tracex that contains everything we need to perform measurements using events tracing and postprocessing (which is the technique with which we implement most network experiments). The general idea here is to (1) create a unique package out of all of these packages; (2) clean up the code a bit (improve tests, docs, apply more recent code patterns); (3) move the resulting code as a toplevel package inside of internal. Once this is done, netx can be further refactored to avoid subpackages and we can search for more code to salvage/refactor. See https://github.com/ooni/probe/issues/2121
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
"github.com/montanaflynn/stats"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/humanize"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
@@ -64,7 +64,7 @@ type TestKeys struct {
|
||||
type runner struct {
|
||||
callbacks model.ExperimentCallbacks
|
||||
httpClient *http.Client
|
||||
saver *trace.Saver
|
||||
saver *tracex.Saver
|
||||
sess model.ExperimentSession
|
||||
tk *TestKeys
|
||||
}
|
||||
@@ -255,7 +255,7 @@ func (m Measurer) Run(
|
||||
) error {
|
||||
tk := new(TestKeys)
|
||||
measurement.TestKeys = tk
|
||||
saver := &trace.Saver{}
|
||||
saver := &tracex.Saver{}
|
||||
httpClient := &http.Client{
|
||||
Transport: netx.NewHTTPTransport(netx.Config{
|
||||
ContextByteCounting: true,
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/apex/log"
|
||||
"github.com/montanaflynn/stats"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
@@ -26,7 +26,7 @@ func TestRunnerLoopLocateFailure(t *testing.T) {
|
||||
err: expected,
|
||||
},
|
||||
},
|
||||
saver: new(trace.Saver),
|
||||
saver: new(tracex.Saver),
|
||||
sess: &mockable.Session{
|
||||
MockableLogger: log.Log,
|
||||
},
|
||||
@@ -56,7 +56,7 @@ func TestRunnerLoopNegotiateFailure(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
saver: new(trace.Saver),
|
||||
saver: new(tracex.Saver),
|
||||
sess: &mockable.Session{
|
||||
MockableLogger: log.Log,
|
||||
},
|
||||
@@ -93,7 +93,7 @@ func TestRunnerLoopMeasureFailure(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
saver: new(trace.Saver),
|
||||
saver: new(tracex.Saver),
|
||||
sess: &mockable.Session{
|
||||
MockableLogger: log.Log,
|
||||
},
|
||||
@@ -107,8 +107,8 @@ func TestRunnerLoopMeasureFailure(t *testing.T) {
|
||||
|
||||
func TestRunnerLoopCollectFailure(t *testing.T) {
|
||||
expected := errors.New("mocked error")
|
||||
saver := new(trace.Saver)
|
||||
saver.Write(trace.Event{Name: netxlite.ConnectOperation, Duration: 150 * time.Millisecond})
|
||||
saver := new(tracex.Saver)
|
||||
saver.Write(tracex.Event{Name: netxlite.ConnectOperation, Duration: 150 * time.Millisecond})
|
||||
r := runner{
|
||||
callbacks: model.NewPrinterCallbacks(log.Log),
|
||||
httpClient: &http.Client{
|
||||
@@ -151,8 +151,8 @@ func TestRunnerLoopCollectFailure(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRunnerLoopSuccess(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver.Write(trace.Event{Name: netxlite.ConnectOperation, Duration: 150 * time.Millisecond})
|
||||
saver := new(tracex.Saver)
|
||||
saver.Write(tracex.Event{Name: netxlite.ConnectOperation, Duration: 150 * time.Millisecond})
|
||||
r := runner{
|
||||
callbacks: model.NewPrinterCallbacks(log.Log),
|
||||
httpClient: &http.Client{
|
||||
|
||||
@@ -16,8 +16,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/atomicx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"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/trace"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
)
|
||||
@@ -168,15 +167,15 @@ func (m *Measurer) Run(
|
||||
// with IP addresses successfully, we just get back the IPs when we are
|
||||
// passing as input an IP address rather than a domain name.
|
||||
begin := measurement.MeasurementStartTimeSaved
|
||||
evsaver := new(trace.Saver)
|
||||
evsaver := new(tracex.Saver)
|
||||
resolver := netx.NewResolver(netx.Config{
|
||||
BogonIsError: true,
|
||||
Logger: sess.Logger(),
|
||||
ResolveSaver: evsaver,
|
||||
})
|
||||
addrs, err := m.lookupHost(ctx, URL.Hostname(), resolver)
|
||||
queries := archival.NewDNSQueriesList(begin, evsaver.Read())
|
||||
tk.BootstrapFailure = archival.NewFailure(err)
|
||||
queries := tracex.NewDNSQueriesList(begin, evsaver.Read())
|
||||
tk.BootstrapFailure = tracex.NewFailure(err)
|
||||
if len(queries) > 0 {
|
||||
// We get no queries in case we are resolving an IP address, since
|
||||
// the address resolver doesn't generate events
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/fbmessenger"
|
||||
"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/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
@@ -169,8 +169,8 @@ func TestComputeEndpointStatsTCPBlocking(t *testing.T) {
|
||||
TestKeys: urlgetter.TestKeys{
|
||||
Failure: &failure,
|
||||
FailedOperation: &operation,
|
||||
Queries: []archival.DNSQueryEntry{{
|
||||
Answers: []archival.DNSAnswerEntry{{
|
||||
Queries: []tracex.DNSQueryEntry{{
|
||||
Answers: []tracex.DNSAnswerEntry{{
|
||||
ASN: fbmessenger.FacebookASN,
|
||||
}},
|
||||
}},
|
||||
@@ -199,8 +199,8 @@ func TestComputeEndpointStatsDNSIsLying(t *testing.T) {
|
||||
TestKeys: urlgetter.TestKeys{
|
||||
Failure: &failure,
|
||||
FailedOperation: &operation,
|
||||
Queries: []archival.DNSQueryEntry{{
|
||||
Answers: []archival.DNSAnswerEntry{{
|
||||
Queries: []tracex.DNSQueryEntry{{
|
||||
Answers: []tracex.DNSAnswerEntry{{
|
||||
ASN: 0,
|
||||
}},
|
||||
}},
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/randx"
|
||||
@@ -34,11 +34,11 @@ type Config struct{}
|
||||
// Here we are emitting for the same set of test keys that are
|
||||
// produced by the MK implementation.
|
||||
type TestKeys struct {
|
||||
Agent string `json:"agent"`
|
||||
Failure *string `json:"failure"`
|
||||
Requests []archival.RequestEntry `json:"requests"`
|
||||
SOCKSProxy *string `json:"socksproxy"`
|
||||
Tampering Tampering `json:"tampering"`
|
||||
Agent string `json:"agent"`
|
||||
Failure *string `json:"failure"`
|
||||
Requests []tracex.RequestEntry `json:"requests"`
|
||||
SOCKSProxy *string `json:"socksproxy"`
|
||||
Tampering Tampering `json:"tampering"`
|
||||
}
|
||||
|
||||
// Tampering describes the detected forms of tampering.
|
||||
@@ -151,7 +151,7 @@ func (m Measurer) Run(
|
||||
// from that and then see to improve the robustness in the future.
|
||||
resp, data, err := Transact(txp, req.WithContext(ctx), callbacks)
|
||||
if err != nil {
|
||||
tk.Failure = archival.NewFailure(err)
|
||||
tk.Failure = tracex.NewFailure(err)
|
||||
tk.Requests[0].Failure = tk.Failure
|
||||
tk.Tampering.Total = true
|
||||
return nil // measurement did not fail, we measured tampering
|
||||
@@ -246,23 +246,23 @@ func (tk *TestKeys) FillTampering(
|
||||
}
|
||||
}
|
||||
|
||||
// NewRequestEntryList creates a new []archival.RequestEntry given a
|
||||
// NewRequestEntryList creates a new []tracex.RequestEntry given a
|
||||
// specific *http.Request and headers with random case.
|
||||
func NewRequestEntryList(req *http.Request, headers map[string]string) (out []archival.RequestEntry) {
|
||||
out = []archival.RequestEntry{{
|
||||
Request: archival.HTTPRequest{
|
||||
Headers: make(map[string]archival.MaybeBinaryValue),
|
||||
HeadersList: []archival.HTTPHeader{},
|
||||
func NewRequestEntryList(req *http.Request, headers map[string]string) (out []tracex.RequestEntry) {
|
||||
out = []tracex.RequestEntry{{
|
||||
Request: tracex.HTTPRequest{
|
||||
Headers: make(map[string]tracex.MaybeBinaryValue),
|
||||
HeadersList: []tracex.HTTPHeader{},
|
||||
Method: req.Method,
|
||||
URL: req.URL.String(),
|
||||
},
|
||||
}}
|
||||
for key, value := range headers {
|
||||
// Using the random capitalization headers here
|
||||
mbv := archival.MaybeBinaryValue{Value: value}
|
||||
mbv := tracex.MaybeBinaryValue{Value: value}
|
||||
out[0].Request.Headers[key] = mbv
|
||||
out[0].Request.HeadersList = append(out[0].Request.HeadersList,
|
||||
archival.HTTPHeader{Key: key, Value: mbv})
|
||||
tracex.HTTPHeader{Key: key, Value: mbv})
|
||||
}
|
||||
sort.Slice(out[0].Request.HeadersList, func(i, j int) bool {
|
||||
return out[0].Request.HeadersList[i].Key < out[0].Request.HeadersList[j].Key
|
||||
@@ -270,19 +270,19 @@ func NewRequestEntryList(req *http.Request, headers map[string]string) (out []ar
|
||||
return
|
||||
}
|
||||
|
||||
// NewHTTPResponse creates a new archival.HTTPResponse given a
|
||||
// NewHTTPResponse creates a new tracex.HTTPResponse given a
|
||||
// specific *http.Response instance and its body.
|
||||
func NewHTTPResponse(resp *http.Response, data []byte) (out archival.HTTPResponse) {
|
||||
out = archival.HTTPResponse{
|
||||
Body: archival.HTTPBody{Value: string(data)},
|
||||
func NewHTTPResponse(resp *http.Response, data []byte) (out tracex.HTTPResponse) {
|
||||
out = tracex.HTTPResponse{
|
||||
Body: tracex.HTTPBody{Value: string(data)},
|
||||
Code: int64(resp.StatusCode),
|
||||
Headers: make(map[string]archival.MaybeBinaryValue),
|
||||
HeadersList: []archival.HTTPHeader{},
|
||||
Headers: make(map[string]tracex.MaybeBinaryValue),
|
||||
HeadersList: []tracex.HTTPHeader{},
|
||||
}
|
||||
for key := range resp.Header {
|
||||
mbv := archival.MaybeBinaryValue{Value: resp.Header.Get(key)}
|
||||
mbv := tracex.MaybeBinaryValue{Value: resp.Header.Get(key)}
|
||||
out.Headers[key] = mbv
|
||||
out.HeadersList = append(out.HeadersList, archival.HTTPHeader{Key: key, Value: mbv})
|
||||
out.HeadersList = append(out.HeadersList, tracex.HTTPHeader{Key: key, Value: mbv})
|
||||
}
|
||||
sort.Slice(out.HeadersList, func(i, j int) bool {
|
||||
return out.HeadersList[i].Key < out.HeadersList[j].Key
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/hhfm"
|
||||
"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/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
@@ -554,7 +554,7 @@ func TestTestKeys_FillTampering(t *testing.T) {
|
||||
type fields struct {
|
||||
Agent string
|
||||
Failure *string
|
||||
Requests []archival.RequestEntry
|
||||
Requests []tracex.RequestEntry
|
||||
SOCKSProxy *string
|
||||
Tampering hhfm.Tampering
|
||||
}
|
||||
@@ -689,7 +689,7 @@ func TestNewRequestEntryList(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantOut []archival.RequestEntry
|
||||
wantOut []tracex.RequestEntry
|
||||
}{{
|
||||
name: "common case",
|
||||
args: args{
|
||||
@@ -706,16 +706,16 @@ func TestNewRequestEntryList(t *testing.T) {
|
||||
"User-aGENT": "foo/1.0",
|
||||
},
|
||||
},
|
||||
wantOut: []archival.RequestEntry{{
|
||||
Request: archival.HTTPRequest{
|
||||
HeadersList: []archival.HTTPHeader{{
|
||||
wantOut: []tracex.RequestEntry{{
|
||||
Request: tracex.HTTPRequest{
|
||||
HeadersList: []tracex.HTTPHeader{{
|
||||
Key: "ContENt-tYPE",
|
||||
Value: archival.MaybeBinaryValue{Value: "text/plain"},
|
||||
Value: tracex.MaybeBinaryValue{Value: "text/plain"},
|
||||
}, {
|
||||
Key: "User-aGENT",
|
||||
Value: archival.MaybeBinaryValue{Value: "foo/1.0"},
|
||||
Value: tracex.MaybeBinaryValue{Value: "foo/1.0"},
|
||||
}},
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"ContENt-tYPE": {Value: "text/plain"},
|
||||
"User-aGENT": {Value: "foo/1.0"},
|
||||
},
|
||||
@@ -735,11 +735,11 @@ func TestNewRequestEntryList(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
wantOut: []archival.RequestEntry{{
|
||||
Request: archival.HTTPRequest{
|
||||
wantOut: []tracex.RequestEntry{{
|
||||
Request: tracex.HTTPRequest{
|
||||
Method: "GeT",
|
||||
Headers: make(map[string]archival.MaybeBinaryValue),
|
||||
HeadersList: []archival.HTTPHeader{},
|
||||
Headers: make(map[string]tracex.MaybeBinaryValue),
|
||||
HeadersList: []tracex.HTTPHeader{},
|
||||
URL: "http://10.0.0.1/",
|
||||
},
|
||||
}},
|
||||
@@ -762,7 +762,7 @@ func TestNewHTTPResponse(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantOut archival.HTTPResponse
|
||||
wantOut tracex.HTTPResponse
|
||||
}{{
|
||||
name: "common case",
|
||||
args: args{
|
||||
@@ -775,17 +775,17 @@ func TestNewHTTPResponse(t *testing.T) {
|
||||
},
|
||||
data: []byte("deadbeef"),
|
||||
},
|
||||
wantOut: archival.HTTPResponse{
|
||||
Body: archival.MaybeBinaryValue{Value: "deadbeef"},
|
||||
wantOut: tracex.HTTPResponse{
|
||||
Body: tracex.MaybeBinaryValue{Value: "deadbeef"},
|
||||
Code: 200,
|
||||
HeadersList: []archival.HTTPHeader{{
|
||||
HeadersList: []tracex.HTTPHeader{{
|
||||
Key: "Content-Type",
|
||||
Value: archival.MaybeBinaryValue{Value: "text/plain"},
|
||||
Value: tracex.MaybeBinaryValue{Value: "text/plain"},
|
||||
}, {
|
||||
Key: "User-Agent",
|
||||
Value: archival.MaybeBinaryValue{Value: "foo/1.0"},
|
||||
Value: tracex.MaybeBinaryValue{Value: "foo/1.0"},
|
||||
}},
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Content-Type": {Value: "text/plain"},
|
||||
"User-Agent": {Value: "foo/1.0"},
|
||||
},
|
||||
@@ -795,11 +795,11 @@ func TestNewHTTPResponse(t *testing.T) {
|
||||
args: args{
|
||||
resp: &http.Response{StatusCode: 200},
|
||||
},
|
||||
wantOut: archival.HTTPResponse{
|
||||
Body: archival.MaybeBinaryValue{Value: ""},
|
||||
wantOut: tracex.HTTPResponse{
|
||||
Body: tracex.MaybeBinaryValue{Value: ""},
|
||||
Code: 200,
|
||||
HeadersList: []archival.HTTPHeader{},
|
||||
Headers: map[string]archival.MaybeBinaryValue{},
|
||||
HeadersList: []tracex.HTTPHeader{},
|
||||
Headers: map[string]tracex.MaybeBinaryValue{},
|
||||
},
|
||||
}}
|
||||
for _, tt := range tests {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"time"
|
||||
|
||||
"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/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/randx"
|
||||
@@ -29,11 +29,11 @@ type Config struct{}
|
||||
|
||||
// TestKeys contains the experiment test keys.
|
||||
type TestKeys struct {
|
||||
FailureList []*string `json:"failure_list"`
|
||||
Received []archival.MaybeBinaryValue `json:"received"`
|
||||
Sent []string `json:"sent"`
|
||||
TamperingList []bool `json:"tampering_list"`
|
||||
Tampering bool `json:"tampering"`
|
||||
FailureList []*string `json:"failure_list"`
|
||||
Received []tracex.MaybeBinaryValue `json:"received"`
|
||||
Sent []string `json:"sent"`
|
||||
TamperingList []bool `json:"tampering_list"`
|
||||
Tampering bool `json:"tampering"`
|
||||
}
|
||||
|
||||
// NewExperimentMeasurer creates a new ExperimentMeasurer.
|
||||
@@ -123,7 +123,7 @@ func (m Measurer) Run(
|
||||
}
|
||||
continue
|
||||
}
|
||||
failure := archival.NewFailure(result.Err)
|
||||
failure := tracex.NewFailure(result.Err)
|
||||
tk.FailureList = append(tk.FailureList, failure)
|
||||
tk.Received = append(tk.Received, result.Received)
|
||||
tk.Sent = append(tk.Sent, result.Sent)
|
||||
@@ -150,7 +150,7 @@ type MethodConfig struct {
|
||||
type MethodResult struct {
|
||||
Err error
|
||||
Name string
|
||||
Received archival.MaybeBinaryValue
|
||||
Received tracex.MaybeBinaryValue
|
||||
Sent string
|
||||
Tampering bool
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/hirl"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"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/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
@@ -149,7 +149,7 @@ func (FakeMethodSuccessful) Name() string {
|
||||
func (meth FakeMethodSuccessful) Run(ctx context.Context, config hirl.MethodConfig) {
|
||||
config.Out <- hirl.MethodResult{
|
||||
Name: meth.Name(),
|
||||
Received: archival.MaybeBinaryValue{Value: "antani"},
|
||||
Received: tracex.MaybeBinaryValue{Value: "antani"},
|
||||
Sent: "antani",
|
||||
Tampering: false,
|
||||
}
|
||||
@@ -164,7 +164,7 @@ func (FakeMethodFailure) Name() string {
|
||||
func (meth FakeMethodFailure) Run(ctx context.Context, config hirl.MethodConfig) {
|
||||
config.Out <- hirl.MethodResult{
|
||||
Name: meth.Name(),
|
||||
Received: archival.MaybeBinaryValue{Value: "antani"},
|
||||
Received: tracex.MaybeBinaryValue{Value: "antani"},
|
||||
Sent: "melandri",
|
||||
Tampering: true,
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
_ "crypto/sha256"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
@@ -102,7 +102,7 @@ func makeResponse(resp *responseInfo) *SinglePingResponse {
|
||||
}
|
||||
return &SinglePingResponse{
|
||||
Data: data,
|
||||
Failure: archival.NewFailure(resp.err),
|
||||
Failure: tracex.NewFailure(resp.err),
|
||||
T: resp.t,
|
||||
SupportedVersions: resp.versions,
|
||||
}
|
||||
@@ -273,7 +273,7 @@ L:
|
||||
tk.Pings = append(tk.Pings, &SinglePing{
|
||||
ConnIdDst: req.dstID,
|
||||
ConnIdSrc: req.srcID,
|
||||
Failure: archival.NewFailure(req.err),
|
||||
Failure: tracex.NewFailure(req.err),
|
||||
Request: &model.ArchivalMaybeBinaryData{Value: string(req.raw)},
|
||||
T: req.t,
|
||||
})
|
||||
@@ -313,7 +313,7 @@ L:
|
||||
tk.Pings = append(tk.Pings, &SinglePing{
|
||||
ConnIdDst: ping.request.dstID,
|
||||
ConnIdSrc: ping.request.srcID,
|
||||
Failure: archival.NewFailure(timeoutErr),
|
||||
Failure: tracex.NewFailure(timeoutErr),
|
||||
Request: &model.ArchivalMaybeBinaryData{Value: string(ping.request.raw)},
|
||||
T: ping.request.t,
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
@@ -132,7 +132,7 @@ func (tk *TestKeys) updateTransportStatus(openvpnGatewayCount, obfs4GatewayCount
|
||||
}
|
||||
|
||||
func newGatewayConnection(
|
||||
tcpConnect archival.TCPConnectEntry, transportType string) *GatewayConnection {
|
||||
tcpConnect tracex.TCPConnectEntry, transportType string) *GatewayConnection {
|
||||
return &GatewayConnection{
|
||||
IP: tcpConnect.IP,
|
||||
Port: tcpConnect.Port,
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/riseupvpn"
|
||||
"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/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
@@ -735,11 +735,11 @@ func generateMockGetter(requestResponse map[string]string, responseStatus map[st
|
||||
responseStatus = 0
|
||||
}
|
||||
|
||||
tcpConnect := archival.TCPConnectEntry{
|
||||
tcpConnect := tracex.TCPConnectEntry{
|
||||
// use some dummy IP/Port combination for URLs, we don't do DNS resolution
|
||||
IP: "123.456.234.123",
|
||||
Port: 443,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Success: isSuccessStatus,
|
||||
Blocked: &isBlocked,
|
||||
Failure: failure,
|
||||
@@ -759,21 +759,21 @@ func generateMockGetter(requestResponse map[string]string, responseStatus map[st
|
||||
FailedOperation: failedOperation,
|
||||
HTTPResponseStatus: responseStatus,
|
||||
HTTPResponseBody: responseBody,
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: failure,
|
||||
Request: archival.HTTPRequest{
|
||||
Request: tracex.HTTPRequest{
|
||||
URL: url,
|
||||
Body: archival.MaybeBinaryValue{},
|
||||
Body: tracex.MaybeBinaryValue{},
|
||||
BodyIsTruncated: false,
|
||||
},
|
||||
Response: archival.HTTPResponse{
|
||||
Body: archival.HTTPBody{
|
||||
Response: tracex.HTTPResponse{
|
||||
Body: tracex.HTTPBody{
|
||||
Value: responseBody,
|
||||
},
|
||||
BodyIsTruncated: false,
|
||||
}},
|
||||
},
|
||||
TCPConnect: []archival.TCPConnectEntry{tcpConnect},
|
||||
TCPConnect: []tracex.TCPConnectEntry{tcpConnect},
|
||||
}
|
||||
return tk, nil
|
||||
}
|
||||
|
||||
@@ -12,8 +12,7 @@ import (
|
||||
"time"
|
||||
|
||||
"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/trace"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/pion/stun"
|
||||
@@ -32,15 +31,15 @@ type Config struct {
|
||||
|
||||
// TestKeys contains the experiment's result.
|
||||
type TestKeys struct {
|
||||
Endpoint string `json:"endpoint"`
|
||||
Failure *string `json:"failure"`
|
||||
NetworkEvents []archival.NetworkEvent `json:"network_events"`
|
||||
Queries []archival.DNSQueryEntry `json:"queries"`
|
||||
Endpoint string `json:"endpoint"`
|
||||
Failure *string `json:"failure"`
|
||||
NetworkEvents []tracex.NetworkEvent `json:"network_events"`
|
||||
Queries []tracex.DNSQueryEntry `json:"queries"`
|
||||
}
|
||||
|
||||
func registerExtensions(m *model.Measurement) {
|
||||
archival.ExtDNS.AddTo(m)
|
||||
archival.ExtNetevents.AddTo(m)
|
||||
tracex.ExtDNS.AddTo(m)
|
||||
tracex.ExtNetevents.AddTo(m)
|
||||
}
|
||||
|
||||
// Measurer performs the measurement.
|
||||
@@ -113,7 +112,7 @@ func (tk *TestKeys) run(
|
||||
defer callbacks.OnProgress(
|
||||
1, fmt.Sprintf("stunreachability: measuring: %s... done", endpoint))
|
||||
tk.Endpoint = endpoint
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
begin := time.Now()
|
||||
err := tk.do(ctx, config, netx.NewDialer(netx.Config{
|
||||
ContextByteCounting: true,
|
||||
@@ -124,10 +123,10 @@ func (tk *TestKeys) run(
|
||||
}), endpoint)
|
||||
events := saver.Read()
|
||||
tk.NetworkEvents = append(
|
||||
tk.NetworkEvents, archival.NewNetworkEventsList(begin, events)...,
|
||||
tk.NetworkEvents, tracex.NewNetworkEventsList(begin, events)...,
|
||||
)
|
||||
tk.Queries = append(
|
||||
tk.Queries, archival.NewDNSQueriesList(begin, events)...,
|
||||
tk.Queries, tracex.NewDNSQueriesList(begin, events)...,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/tlstool/internal"
|
||||
"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/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
)
|
||||
@@ -101,7 +101,7 @@ func (m Measurer) Run(
|
||||
percent := float64(idx) / float64(len(allMethods))
|
||||
callbacks.OnProgress(percent, fmt.Sprintf("%s: %+v", meth.name, err))
|
||||
tk.Experiment[meth.name] = &ExperimentKeys{
|
||||
Failure: archival.NewFailure(err),
|
||||
Failure: tracex.NewFailure(err),
|
||||
}
|
||||
}
|
||||
return nil // return nil so we always submit the measurement
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/atomicx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/measurex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
@@ -62,11 +62,11 @@ type TargetResults struct {
|
||||
}
|
||||
|
||||
func registerExtensions(m *model.Measurement) {
|
||||
archival.ExtHTTP.AddTo(m)
|
||||
archival.ExtNetevents.AddTo(m)
|
||||
archival.ExtDNS.AddTo(m)
|
||||
archival.ExtTCPConnect.AddTo(m)
|
||||
archival.ExtTLSHandshake.AddTo(m)
|
||||
tracex.ExtHTTP.AddTo(m)
|
||||
tracex.ExtNetevents.AddTo(m)
|
||||
tracex.ExtDNS.AddTo(m)
|
||||
tracex.ExtTCPConnect.AddTo(m)
|
||||
tracex.ExtTLSHandshake.AddTo(m)
|
||||
}
|
||||
|
||||
// fillSummary fills the Summary field used by the UI.
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/bytecounter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/ptx"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
@@ -232,8 +232,8 @@ func (m *Measurer) bootstrap(ctx context.Context, timeout time.Duration, sess mo
|
||||
tk.TorVersion = debugInfo.Version
|
||||
m.readTorLogs(sess.Logger(), tk, debugInfo.LogFilePath)
|
||||
if err != nil {
|
||||
// Note: archival.NewFailure scrubs IP addresses
|
||||
tk.Failure = archival.NewFailure(err)
|
||||
// Note: tracex.NewFailure scrubs IP addresses
|
||||
tk.Failure = tracex.NewFailure(err)
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
tk.Error = &timeoutReachedError
|
||||
} else {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
@@ -20,7 +20,7 @@ type Configurer struct {
|
||||
Config Config
|
||||
Logger model.Logger
|
||||
ProxyURL *url.URL
|
||||
Saver *trace.Saver
|
||||
Saver *tracex.Saver
|
||||
}
|
||||
|
||||
// The Configuration is the configuration for running a measurement.
|
||||
|
||||
@@ -9,13 +9,12 @@ import (
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/resolver"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
func TestConfigurerNewConfigurationVanilla(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Logger: log.Log,
|
||||
Saver: saver,
|
||||
@@ -73,7 +72,7 @@ func TestConfigurerNewConfigurationVanilla(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationResolverDNSOverHTTPSPowerdns(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
ResolverURL: "doh://google",
|
||||
@@ -120,7 +119,7 @@ func TestConfigurerNewConfigurationResolverDNSOverHTTPSPowerdns(t *testing.T) {
|
||||
if !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
stxp, ok := sr.Txp.(resolver.SaverDNSTransport)
|
||||
stxp, ok := sr.Txp.(tracex.SaverDNSTransport)
|
||||
if !ok {
|
||||
t.Fatal("not the DNS transport we expected")
|
||||
}
|
||||
@@ -149,7 +148,7 @@ func TestConfigurerNewConfigurationResolverDNSOverHTTPSPowerdns(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationResolverDNSOverHTTPSGoogle(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
ResolverURL: "doh://google",
|
||||
@@ -196,7 +195,7 @@ func TestConfigurerNewConfigurationResolverDNSOverHTTPSGoogle(t *testing.T) {
|
||||
if !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
stxp, ok := sr.Txp.(resolver.SaverDNSTransport)
|
||||
stxp, ok := sr.Txp.(tracex.SaverDNSTransport)
|
||||
if !ok {
|
||||
t.Fatal("not the DNS transport we expected")
|
||||
}
|
||||
@@ -225,7 +224,7 @@ func TestConfigurerNewConfigurationResolverDNSOverHTTPSGoogle(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationResolverDNSOverHTTPSCloudflare(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
ResolverURL: "doh://cloudflare",
|
||||
@@ -272,7 +271,7 @@ func TestConfigurerNewConfigurationResolverDNSOverHTTPSCloudflare(t *testing.T)
|
||||
if !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
stxp, ok := sr.Txp.(resolver.SaverDNSTransport)
|
||||
stxp, ok := sr.Txp.(tracex.SaverDNSTransport)
|
||||
if !ok {
|
||||
t.Fatal("not the DNS transport we expected")
|
||||
}
|
||||
@@ -301,7 +300,7 @@ func TestConfigurerNewConfigurationResolverDNSOverHTTPSCloudflare(t *testing.T)
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationResolverUDP(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
ResolverURL: "udp://8.8.8.8:53",
|
||||
@@ -348,7 +347,7 @@ func TestConfigurerNewConfigurationResolverUDP(t *testing.T) {
|
||||
if !ok {
|
||||
t.Fatal("not the resolver we expected")
|
||||
}
|
||||
stxp, ok := sr.Txp.(resolver.SaverDNSTransport)
|
||||
stxp, ok := sr.Txp.(tracex.SaverDNSTransport)
|
||||
if !ok {
|
||||
t.Fatal("not the DNS transport we expected")
|
||||
}
|
||||
@@ -377,7 +376,7 @@ func TestConfigurerNewConfigurationResolverUDP(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationDNSCacheInvalidString(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
DNSCache: "a",
|
||||
@@ -392,7 +391,7 @@ func TestConfigurerNewConfigurationDNSCacheInvalidString(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationDNSCacheNotDomain(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
DNSCache: "b b",
|
||||
@@ -407,7 +406,7 @@ func TestConfigurerNewConfigurationDNSCacheNotDomain(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationDNSCacheNotIP(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
DNSCache: "x.org b",
|
||||
@@ -422,7 +421,7 @@ func TestConfigurerNewConfigurationDNSCacheNotIP(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationDNSCacheGood(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
DNSCache: "dns.google.com 8.8.8.8 8.8.4.4",
|
||||
@@ -449,7 +448,7 @@ func TestConfigurerNewConfigurationDNSCacheGood(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationResolverInvalidURL(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
ResolverURL: "\t",
|
||||
@@ -464,7 +463,7 @@ func TestConfigurerNewConfigurationResolverInvalidURL(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationResolverInvalidURLScheme(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
ResolverURL: "antani://8.8.8.8:53",
|
||||
@@ -479,7 +478,7 @@ func TestConfigurerNewConfigurationResolverInvalidURLScheme(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationTLSServerName(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
TLSServerName: "www.x.org",
|
||||
@@ -506,7 +505,7 @@ func TestConfigurerNewConfigurationTLSServerName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationNoTLSVerify(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
NoTLSVerify: true,
|
||||
@@ -524,7 +523,7 @@ func TestConfigurerNewConfigurationNoTLSVerify(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationTLSv1(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
TLSVersion: "TLSv1",
|
||||
@@ -554,7 +553,7 @@ func TestConfigurerNewConfigurationTLSv1(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationTLSv1dot0(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
TLSVersion: "TLSv1.0",
|
||||
@@ -584,7 +583,7 @@ func TestConfigurerNewConfigurationTLSv1dot0(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationTLSv1dot1(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
TLSVersion: "TLSv1.1",
|
||||
@@ -614,7 +613,7 @@ func TestConfigurerNewConfigurationTLSv1dot1(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationTLSv1dot2(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
TLSVersion: "TLSv1.2",
|
||||
@@ -644,7 +643,7 @@ func TestConfigurerNewConfigurationTLSv1dot2(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationTLSv1dot3(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
TLSVersion: "TLSv1.3",
|
||||
@@ -674,7 +673,7 @@ func TestConfigurerNewConfigurationTLSv1dot3(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationTLSvDefault(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{},
|
||||
Logger: log.Log,
|
||||
@@ -702,7 +701,7 @@ func TestConfigurerNewConfigurationTLSvDefault(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigurerNewConfigurationTLSvInvalid(t *testing.T) {
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Config: urlgetter.Config{
|
||||
TLSVersion: "SSLv3",
|
||||
@@ -718,7 +717,7 @@ func TestConfigurerNewConfigurationTLSvInvalid(t *testing.T) {
|
||||
|
||||
func TestConfigurerNewConfigurationProxyURL(t *testing.T) {
|
||||
URL, _ := url.Parse("socks5://127.0.0.1:9050")
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
configurer := urlgetter.Configurer{
|
||||
Logger: log.Log,
|
||||
Saver: saver,
|
||||
|
||||
@@ -6,8 +6,7 @@ import (
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/tunnel"
|
||||
@@ -50,22 +49,22 @@ func (g Getter) Get(ctx context.Context) (TestKeys, error) {
|
||||
if g.Begin.IsZero() {
|
||||
g.Begin = time.Now()
|
||||
}
|
||||
saver := new(trace.Saver)
|
||||
saver := new(tracex.Saver)
|
||||
tk, err := g.get(ctx, saver)
|
||||
// Make sure we have an operation in cases where we fail before
|
||||
// hitting our httptransport that does error wrapping.
|
||||
if err != nil {
|
||||
err = netxlite.NewTopLevelGenericErrWrapper(err)
|
||||
}
|
||||
tk.FailedOperation = archival.NewFailedOperation(err)
|
||||
tk.Failure = archival.NewFailure(err)
|
||||
tk.FailedOperation = tracex.NewFailedOperation(err)
|
||||
tk.Failure = tracex.NewFailure(err)
|
||||
events := saver.Read()
|
||||
tk.Queries = append(tk.Queries, archival.NewDNSQueriesList(g.Begin, events)...)
|
||||
tk.Queries = append(tk.Queries, tracex.NewDNSQueriesList(g.Begin, events)...)
|
||||
tk.NetworkEvents = append(
|
||||
tk.NetworkEvents, archival.NewNetworkEventsList(g.Begin, events)...,
|
||||
tk.NetworkEvents, tracex.NewNetworkEventsList(g.Begin, events)...,
|
||||
)
|
||||
tk.Requests = append(
|
||||
tk.Requests, archival.NewRequestList(g.Begin, events)...,
|
||||
tk.Requests, tracex.NewRequestList(g.Begin, events)...,
|
||||
)
|
||||
if len(tk.Requests) > 0 {
|
||||
// OONI's convention is that the last request appears first
|
||||
@@ -74,10 +73,10 @@ func (g Getter) Get(ctx context.Context) (TestKeys, error) {
|
||||
tk.HTTPResponseLocations = tk.Requests[0].Response.Locations
|
||||
}
|
||||
tk.TCPConnect = append(
|
||||
tk.TCPConnect, archival.NewTCPConnectList(g.Begin, events)...,
|
||||
tk.TCPConnect, tracex.NewTCPConnectList(g.Begin, events)...,
|
||||
)
|
||||
tk.TLSHandshakes = append(
|
||||
tk.TLSHandshakes, archival.NewTLSHandshakesList(g.Begin, events)...,
|
||||
tk.TLSHandshakes, tracex.NewTLSHandshakesList(g.Begin, events)...,
|
||||
)
|
||||
return tk, err
|
||||
}
|
||||
@@ -90,7 +89,7 @@ func (g Getter) ioutilTempDir(dir, pattern string) (string, error) {
|
||||
return ioutil.TempDir(dir, pattern)
|
||||
}
|
||||
|
||||
func (g Getter) get(ctx context.Context, saver *trace.Saver) (TestKeys, error) {
|
||||
func (g Getter) get(ctx context.Context, saver *tracex.Saver) (TestKeys, error) {
|
||||
tk := TestKeys{
|
||||
Agent: "redirect",
|
||||
Tunnel: g.Config.Tunnel,
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"crypto/x509"
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
@@ -45,18 +45,18 @@ type Config struct {
|
||||
// TestKeys contains the experiment's result.
|
||||
type TestKeys struct {
|
||||
// The following fields are part of the typical JSON emitted by OONI.
|
||||
Agent string `json:"agent"`
|
||||
BootstrapTime float64 `json:"bootstrap_time,omitempty"`
|
||||
DNSCache []string `json:"dns_cache,omitempty"`
|
||||
FailedOperation *string `json:"failed_operation"`
|
||||
Failure *string `json:"failure"`
|
||||
NetworkEvents []archival.NetworkEvent `json:"network_events"`
|
||||
Queries []archival.DNSQueryEntry `json:"queries"`
|
||||
Requests []archival.RequestEntry `json:"requests"`
|
||||
SOCKSProxy string `json:"socksproxy,omitempty"`
|
||||
TCPConnect []archival.TCPConnectEntry `json:"tcp_connect"`
|
||||
TLSHandshakes []archival.TLSHandshake `json:"tls_handshakes"`
|
||||
Tunnel string `json:"tunnel,omitempty"`
|
||||
Agent string `json:"agent"`
|
||||
BootstrapTime float64 `json:"bootstrap_time,omitempty"`
|
||||
DNSCache []string `json:"dns_cache,omitempty"`
|
||||
FailedOperation *string `json:"failed_operation"`
|
||||
Failure *string `json:"failure"`
|
||||
NetworkEvents []tracex.NetworkEvent `json:"network_events"`
|
||||
Queries []tracex.DNSQueryEntry `json:"queries"`
|
||||
Requests []tracex.RequestEntry `json:"requests"`
|
||||
SOCKSProxy string `json:"socksproxy,omitempty"`
|
||||
TCPConnect []tracex.TCPConnectEntry `json:"tcp_connect"`
|
||||
TLSHandshakes []tracex.TLSHandshake `json:"tls_handshakes"`
|
||||
Tunnel string `json:"tunnel,omitempty"`
|
||||
|
||||
// The following fields are not serialised but are useful to simplify
|
||||
// analysing the measurements in telegram, whatsapp, etc.
|
||||
@@ -68,12 +68,12 @@ type TestKeys struct {
|
||||
// RegisterExtensions registers the extensions used by the urlgetter
|
||||
// experiment into the provided measurement.
|
||||
func RegisterExtensions(m *model.Measurement) {
|
||||
archival.ExtHTTP.AddTo(m)
|
||||
archival.ExtDNS.AddTo(m)
|
||||
archival.ExtNetevents.AddTo(m)
|
||||
archival.ExtTCPConnect.AddTo(m)
|
||||
archival.ExtTLSHandshake.AddTo(m)
|
||||
archival.ExtTunnel.AddTo(m)
|
||||
tracex.ExtHTTP.AddTo(m)
|
||||
tracex.ExtDNS.AddTo(m)
|
||||
tracex.ExtNetevents.AddTo(m)
|
||||
tracex.ExtTCPConnect.AddTo(m)
|
||||
tracex.ExtTLSHandshake.AddTo(m)
|
||||
tracex.ExtTunnel.AddTo(m)
|
||||
}
|
||||
|
||||
// Measurer performs the measurement.
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
"github.com/ooni/probe-cli/v3/internal/torlogs"
|
||||
@@ -172,8 +172,8 @@ func (m *Measurer) bootstrap(ctx context.Context, timeout time.Duration,
|
||||
tk.TorVersion = debugInfo.Version
|
||||
m.readTorLogs(sess.Logger(), tk, debugInfo.LogFilePath)
|
||||
if err != nil {
|
||||
// Note: archival.NewFailure scrubs IP addresses
|
||||
tk.Failure = archival.NewFailure(err)
|
||||
// Note: tracex.NewFailure scrubs IP addresses
|
||||
tk.Failure = tracex.NewFailure(err)
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
tk.Error = &timeoutReachedError
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"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/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/randx"
|
||||
)
|
||||
|
||||
@@ -42,8 +42,8 @@ func TestHTTPBodyLengthChecks(t *testing.T) {
|
||||
name: "response body is truncated",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
BodyIsTruncated: true,
|
||||
},
|
||||
}},
|
||||
@@ -59,8 +59,8 @@ func TestHTTPBodyLengthChecks(t *testing.T) {
|
||||
name: "response body length is zero",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{},
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{},
|
||||
}},
|
||||
},
|
||||
ctrl: webconnectivity.ControlResponse{
|
||||
@@ -74,9 +74,9 @@ func TestHTTPBodyLengthChecks(t *testing.T) {
|
||||
name: "control length is negative",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: randx.Letters(768),
|
||||
},
|
||||
},
|
||||
@@ -93,9 +93,9 @@ func TestHTTPBodyLengthChecks(t *testing.T) {
|
||||
name: "match with bigger control",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: randx.Letters(768),
|
||||
},
|
||||
},
|
||||
@@ -113,9 +113,9 @@ func TestHTTPBodyLengthChecks(t *testing.T) {
|
||||
name: "match with bigger measurement",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: randx.Letters(1024),
|
||||
},
|
||||
},
|
||||
@@ -133,9 +133,9 @@ func TestHTTPBodyLengthChecks(t *testing.T) {
|
||||
name: "not match with bigger control",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: randx.Letters(8),
|
||||
},
|
||||
},
|
||||
@@ -153,9 +153,9 @@ func TestHTTPBodyLengthChecks(t *testing.T) {
|
||||
name: "match with bigger measurement",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: randx.Letters(16),
|
||||
},
|
||||
},
|
||||
@@ -203,15 +203,15 @@ func TestStatusCodeMatch(t *testing.T) {
|
||||
name: "with a request but zero status codes",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{}},
|
||||
Requests: []tracex.RequestEntry{{}},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
name: "with equal status codes including 5xx",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 501,
|
||||
},
|
||||
}},
|
||||
@@ -227,8 +227,8 @@ func TestStatusCodeMatch(t *testing.T) {
|
||||
name: "with different status codes and the control being 5xx",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 407,
|
||||
},
|
||||
}},
|
||||
@@ -244,8 +244,8 @@ func TestStatusCodeMatch(t *testing.T) {
|
||||
name: "with different status codes and the control being not 5xx",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 407,
|
||||
},
|
||||
}},
|
||||
@@ -261,8 +261,8 @@ func TestStatusCodeMatch(t *testing.T) {
|
||||
name: "with only response status code and no control status code",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
},
|
||||
}},
|
||||
@@ -272,8 +272,8 @@ func TestStatusCodeMatch(t *testing.T) {
|
||||
name: "with response status code and -1 as control status code",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
},
|
||||
}},
|
||||
@@ -288,8 +288,8 @@ func TestStatusCodeMatch(t *testing.T) {
|
||||
name: "with only control status code and no response status code",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 0,
|
||||
},
|
||||
}},
|
||||
@@ -346,7 +346,7 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with request and no response status code",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{}},
|
||||
Requests: []tracex.RequestEntry{{}},
|
||||
},
|
||||
ctrl: webconnectivity.ControlResponse{
|
||||
HTTPRequest: webconnectivity.ControlHTTPRequestResult{
|
||||
@@ -363,9 +363,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with no control status code",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Date": {Value: "Mon Jul 13 21:10:08 CEST 2020"},
|
||||
},
|
||||
Code: 200,
|
||||
@@ -379,9 +379,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with negative control status code",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Date": {Value: "Mon Jul 13 21:10:08 CEST 2020"},
|
||||
},
|
||||
Code: 200,
|
||||
@@ -399,9 +399,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with no uncommon headers",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Date": {Value: "Mon Jul 13 21:10:08 CEST 2020"},
|
||||
},
|
||||
Code: 200,
|
||||
@@ -422,9 +422,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with equal uncommon headers",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Date": {Value: "Mon Jul 13 21:10:08 CEST 2020"},
|
||||
"Antani": {Value: "MASCETTI"},
|
||||
},
|
||||
@@ -447,9 +447,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with different uncommon headers",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Date": {Value: "Mon Jul 13 21:10:08 CEST 2020"},
|
||||
"Antani": {Value: "MASCETTI"},
|
||||
},
|
||||
@@ -472,9 +472,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with small uncommon intersection (X-Cache)",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Accept-Ranges": {Value: "bytes"},
|
||||
"Age": {Value: "404727"},
|
||||
"Cache-Control": {Value: "max-age=604800"},
|
||||
@@ -519,9 +519,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with no uncommon intersection",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Accept-Ranges": {Value: "bytes"},
|
||||
"Age": {Value: "404727"},
|
||||
"Cache-Control": {Value: "max-age=604800"},
|
||||
@@ -564,9 +564,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with exactly equal headers",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Accept-Ranges": {Value: "bytes"},
|
||||
"Age": {Value: "404727"},
|
||||
"Cache-Control": {Value: "max-age=604800"},
|
||||
@@ -605,9 +605,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with equal headers except for the case",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"accept-ranges": {Value: "bytes"},
|
||||
"AGE": {Value: "404727"},
|
||||
"cache-Control": {Value: "max-age=604800"},
|
||||
@@ -674,7 +674,7 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "with a request and no response",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{}},
|
||||
Requests: []tracex.RequestEntry{{}},
|
||||
},
|
||||
},
|
||||
wantOut: nil,
|
||||
@@ -682,8 +682,8 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "with a response with truncated body",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
BodyIsTruncated: true,
|
||||
},
|
||||
@@ -695,10 +695,10 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "with a response with good body",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
Body: archival.MaybeBinaryValue{Value: "<HTML/>"},
|
||||
Body: tracex.MaybeBinaryValue{Value: "<HTML/>"},
|
||||
},
|
||||
}},
|
||||
},
|
||||
@@ -708,10 +708,10 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "with all good but no titles",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
Body: archival.MaybeBinaryValue{Value: "<HTML/>"},
|
||||
Body: tracex.MaybeBinaryValue{Value: "<HTML/>"},
|
||||
},
|
||||
}},
|
||||
},
|
||||
@@ -727,10 +727,10 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "reasonably common case where it succeeds",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: "<HTML><TITLE>La community di MSN</TITLE></HTML>"},
|
||||
},
|
||||
}},
|
||||
@@ -747,10 +747,10 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "reasonably common case where it fails",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: "<HTML><TITLE>La communità di MSN</TITLE></HTML>"},
|
||||
},
|
||||
}},
|
||||
@@ -767,10 +767,10 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "when the title is too long",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: "<HTML><TITLE>" + randx.Letters(1024) + "</TITLE></HTML>"},
|
||||
},
|
||||
}},
|
||||
@@ -787,10 +787,10 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "reasonably common case where it succeeds with case variations",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: "<HTML><TiTLe>La commUNity di MSN</tITLE></HTML>"},
|
||||
},
|
||||
}},
|
||||
@@ -807,10 +807,10 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "when the control status code is negative",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: "<HTML><TiTLe>La commUNity di MSN</tITLE></HTML>"},
|
||||
},
|
||||
}},
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
@@ -41,8 +41,8 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with an HTTPS request with no failure",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Request: archival.HTTPRequest{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Request: tracex.HTTPRequest{
|
||||
URL: "https://www.kernel.org/",
|
||||
},
|
||||
Failure: nil,
|
||||
@@ -210,7 +210,7 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with connection refused",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeConnectionRefused,
|
||||
}},
|
||||
},
|
||||
@@ -226,7 +226,7 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with connection reset",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeConnectionReset,
|
||||
}},
|
||||
},
|
||||
@@ -242,7 +242,7 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with NXDOMAIN",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeNXDOMAIN,
|
||||
}},
|
||||
},
|
||||
@@ -258,7 +258,7 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with EOF",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeEOFError,
|
||||
}},
|
||||
},
|
||||
@@ -274,7 +274,7 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with timeout",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeTimeout,
|
||||
}},
|
||||
},
|
||||
@@ -290,7 +290,7 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with SSL invalid hostname",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeSSLInvalidHost,
|
||||
}},
|
||||
},
|
||||
@@ -306,7 +306,7 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with SSL invalid cert",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeSSLInvalidCert,
|
||||
}},
|
||||
},
|
||||
@@ -322,7 +322,7 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with SSL unknown auth",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeSSLUnknownAuth,
|
||||
}},
|
||||
},
|
||||
@@ -341,7 +341,7 @@ func TestSummarize(t *testing.T) {
|
||||
DNSAnalysisResult: webconnectivity.DNSAnalysisResult{
|
||||
DNSConsistency: &webconnectivity.DNSInconsistent,
|
||||
},
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeSSLUnknownAuth,
|
||||
}},
|
||||
},
|
||||
@@ -361,7 +361,7 @@ func TestSummarize(t *testing.T) {
|
||||
DNSAnalysisResult: webconnectivity.DNSAnalysisResult{
|
||||
DNSConsistency: &webconnectivity.DNSInconsistent,
|
||||
},
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeSSLUnknownAuth,
|
||||
}, {}},
|
||||
},
|
||||
@@ -381,7 +381,7 @@ func TestSummarize(t *testing.T) {
|
||||
StatusCodeMatch: &trueValue,
|
||||
BodyLengthMatch: &trueValue,
|
||||
},
|
||||
Requests: []archival.RequestEntry{{}},
|
||||
Requests: []tracex.RequestEntry{{}},
|
||||
},
|
||||
},
|
||||
wantOut: webconnectivity.Summary{
|
||||
@@ -398,7 +398,7 @@ func TestSummarize(t *testing.T) {
|
||||
StatusCodeMatch: &trueValue,
|
||||
HeadersMatch: &trueValue,
|
||||
},
|
||||
Requests: []archival.RequestEntry{{}},
|
||||
Requests: []tracex.RequestEntry{{}},
|
||||
},
|
||||
},
|
||||
wantOut: webconnectivity.Summary{
|
||||
@@ -415,7 +415,7 @@ func TestSummarize(t *testing.T) {
|
||||
StatusCodeMatch: &trueValue,
|
||||
TitleMatch: &trueValue,
|
||||
},
|
||||
Requests: []archival.RequestEntry{{}},
|
||||
Requests: []tracex.RequestEntry{{}},
|
||||
},
|
||||
},
|
||||
wantOut: webconnectivity.Summary{
|
||||
@@ -432,7 +432,7 @@ func TestSummarize(t *testing.T) {
|
||||
StatusCodeMatch: &falseValue,
|
||||
TitleMatch: &trueValue,
|
||||
},
|
||||
Requests: []archival.RequestEntry{{}},
|
||||
Requests: []tracex.RequestEntry{{}},
|
||||
DNSAnalysisResult: webconnectivity.DNSAnalysisResult{
|
||||
DNSConsistency: &webconnectivity.DNSInconsistent,
|
||||
},
|
||||
@@ -453,7 +453,7 @@ func TestSummarize(t *testing.T) {
|
||||
StatusCodeMatch: &falseValue,
|
||||
TitleMatch: &trueValue,
|
||||
},
|
||||
Requests: []archival.RequestEntry{{}},
|
||||
Requests: []tracex.RequestEntry{{}},
|
||||
DNSAnalysisResult: webconnectivity.DNSAnalysisResult{
|
||||
DNSConsistency: &webconnectivity.DNSConsistent,
|
||||
},
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity/internal"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
@@ -34,12 +34,12 @@ type TestKeys struct {
|
||||
// is rather obvious where they come from.
|
||||
//
|
||||
// See https://github.com/ooni/probe/issues/1413.
|
||||
NetworkEvents []archival.NetworkEvent `json:"network_events"`
|
||||
TLSHandshakes []archival.TLSHandshake `json:"tls_handshakes"`
|
||||
NetworkEvents []tracex.NetworkEvent `json:"network_events"`
|
||||
TLSHandshakes []tracex.TLSHandshake `json:"tls_handshakes"`
|
||||
|
||||
// DNS experiment
|
||||
Queries []archival.DNSQueryEntry `json:"queries"`
|
||||
DNSExperimentFailure *string `json:"dns_experiment_failure"`
|
||||
Queries []tracex.DNSQueryEntry `json:"queries"`
|
||||
DNSExperimentFailure *string `json:"dns_experiment_failure"`
|
||||
DNSAnalysisResult
|
||||
|
||||
// Control experiment
|
||||
@@ -48,13 +48,13 @@ type TestKeys struct {
|
||||
Control ControlResponse `json:"control"`
|
||||
|
||||
// TCP/TLS "connect" experiment
|
||||
TCPConnect []archival.TCPConnectEntry `json:"tcp_connect"`
|
||||
TCPConnectSuccesses int `json:"-"`
|
||||
TCPConnectAttempts int `json:"-"`
|
||||
TCPConnect []tracex.TCPConnectEntry `json:"tcp_connect"`
|
||||
TCPConnectSuccesses int `json:"-"`
|
||||
TCPConnectAttempts int `json:"-"`
|
||||
|
||||
// HTTP experiment
|
||||
Requests []archival.RequestEntry `json:"requests"`
|
||||
HTTPExperimentFailure *string `json:"http_experiment_failure"`
|
||||
Requests []tracex.RequestEntry `json:"requests"`
|
||||
HTTPExperimentFailure *string `json:"http_experiment_failure"`
|
||||
HTTPAnalysisResult
|
||||
|
||||
// Top-level analysis
|
||||
@@ -180,7 +180,7 @@ func (m Measurer) Run(
|
||||
TCPConnect: epnts.Endpoints(),
|
||||
})
|
||||
tk.THRuntime = time.Since(thBegin)
|
||||
tk.ControlFailure = archival.NewFailure(err)
|
||||
tk.ControlFailure = tracex.NewFailure(err)
|
||||
// 4. analyze DNS results
|
||||
if tk.ControlFailure == nil {
|
||||
tk.DNSAnalysisResult = DNSAnalysis(URL, dnsResult, tk.Control)
|
||||
@@ -240,9 +240,9 @@ func (m Measurer) Run(
|
||||
|
||||
// ComputeTCPBlocking will return a copy of the input TCPConnect structure
|
||||
// where we set the Blocking value depending on the control results.
|
||||
func ComputeTCPBlocking(measurement []archival.TCPConnectEntry,
|
||||
control map[string]ControlTCPConnectResult) (out []archival.TCPConnectEntry) {
|
||||
out = []archival.TCPConnectEntry{}
|
||||
func ComputeTCPBlocking(measurement []tracex.TCPConnectEntry,
|
||||
control map[string]ControlTCPConnectResult) (out []tracex.TCPConnectEntry) {
|
||||
out = []tracex.TCPConnectEntry{}
|
||||
for _, me := range measurement {
|
||||
epnt := net.JoinHostPort(me.IP, strconv.Itoa(me.Port))
|
||||
if ce, ok := control[epnt]; ok {
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/google/go-cmp/cmp"
|
||||
engine "github.com/ooni/probe-cli/v3/internal/engine"
|
||||
"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/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
@@ -232,33 +232,33 @@ func TestComputeTCPBlocking(t *testing.T) {
|
||||
failure := io.EOF.Error()
|
||||
anotherFailure := "unknown_error"
|
||||
type args struct {
|
||||
measurement []archival.TCPConnectEntry
|
||||
measurement []tracex.TCPConnectEntry
|
||||
control map[string]webconnectivity.ControlTCPConnectResult
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want []archival.TCPConnectEntry
|
||||
want []tracex.TCPConnectEntry
|
||||
}{{
|
||||
name: "with all empty",
|
||||
args: args{},
|
||||
want: []archival.TCPConnectEntry{},
|
||||
want: []tracex.TCPConnectEntry{},
|
||||
}, {
|
||||
name: "with control failure",
|
||||
args: args{
|
||||
measurement: []archival.TCPConnectEntry{{
|
||||
measurement: []tracex.TCPConnectEntry{{
|
||||
IP: "1.1.1.1",
|
||||
Port: 853,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Failure: &failure,
|
||||
Success: false,
|
||||
},
|
||||
}},
|
||||
},
|
||||
want: []archival.TCPConnectEntry{{
|
||||
want: []tracex.TCPConnectEntry{{
|
||||
IP: "1.1.1.1",
|
||||
Port: 853,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Failure: &failure,
|
||||
Success: false,
|
||||
},
|
||||
@@ -266,10 +266,10 @@ func TestComputeTCPBlocking(t *testing.T) {
|
||||
}, {
|
||||
name: "with failures on both ends",
|
||||
args: args{
|
||||
measurement: []archival.TCPConnectEntry{{
|
||||
measurement: []tracex.TCPConnectEntry{{
|
||||
IP: "1.1.1.1",
|
||||
Port: 853,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Failure: &failure,
|
||||
Success: false,
|
||||
},
|
||||
@@ -281,10 +281,10 @@ func TestComputeTCPBlocking(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
want: []archival.TCPConnectEntry{{
|
||||
want: []tracex.TCPConnectEntry{{
|
||||
IP: "1.1.1.1",
|
||||
Port: 853,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Blocked: &falseValue,
|
||||
Failure: &failure,
|
||||
Success: false,
|
||||
@@ -293,10 +293,10 @@ func TestComputeTCPBlocking(t *testing.T) {
|
||||
}, {
|
||||
name: "with failure on the probe side",
|
||||
args: args{
|
||||
measurement: []archival.TCPConnectEntry{{
|
||||
measurement: []tracex.TCPConnectEntry{{
|
||||
IP: "1.1.1.1",
|
||||
Port: 853,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Failure: &failure,
|
||||
Success: false,
|
||||
},
|
||||
@@ -308,10 +308,10 @@ func TestComputeTCPBlocking(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
want: []archival.TCPConnectEntry{{
|
||||
want: []tracex.TCPConnectEntry{{
|
||||
IP: "1.1.1.1",
|
||||
Port: 853,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Blocked: &trueValue,
|
||||
Failure: &failure,
|
||||
Success: false,
|
||||
@@ -320,10 +320,10 @@ func TestComputeTCPBlocking(t *testing.T) {
|
||||
}, {
|
||||
name: "with failure on the control side",
|
||||
args: args{
|
||||
measurement: []archival.TCPConnectEntry{{
|
||||
measurement: []tracex.TCPConnectEntry{{
|
||||
IP: "1.1.1.1",
|
||||
Port: 853,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Failure: nil,
|
||||
Success: true,
|
||||
},
|
||||
@@ -335,10 +335,10 @@ func TestComputeTCPBlocking(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
want: []archival.TCPConnectEntry{{
|
||||
want: []tracex.TCPConnectEntry{{
|
||||
IP: "1.1.1.1",
|
||||
Port: 853,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Blocked: &falseValue,
|
||||
Failure: nil,
|
||||
Success: true,
|
||||
|
||||
Reference in New Issue
Block a user