refactor: interfaces and data types into the model package (#642)
## Checklist - [x] I have read the [contribution guidelines](https://github.com/ooni/probe-cli/blob/master/CONTRIBUTING.md) - [x] reference issue for this pull request: https://github.com/ooni/probe/issues/1885 - [x] related ooni/spec pull request: N/A Location of the issue tracker: https://github.com/ooni/probe ## Description This PR contains a set of changes to move important interfaces and data types into the `./internal/model` package. The criteria for including an interface or data type in here is roughly that the type should be important and used by several packages. We are especially interested to move more interfaces here to increase modularity. An additional side effect is that, by reading this package, one should be able to understand more quickly how different parts of the codebase interact with each other. This is what I want to move in `internal/model`: - [x] most important interfaces from `internal/netxlite` - [x] everything that was previously part of `internal/engine/model` - [x] mocks from `internal/netxlite/mocks` should also be moved in here as a subpackage
This commit is contained in:
parent
69aca619ea
commit
273b70bacc
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
|
||||
engine "github.com/ooni/probe-cli/v3/internal/engine"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
// DNSCheck nettest implementation.
|
||||
|
@ -12,7 +12,7 @@ type DNSCheck struct{}
|
|||
|
||||
func (n DNSCheck) lookupURLs(ctl *Controller) ([]string, error) {
|
||||
inputloader := &engine.InputLoader{
|
||||
CheckInConfig: &model.CheckInConfig{
|
||||
CheckInConfig: &model.OOAPICheckInConfig{
|
||||
// not needed because we have default static input in the engine
|
||||
},
|
||||
ExperimentName: "dnscheck",
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/ooni"
|
||||
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/output"
|
||||
engine "github.com/ooni/probe-cli/v3/internal/engine"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/pkg/errors"
|
||||
"upper.io/db.v3/lib/sqlbuilder"
|
||||
)
|
||||
|
@ -90,7 +90,7 @@ type Controller struct {
|
|||
//
|
||||
// - on failure, an error.
|
||||
func (c *Controller) BuildAndSetInputIdxMap(
|
||||
db sqlbuilder.Database, testlist []model.URLInfo) ([]string, error) {
|
||||
db sqlbuilder.Database, testlist []model.OOAPIURLInfo) ([]string, error) {
|
||||
var urls []string
|
||||
urlIDMap := make(map[int64]int64)
|
||||
for idx, url := range testlist {
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
|
||||
engine "github.com/ooni/probe-cli/v3/internal/engine"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
// STUNReachability nettest implementation.
|
||||
|
@ -12,7 +12,7 @@ type STUNReachability struct{}
|
|||
|
||||
func (n STUNReachability) lookupURLs(ctl *Controller) ([]string, error) {
|
||||
inputloader := &engine.InputLoader{
|
||||
CheckInConfig: &model.CheckInConfig{
|
||||
CheckInConfig: &model.OOAPICheckInConfig{
|
||||
// not needed because we have default static input in the engine
|
||||
},
|
||||
ExperimentName: "stunreachability",
|
||||
|
|
|
@ -5,19 +5,19 @@ import (
|
|||
|
||||
"github.com/apex/log"
|
||||
engine "github.com/ooni/probe-cli/v3/internal/engine"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
func (n WebConnectivity) lookupURLs(ctl *Controller, categories []string) ([]string, error) {
|
||||
inputloader := &engine.InputLoader{
|
||||
CheckInConfig: &model.CheckInConfig{
|
||||
CheckInConfig: &model.OOAPICheckInConfig{
|
||||
// Setting Charging and OnWiFi to true causes the CheckIn
|
||||
// API to return to us as much URL as possible with the
|
||||
// given RunType hint.
|
||||
Charging: true,
|
||||
OnWiFi: true,
|
||||
RunType: ctl.RunType,
|
||||
WebConnectivity: model.CheckInConfigWebConnectivity{
|
||||
WebConnectivity: model.OOAPICheckInConfigWebConnectivity{
|
||||
CategoryCodes: categories,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -13,6 +13,9 @@ where `$package` is the name of the package.
|
|||
|
||||
Some notable packages:
|
||||
|
||||
- [model](model) contains the interfaces and data model shared
|
||||
by most packages inside this directory;
|
||||
|
||||
- [netxlite](netxlite) is the underlying networking library;
|
||||
|
||||
- [tutorial](tutorial) contains tutorials on writing new experiments,
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
|
||||
"github.com/ooni/probe-cli/v3/internal/model/mocks"
|
||||
)
|
||||
|
||||
func TestConnWorksOnSuccess(t *testing.T) {
|
||||
|
|
|
@ -17,9 +17,9 @@ import (
|
|||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/assetsdir"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/humanize"
|
||||
"github.com/ooni/probe-cli/v3/internal/kvstore"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/filtering"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
|
@ -377,7 +377,7 @@ func MainWithConfiguration(experimentName string, currentOptions Options) {
|
|||
TunnelDir: tunnelDir,
|
||||
}
|
||||
if currentOptions.ProbeServicesURL != "" {
|
||||
config.AvailableProbeServices = []model.Service{{
|
||||
config.AvailableProbeServices = []model.OOAPIService{{
|
||||
Address: currentOptions.ProbeServicesURL,
|
||||
Type: "https",
|
||||
}}
|
||||
|
@ -411,7 +411,7 @@ func MainWithConfiguration(experimentName string, currentOptions Options) {
|
|||
fatalOnError(err, "cannot create experiment builder")
|
||||
|
||||
inputLoader := &engine.InputLoader{
|
||||
CheckInConfig: &model.CheckInConfig{
|
||||
CheckInConfig: &model.OOAPICheckInConfig{
|
||||
RunType: "manual",
|
||||
OnWiFi: true, // meaning: not on 4G
|
||||
Charging: true,
|
||||
|
|
|
@ -8,7 +8,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/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
|
||||
"github.com/ooni/probe-cli/v3/internal/model/mocks"
|
||||
)
|
||||
|
||||
func stringPointerForString(s string) *string {
|
||||
|
|
|
@ -11,10 +11,10 @@ import (
|
|||
|
||||
"github.com/ooni/probe-cli/v3/internal/bytecounter"
|
||||
"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/netx/dialer"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/httptransport"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/probeservices"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/version"
|
||||
)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
type collectDeps interface {
|
||||
|
|
|
@ -14,10 +14,10 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/montanaflynn/stats"
|
||||
"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/trace"
|
||||
"github.com/ooni/probe-cli/v3/internal/humanize"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ 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/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
type FakeDeps struct {
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/mlablocate"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
type locateDeps interface {
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
type negotiateDeps interface {
|
||||
|
|
|
@ -15,10 +15,10 @@ 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/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
)
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
func TestHTTPHostWithOverride(t *testing.T) {
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
const testVersion = "0.1.0"
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/example"
|
||||
"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/model"
|
||||
)
|
||||
|
||||
func TestSuccess(t *testing.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/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ 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/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
@ -222,7 +222,7 @@ func TestComputeEndpointStatsDNSIsLying(t *testing.T) {
|
|||
|
||||
func newsession(t *testing.T) model.ExperimentSession {
|
||||
sess, err := engine.NewSession(context.Background(), engine.SessionConfig{
|
||||
AvailableProbeServices: []model.Service{{
|
||||
AvailableProbeServices: []model.OOAPIService{{
|
||||
Address: "https://ams-pg-test.ooni.org",
|
||||
Type: "https",
|
||||
}},
|
||||
|
|
|
@ -17,9 +17,9 @@ import (
|
|||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
|
||||
errorsxlegacy "github.com/ooni/probe-cli/v3/internal/engine/legacy/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/dialer"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/randx"
|
||||
)
|
||||
|
|
|
@ -16,8 +16,8 @@ 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/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
@ -36,7 +36,7 @@ func TestSuccess(t *testing.T) {
|
|||
ctx := context.Background()
|
||||
sess := &mockable.Session{
|
||||
MockableLogger: log.Log,
|
||||
MockableTestHelpers: map[string][]model.Service{
|
||||
MockableTestHelpers: map[string][]model.OOAPIService{
|
||||
"http-return-json-headers": {{
|
||||
Address: "http://37.218.241.94:80",
|
||||
Type: "legacy",
|
||||
|
@ -144,7 +144,7 @@ func TestCancelledContext(t *testing.T) {
|
|||
cancel()
|
||||
sess := &mockable.Session{
|
||||
MockableLogger: log.Log,
|
||||
MockableTestHelpers: map[string][]model.Service{
|
||||
MockableTestHelpers: map[string][]model.OOAPIService{
|
||||
"http-return-json-headers": {{
|
||||
Address: "http://37.218.241.94:80",
|
||||
Type: "legacy",
|
||||
|
@ -303,7 +303,7 @@ func TestNoActualHelpersInList(t *testing.T) {
|
|||
measurer := hhfm.NewExperimentMeasurer(hhfm.Config{})
|
||||
ctx := context.Background()
|
||||
sess := &mockable.Session{
|
||||
MockableTestHelpers: map[string][]model.Service{
|
||||
MockableTestHelpers: map[string][]model.OOAPIService{
|
||||
"http-return-json-headers": nil,
|
||||
},
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ func TestWrongTestHelperType(t *testing.T) {
|
|||
measurer := hhfm.NewExperimentMeasurer(hhfm.Config{})
|
||||
ctx := context.Background()
|
||||
sess := &mockable.Session{
|
||||
MockableTestHelpers: map[string][]model.Service{
|
||||
MockableTestHelpers: map[string][]model.OOAPIService{
|
||||
"http-return-json-headers": {{
|
||||
Address: "http://127.0.0.1",
|
||||
Type: "antani",
|
||||
|
@ -406,7 +406,7 @@ func TestNewRequestFailure(t *testing.T) {
|
|||
measurer := hhfm.NewExperimentMeasurer(hhfm.Config{})
|
||||
ctx := context.Background()
|
||||
sess := &mockable.Session{
|
||||
MockableTestHelpers: map[string][]model.Service{
|
||||
MockableTestHelpers: map[string][]model.OOAPIService{
|
||||
"http-return-json-headers": {{
|
||||
Address: "http://127.0.0.1\t\t\t", // invalid
|
||||
Type: "legacy",
|
||||
|
@ -463,7 +463,7 @@ func TestInvalidJSONBody(t *testing.T) {
|
|||
measurer := hhfm.NewExperimentMeasurer(hhfm.Config{})
|
||||
ctx := context.Background()
|
||||
sess := &mockable.Session{
|
||||
MockableTestHelpers: map[string][]model.Service{
|
||||
MockableTestHelpers: map[string][]model.OOAPIService{
|
||||
"http-return-json-headers": {{
|
||||
Address: server.URL,
|
||||
Type: "legacy",
|
||||
|
|
|
@ -11,9 +11,9 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/randx"
|
||||
)
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
"github.com/apex/log"
|
||||
"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/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
@ -30,7 +30,7 @@ func TestSuccess(t *testing.T) {
|
|||
ctx := context.Background()
|
||||
sess := &mockable.Session{
|
||||
MockableLogger: log.Log,
|
||||
MockableTestHelpers: map[string][]model.Service{
|
||||
MockableTestHelpers: map[string][]model.OOAPIService{
|
||||
"tcp-echo": {{
|
||||
Address: "37.218.241.93",
|
||||
Type: "legacy",
|
||||
|
@ -79,7 +79,7 @@ func TestCancelledContext(t *testing.T) {
|
|||
cancel()
|
||||
sess := &mockable.Session{
|
||||
MockableLogger: log.Log,
|
||||
MockableTestHelpers: map[string][]model.Service{
|
||||
MockableTestHelpers: map[string][]model.OOAPIService{
|
||||
"tcp-echo": {{
|
||||
Address: "37.218.241.93",
|
||||
Type: "legacy",
|
||||
|
@ -178,7 +178,7 @@ func TestWithFakeMethods(t *testing.T) {
|
|||
}
|
||||
ctx := context.Background()
|
||||
sess := &mockable.Session{
|
||||
MockableTestHelpers: map[string][]model.Service{
|
||||
MockableTestHelpers: map[string][]model.OOAPIService{
|
||||
"tcp-echo": {{
|
||||
Address: "127.0.0.1",
|
||||
Type: "legacy",
|
||||
|
@ -239,7 +239,7 @@ func TestWithNoMethods(t *testing.T) {
|
|||
}
|
||||
ctx := context.Background()
|
||||
sess := &mockable.Session{
|
||||
MockableTestHelpers: map[string][]model.Service{
|
||||
MockableTestHelpers: map[string][]model.OOAPIService{
|
||||
"tcp-echo": {{
|
||||
Address: "127.0.0.1",
|
||||
Type: "legacy",
|
||||
|
@ -302,7 +302,7 @@ func TestNoActualHelperInList(t *testing.T) {
|
|||
measurer := hirl.NewExperimentMeasurer(hirl.Config{})
|
||||
ctx := context.Background()
|
||||
sess := &mockable.Session{
|
||||
MockableTestHelpers: map[string][]model.Service{
|
||||
MockableTestHelpers: map[string][]model.OOAPIService{
|
||||
"tcp-echo": nil,
|
||||
},
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ func TestWrongTestHelperType(t *testing.T) {
|
|||
measurer := hirl.NewExperimentMeasurer(hirl.Config{})
|
||||
ctx := context.Background()
|
||||
sess := &mockable.Session{
|
||||
MockableTestHelpers: map[string][]model.Service{
|
||||
MockableTestHelpers: map[string][]model.OOAPIService{
|
||||
"tcp-echo": {{
|
||||
Address: "127.0.0.1",
|
||||
Type: "antani",
|
||||
|
@ -368,7 +368,7 @@ func TestWrongTestHelperType(t *testing.T) {
|
|||
func TestRunMethodDialFailure(t *testing.T) {
|
||||
sess := &mockable.Session{
|
||||
MockableLogger: log.Log,
|
||||
MockableTestHelpers: map[string][]model.Service{
|
||||
MockableTestHelpers: map[string][]model.OOAPIService{
|
||||
"tcp-echo": {{
|
||||
Address: "37.218.241.93",
|
||||
Type: "legacy",
|
||||
|
@ -415,7 +415,7 @@ func TestRunMethodDialFailure(t *testing.T) {
|
|||
func TestRunMethodSetDeadlineFailure(t *testing.T) {
|
||||
sess := &mockable.Session{
|
||||
MockableLogger: log.Log,
|
||||
MockableTestHelpers: map[string][]model.Service{
|
||||
MockableTestHelpers: map[string][]model.OOAPIService{
|
||||
"tcp-echo": {{
|
||||
Address: "37.218.241.93",
|
||||
Type: "legacy",
|
||||
|
@ -464,7 +464,7 @@ func TestRunMethodSetDeadlineFailure(t *testing.T) {
|
|||
func TestRunMethodWriteFailure(t *testing.T) {
|
||||
sess := &mockable.Session{
|
||||
MockableLogger: log.Log,
|
||||
MockableTestHelpers: map[string][]model.Service{
|
||||
MockableTestHelpers: map[string][]model.OOAPIService{
|
||||
"tcp-echo": {{
|
||||
Address: "37.218.241.93",
|
||||
Type: "legacy",
|
||||
|
@ -513,7 +513,7 @@ func TestRunMethodWriteFailure(t *testing.T) {
|
|||
func TestRunMethodReadEOFWithWrongData(t *testing.T) {
|
||||
sess := &mockable.Session{
|
||||
MockableLogger: log.Log,
|
||||
MockableTestHelpers: map[string][]model.Service{
|
||||
MockableTestHelpers: map[string][]model.OOAPIService{
|
||||
"tcp-echo": {{
|
||||
Address: "37.218.241.93",
|
||||
Type: "legacy",
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"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/model"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
"net/url"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/dialer"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/resolver"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"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/humanize"
|
||||
"github.com/ooni/probe-cli/v3/internal/mlablocatev2"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
func TestNewExperimentMeasurer(t *testing.T) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"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/model"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/psiphon"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
// Implementation note: integration test performed by
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
"time"
|
||||
|
||||
"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/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ 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/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/dnscheck"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
type dnsCheckMain struct {
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/dnscheck"
|
||||
"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/model"
|
||||
)
|
||||
|
||||
// Config contains settings.
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/run"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
func TestExperimentNameAndVersion(t *testing.T) {
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/dnscheck"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
type experimentMain interface {
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
|
||||
"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/model"
|
||||
)
|
||||
|
||||
type urlGetterMain struct{}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"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/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/signal"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"time"
|
||||
|
||||
"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/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// TODO(bassosimone): we should use internal/netxlite/mocks rather
|
||||
// TODO(bassosimone): we should use internal/model/mocks rather
|
||||
// than rolling out a custom type private to this package.
|
||||
|
||||
type FakeConn struct {
|
||||
|
|
|
@ -12,11 +12,11 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"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/trace"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/pion/stun"
|
||||
)
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/pion/stun"
|
||||
)
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"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/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/telegram"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/tlstool/internal"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/tlstool"
|
||||
"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/model"
|
||||
)
|
||||
|
||||
func TestMeasurerExperimentNameVersion(t *testing.T) {
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netxlogger"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/oonidatamodel"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/oonitemplates"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
"github.com/ooni/probe-cli/v3/internal/scrubber"
|
||||
|
@ -144,14 +144,14 @@ func (tk *TestKeys) fillToplevelKeys() {
|
|||
// Measurer performs the measurement.
|
||||
type Measurer struct {
|
||||
config Config
|
||||
fetchTorTargets func(ctx context.Context, sess model.ExperimentSession, cc string) (map[string]model.TorTarget, error)
|
||||
fetchTorTargets func(ctx context.Context, sess model.ExperimentSession, cc string) (map[string]model.OOAPITorTarget, error)
|
||||
}
|
||||
|
||||
// NewMeasurer creates a new Measurer
|
||||
func NewMeasurer(config Config) *Measurer {
|
||||
return &Measurer{
|
||||
config: config,
|
||||
fetchTorTargets: func(ctx context.Context, sess model.ExperimentSession, cc string) (map[string]model.TorTarget, error) {
|
||||
fetchTorTargets: func(ctx context.Context, sess model.ExperimentSession, cc string) (map[string]model.OOAPITorTarget, error) {
|
||||
return sess.FetchTorTargets(ctx, cc)
|
||||
},
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ func (m *Measurer) Run(
|
|||
|
||||
func (m *Measurer) gimmeTargets(
|
||||
ctx context.Context, sess model.ExperimentSession,
|
||||
) (map[string]model.TorTarget, error) {
|
||||
) (map[string]model.OOAPITorTarget, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
|
||||
defer cancel()
|
||||
return m.fetchTorTargets(ctx, sess, sess.ProbeCC())
|
||||
|
@ -198,7 +198,7 @@ func (m *Measurer) gimmeTargets(
|
|||
// keytarget contains a key and the related target
|
||||
type keytarget struct {
|
||||
key string
|
||||
target model.TorTarget
|
||||
target model.OOAPITorTarget
|
||||
}
|
||||
|
||||
// private returns whether a target is private. We consider private
|
||||
|
@ -222,7 +222,7 @@ func (m *Measurer) measureTargets(
|
|||
sess model.ExperimentSession,
|
||||
measurement *model.Measurement,
|
||||
callbacks model.ExperimentCallbacks,
|
||||
targets map[string]model.TorTarget,
|
||||
targets map[string]model.OOAPITorTarget,
|
||||
) {
|
||||
// run measurements in parallel
|
||||
var waitgroup sync.WaitGroup
|
||||
|
@ -327,7 +327,7 @@ func maybeScrubbingLogger(input model.Logger, kt keytarget) model.Logger {
|
|||
if !kt.private() {
|
||||
return input
|
||||
}
|
||||
return &scrubber.Logger{UnderlyingLogger: input}
|
||||
return &scrubber.Logger{Logger: input}
|
||||
}
|
||||
|
||||
func (rc *resultsCollector) defaultFlexibleConnect(
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/oonidatamodel"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/oonitemplates"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/scrubber"
|
||||
)
|
||||
|
@ -34,7 +34,7 @@ func TestNewExperimentMeasurer(t *testing.T) {
|
|||
func TestMeasurerMeasureFetchTorTargetsError(t *testing.T) {
|
||||
measurer := NewMeasurer(Config{})
|
||||
expected := errors.New("mocked error")
|
||||
measurer.fetchTorTargets = func(ctx context.Context, sess model.ExperimentSession, cc string) (map[string]model.TorTarget, error) {
|
||||
measurer.fetchTorTargets = func(ctx context.Context, sess model.ExperimentSession, cc string) (map[string]model.OOAPITorTarget, error) {
|
||||
return nil, expected
|
||||
}
|
||||
err := measurer.Run(
|
||||
|
@ -52,7 +52,7 @@ func TestMeasurerMeasureFetchTorTargetsError(t *testing.T) {
|
|||
|
||||
func TestMeasurerMeasureFetchTorTargetsEmptyList(t *testing.T) {
|
||||
measurer := NewMeasurer(Config{})
|
||||
measurer.fetchTorTargets = func(ctx context.Context, sess model.ExperimentSession, cc string) (map[string]model.TorTarget, error) {
|
||||
measurer.fetchTorTargets = func(ctx context.Context, sess model.ExperimentSession, cc string) (map[string]model.OOAPITorTarget, error) {
|
||||
return nil, nil
|
||||
}
|
||||
measurement := new(model.Measurement)
|
||||
|
@ -77,7 +77,7 @@ func TestMeasurerMeasureGoodWithMockedOrchestra(t *testing.T) {
|
|||
// This test mocks orchestra to return a nil list of targets, so the code runs
|
||||
// but we don't perform any actual network actions.
|
||||
measurer := NewMeasurer(Config{})
|
||||
measurer.fetchTorTargets = func(ctx context.Context, sess model.ExperimentSession, cc string) (map[string]model.TorTarget, error) {
|
||||
measurer.fetchTorTargets = func(ctx context.Context, sess model.ExperimentSession, cc string) (map[string]model.OOAPITorTarget, error) {
|
||||
return nil, nil
|
||||
}
|
||||
err := measurer.Run(
|
||||
|
@ -120,7 +120,7 @@ func TestMeasurerMeasureGood(t *testing.T) {
|
|||
|
||||
var staticPrivateTestingTargetEndpoint = "192.95.36.142:443"
|
||||
|
||||
var staticPrivateTestingTarget = model.TorTarget{
|
||||
var staticPrivateTestingTarget = model.OOAPITorTarget{
|
||||
Address: staticPrivateTestingTargetEndpoint,
|
||||
Params: map[string][]string{
|
||||
"cert": {
|
||||
|
@ -139,7 +139,7 @@ func TestMeasurerMeasureSanitiseOutput(t *testing.T) {
|
|||
measurer := NewMeasurer(Config{})
|
||||
sess := newsession()
|
||||
key := "xyz-xyz-xyz-theCh2ju-ahG4chei-Ai2eka0a"
|
||||
sess.MockableFetchTorTargetsResult = map[string]model.TorTarget{
|
||||
sess.MockableFetchTorTargetsResult = map[string]model.OOAPITorTarget{
|
||||
key: staticPrivateTestingTarget,
|
||||
}
|
||||
measurement := new(model.Measurement)
|
||||
|
@ -172,7 +172,7 @@ func TestMeasurerMeasureSanitiseOutput(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
var staticTestingTargets = []model.TorTarget{
|
||||
var staticTestingTargets = []model.OOAPITorTarget{
|
||||
{
|
||||
Address: "192.95.36.142:443",
|
||||
Params: map[string][]string{
|
||||
|
@ -226,7 +226,7 @@ func TestMeasurerMeasureTargetsCanceledContext(t *testing.T) {
|
|||
},
|
||||
&measurement,
|
||||
model.NewPrinterCallbacks(log.Log),
|
||||
map[string]model.TorTarget{
|
||||
map[string]model.OOAPITorTarget{
|
||||
"xx": staticTestingTargets[0],
|
||||
},
|
||||
)
|
||||
|
@ -243,7 +243,7 @@ func TestMeasurerMeasureTargetsCanceledContext(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func wrapTestingTarget(tt model.TorTarget) keytarget {
|
||||
func wrapTestingTarget(tt model.OOAPITorTarget) keytarget {
|
||||
return keytarget{
|
||||
key: "xx", // using an super simple key; should work anyway
|
||||
target: tt,
|
||||
|
@ -683,7 +683,7 @@ func TestMaybeSanitize(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
t.Run("nothing to do", func(t *testing.T) {
|
||||
out := maybeSanitize(input, keytarget{target: model.TorTarget{Source: ""}})
|
||||
out := maybeSanitize(input, keytarget{target: model.OOAPITorTarget{Source: ""}})
|
||||
diff := cmp.Diff(input, out)
|
||||
if diff != "" {
|
||||
t.Fatal(diff)
|
||||
|
@ -694,7 +694,7 @@ func TestMaybeSanitize(t *testing.T) {
|
|||
if err := json.Unmarshal(scrubbedTargetResult, &expected); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
out := maybeSanitize(input, keytarget{target: model.TorTarget{
|
||||
out := maybeSanitize(input, keytarget{target: model.OOAPITorTarget{
|
||||
Address: "85.31.186.98:443",
|
||||
Source: "bridgedb",
|
||||
}})
|
||||
|
@ -709,7 +709,7 @@ func TestMaybeScrubbingLogger(t *testing.T) {
|
|||
var input model.Logger = log.Log
|
||||
|
||||
t.Run("for when we don't need to save", func(t *testing.T) {
|
||||
kt := keytarget{target: model.TorTarget{
|
||||
kt := keytarget{target: model.OOAPITorTarget{
|
||||
Source: "",
|
||||
}}
|
||||
out := maybeScrubbingLogger(input, kt)
|
||||
|
@ -722,7 +722,7 @@ func TestMaybeScrubbingLogger(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("for when we need to save", func(t *testing.T) {
|
||||
kt := keytarget{target: model.TorTarget{
|
||||
kt := keytarget{target: model.OOAPITorTarget{
|
||||
Source: "bridgedb",
|
||||
}}
|
||||
out := maybeScrubbingLogger(input, kt)
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/torsf"
|
||||
"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/model"
|
||||
"golang.org/x/sys/execabs"
|
||||
)
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
"path"
|
||||
"time"
|
||||
|
||||
"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/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/ptx"
|
||||
"github.com/ooni/probe-cli/v3/internal/tunnel"
|
||||
)
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/tunnel"
|
||||
)
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"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/trace"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
"time"
|
||||
|
||||
legacyerrorsx "github.com/ooni/probe-cli/v3/internal/engine/legacy/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/tunnel"
|
||||
)
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
// MultiInput is the input for Multi.Run().
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
func TestMultiIntegration(t *testing.T) {
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
"crypto/x509"
|
||||
"time"
|
||||
|
||||
"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/model"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
func TestMeasurer(t *testing.T) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"time"
|
||||
|
||||
"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/model"
|
||||
)
|
||||
|
||||
// ConnectsConfig contains the config for Connects
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/ooni/probe-cli/v3/internal/engine/geolocate"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
|
||||
legacyerrorsx "github.com/ooni/probe-cli/v3/internal/engine/legacy/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
"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/model"
|
||||
)
|
||||
|
||||
// DNSLookupConfig contains settings for the DNS lookup.
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"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/model"
|
||||
)
|
||||
|
||||
// HTTPAnalysisResult contains the results of the analysis performed on the
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"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/model"
|
||||
)
|
||||
|
||||
// HTTPGetConfig contains the config for HTTPGet
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"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/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ import (
|
|||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity/internal"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
|
||||
"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/model"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -149,7 +149,7 @@ func (m Measurer) Run(
|
|||
}
|
||||
// 1. find test helper
|
||||
testhelpers, _ := sess.GetTestHelpersByName("web-connectivity")
|
||||
var testhelper *model.Service
|
||||
var testhelper *model.OOAPIService
|
||||
for _, th := range testhelpers {
|
||||
if th.Type == "https" {
|
||||
testhelper = &th
|
||||
|
|
|
@ -11,8 +11,8 @@ 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/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
@ -202,7 +202,7 @@ func TestMeasureWithNoAvailableTestHelpers(t *testing.T) {
|
|||
|
||||
func newsession(t *testing.T, lookupBackends bool) model.ExperimentSession {
|
||||
sess, err := engine.NewSession(context.Background(), engine.SessionConfig{
|
||||
AvailableProbeServices: []model.Service{{
|
||||
AvailableProbeServices: []model.OOAPIService{{
|
||||
Address: "https://ams-pg-test.ooni.org",
|
||||
Type: "https",
|
||||
}},
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
|
||||
errorsxlegacy "github.com/ooni/probe-cli/v3/internal/engine/legacy/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
oohttp "github.com/ooni/oohttp"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/quicdialer"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
)
|
||||
|
@ -80,7 +81,7 @@ func NewSingleTransport(conn net.Conn) http.RoundTripper {
|
|||
}
|
||||
|
||||
// NewSingleTransport creates a new HTTP transport with a custom dialer and handshaker.
|
||||
func NewTransportWithDialer(dialer netxlite.DialerLegacy, tlsConfig *tls.Config, handshaker netxlite.TLSHandshaker) http.RoundTripper {
|
||||
func NewTransportWithDialer(dialer netxlite.DialerLegacy, tlsConfig *tls.Config, handshaker model.TLSHandshaker) http.RoundTripper {
|
||||
transport := newBaseTransport()
|
||||
transport.DialContext = dialer.DialContext
|
||||
transport.DialTLSContext = (&netxlite.TLSDialerLegacy{
|
||||
|
|
|
@ -24,8 +24,8 @@ import (
|
|||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
|
||||
"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/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
)
|
||||
|
||||
|
@ -111,7 +111,7 @@ func (m Measurer) Run(
|
|||
// 3. Find the testhelper
|
||||
// TODO(kelmenhorst,bassosimone): this is not used at the moment, but the hardcoded local address
|
||||
testhelpers, _ := sess.GetTestHelpersByName("web-connectivity")
|
||||
var testhelper *model.Service
|
||||
var testhelper *model.OOAPIService
|
||||
for _, th := range testhelpers {
|
||||
if th.Type == "https" {
|
||||
testhelper = &th
|
||||
|
|
|
@ -13,9 +13,9 @@ import (
|
|||
"net/url"
|
||||
"time"
|
||||
|
||||
"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/measurex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
|
@ -85,7 +85,7 @@ func (mx *Measurer) RunAsync(
|
|||
}
|
||||
// 2. Find the testhelper
|
||||
testhelpers, _ := sess.GetTestHelpersByName("web-connectivity")
|
||||
var testhelper *model.Service
|
||||
var testhelper *model.OOAPIService
|
||||
for _, th := range testhelpers {
|
||||
if th.Type == "https" {
|
||||
testhelper = &th
|
||||
|
@ -110,7 +110,7 @@ var measurerResolvers = []*measurex.ResolverInfo{{
|
|||
}}
|
||||
|
||||
func (mx *Measurer) runAsync(ctx context.Context, sess model.ExperimentSession,
|
||||
URL string, th *model.Service, out chan<- *model.ExperimentAsyncTestKeys) {
|
||||
URL string, th *model.OOAPIService, out chan<- *model.ExperimentAsyncTestKeys) {
|
||||
defer close(out)
|
||||
helper := &measurerMeasureURLHelper{
|
||||
Clnt: sess.DefaultHTTPClient(),
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpfailure"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/whatsapp"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpfailure"
|
||||
"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/model"
|
||||
)
|
||||
|
||||
func TestNewExperimentMeasurer(t *testing.T) {
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/example"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
func TestCreateAll(t *testing.T) {
|
||||
|
@ -454,7 +454,7 @@ func TestOpenReportFailure(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
exp := builder.NewExperiment()
|
||||
exp.session.selectedProbeService = &model.Service{
|
||||
exp.session.selectedProbeService = &model.OOAPIService{
|
||||
Address: server.URL,
|
||||
Type: "https",
|
||||
}
|
||||
|
@ -475,7 +475,7 @@ func TestOpenReportNewClientFailure(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
exp := builder.NewExperiment()
|
||||
exp.session.selectedProbeService = &model.Service{
|
||||
exp.session.selectedProbeService = &model.OOAPIService{
|
||||
Address: "antani:///",
|
||||
Type: "antani",
|
||||
}
|
||||
|
@ -523,7 +523,7 @@ func TestOpenReportNonHTTPS(t *testing.T) {
|
|||
}
|
||||
sess := newSessionForTestingNoLookups(t)
|
||||
defer sess.Close()
|
||||
sess.availableProbeServices = []model.Service{
|
||||
sess.availableProbeServices = []model.OOAPIService{
|
||||
{
|
||||
Address: "antani",
|
||||
Type: "mascetti",
|
||||
|
|
|
@ -3,7 +3,7 @@ package engine
|
|||
import (
|
||||
"os"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
func (e *Experiment) SaveMeasurementEx(
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"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/model"
|
||||
)
|
||||
|
||||
func TestExperimentHonoursSharingDefaults(t *testing.T) {
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/iancoleman/strcase"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
// InputPolicy describes the experiment policy with respect to input. That is
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
type avastResponse struct {
|
||||
|
@ -14,7 +15,7 @@ type avastResponse struct {
|
|||
func avastIPLookup(
|
||||
ctx context.Context,
|
||||
httpClient *http.Client,
|
||||
logger Logger,
|
||||
logger model.Logger,
|
||||
userAgent string,
|
||||
) (string, error) {
|
||||
var v avastResponse
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/version"
|
||||
)
|
||||
|
||||
|
@ -17,7 +18,7 @@ const (
|
|||
DefaultProbeCC = "ZZ"
|
||||
|
||||
// DefaultProbeIP is the default probe IP.
|
||||
DefaultProbeIP = "127.0.0.1"
|
||||
DefaultProbeIP = model.DefaultProbeIP
|
||||
|
||||
// DefaultProbeNetworkName is the default probe network name.
|
||||
DefaultProbeNetworkName = ""
|
||||
|
@ -40,13 +41,6 @@ var (
|
|||
DefaultResolverASNString = fmt.Sprintf("AS%d", DefaultResolverASN)
|
||||
)
|
||||
|
||||
// Logger is the definition of Logger used by this package.
|
||||
type Logger interface {
|
||||
Debug(msg string)
|
||||
Debugf(format string, v ...interface{})
|
||||
Infof(format string, v ...interface{})
|
||||
}
|
||||
|
||||
// Results contains geolocate results.
|
||||
type Results struct {
|
||||
// ASN is the autonomous system number.
|
||||
|
@ -111,26 +105,17 @@ type Config struct {
|
|||
|
||||
// Logger is the logger to use. If not set, then we will
|
||||
// use a logger that discards all messages.
|
||||
Logger Logger
|
||||
Logger model.Logger
|
||||
|
||||
// UserAgent is the user agent to use. If not set, then
|
||||
// we will use a default user agent.
|
||||
UserAgent string
|
||||
}
|
||||
|
||||
// discardLogger just ignores log messages thrown at it.
|
||||
type discardLogger struct{}
|
||||
|
||||
func (*discardLogger) Debug(msg string) {}
|
||||
|
||||
func (*discardLogger) Debugf(format string, v ...interface{}) {}
|
||||
|
||||
func (*discardLogger) Infof(format string, v ...interface{}) {}
|
||||
|
||||
// NewTask creates a new instance of Task from config.
|
||||
func NewTask(config Config) *Task {
|
||||
if config.Logger == nil {
|
||||
config.Logger = &discardLogger{}
|
||||
config.Logger = model.DiscardLogger
|
||||
}
|
||||
if config.UserAgent == "" {
|
||||
config.UserAgent = fmt.Sprintf("ooniprobe-engine/%s", version.Version)
|
||||
|
|
|
@ -3,12 +3,14 @@ package geolocate
|
|||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
func invalidIPLookup(
|
||||
ctx context.Context,
|
||||
httpClient *http.Client,
|
||||
logger Logger,
|
||||
logger model.Logger,
|
||||
userAgent string,
|
||||
) (string, error) {
|
||||
return "invalid IP", nil
|
||||
|
|
|
@ -7,12 +7,13 @@ import (
|
|||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
func ipConfigIPLookup(
|
||||
ctx context.Context,
|
||||
httpClient *http.Client,
|
||||
logger Logger,
|
||||
logger model.Logger,
|
||||
userAgent string,
|
||||
) (string, error) {
|
||||
data, err := (httpx.Client{
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
type ipInfoResponse struct {
|
||||
|
@ -15,7 +16,7 @@ type ipInfoResponse struct {
|
|||
func ipInfoIPLookup(
|
||||
ctx context.Context,
|
||||
httpClient *http.Client,
|
||||
logger Logger,
|
||||
logger model.Logger,
|
||||
userAgent string,
|
||||
) (string, error) {
|
||||
var v ipInfoResponse
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/multierror"
|
||||
)
|
||||
|
||||
|
@ -25,7 +26,7 @@ var (
|
|||
|
||||
type lookupFunc func(
|
||||
ctx context.Context, client *http.Client,
|
||||
logger Logger, userAgent string,
|
||||
logger model.Logger, userAgent string,
|
||||
) (string, error)
|
||||
|
||||
type method struct {
|
||||
|
@ -67,7 +68,7 @@ type ipLookupClient struct {
|
|||
Resolver Resolver
|
||||
|
||||
// Logger is the logger to use
|
||||
Logger Logger
|
||||
Logger model.Logger
|
||||
|
||||
// UserAgent is the user agent to use
|
||||
UserAgent string
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/pion/stun"
|
||||
)
|
||||
|
||||
|
@ -20,7 +21,7 @@ type stunClient interface {
|
|||
type stunConfig struct {
|
||||
Dial func(network string, address string) (stunClient, error)
|
||||
Endpoint string
|
||||
Logger Logger
|
||||
Logger model.Logger
|
||||
}
|
||||
|
||||
func stunDialer(network string, address string) (stunClient, error) {
|
||||
|
@ -75,7 +76,7 @@ func stunIPLookup(ctx context.Context, config stunConfig) (string, error) {
|
|||
func stunEkigaIPLookup(
|
||||
ctx context.Context,
|
||||
httpClient *http.Client,
|
||||
logger Logger,
|
||||
logger model.Logger,
|
||||
userAgent string,
|
||||
) (string, error) {
|
||||
return stunIPLookup(ctx, stunConfig{
|
||||
|
@ -87,7 +88,7 @@ func stunEkigaIPLookup(
|
|||
func stunGoogleIPLookup(
|
||||
ctx context.Context,
|
||||
httpClient *http.Client,
|
||||
logger Logger,
|
||||
logger model.Logger,
|
||||
userAgent string,
|
||||
) (string, error) {
|
||||
return stunIPLookup(ctx, stunConfig{
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
type ubuntuResponse struct {
|
||||
|
@ -16,7 +17,7 @@ type ubuntuResponse struct {
|
|||
func ubuntuIPLookup(
|
||||
ctx context.Context,
|
||||
httpClient *http.Client,
|
||||
logger Logger,
|
||||
logger model.Logger,
|
||||
userAgent string,
|
||||
) (string, error) {
|
||||
data, err := (httpx.Client{
|
||||
|
|
|
@ -10,14 +10,10 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
// Logger is the definition of Logger used by this package.
|
||||
type Logger interface {
|
||||
Debugf(format string, v ...interface{})
|
||||
}
|
||||
|
||||
// Client is an extended client.
|
||||
type Client struct {
|
||||
// Accept contains the accept header.
|
||||
|
@ -37,7 +33,7 @@ type Client struct {
|
|||
Host string
|
||||
|
||||
// Logger is the logger to use.
|
||||
Logger Logger
|
||||
Logger model.DebugLogger
|
||||
|
||||
// UserAgent is the user agent to use.
|
||||
UserAgent string
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
"net/url"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/fsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/stuninput"
|
||||
)
|
||||
|
||||
|
@ -27,7 +27,7 @@ var (
|
|||
// introduce this abstraction because it helps us with testing.
|
||||
type InputLoaderSession interface {
|
||||
CheckIn(ctx context.Context,
|
||||
config *model.CheckInConfig) (*model.CheckInInfo, error)
|
||||
config *model.OOAPICheckInConfig) (*model.OOAPICheckInInfo, error)
|
||||
}
|
||||
|
||||
// InputLoaderLogger is the logger according to an InputLoader.
|
||||
|
@ -76,7 +76,7 @@ type InputLoader struct {
|
|||
// not set, then we'll create a default config. If set but
|
||||
// there are fields inside it that are not set, then we
|
||||
// will set them to a default value.
|
||||
CheckInConfig *model.CheckInConfig
|
||||
CheckInConfig *model.OOAPICheckInConfig
|
||||
|
||||
// ExperimentName is the name of the experiment. This field
|
||||
// is only used together with the InputOrStaticDefault policy.
|
||||
|
@ -110,7 +110,7 @@ type InputLoader struct {
|
|||
|
||||
// Load attempts to load input using the specified input loader. We will
|
||||
// return a list of URLs because this is the only input we support.
|
||||
func (il *InputLoader) Load(ctx context.Context) ([]model.URLInfo, error) {
|
||||
func (il *InputLoader) Load(ctx context.Context) ([]model.OOAPIURLInfo, error) {
|
||||
switch il.InputPolicy {
|
||||
case InputOptional:
|
||||
return il.loadOptional()
|
||||
|
@ -126,26 +126,26 @@ func (il *InputLoader) Load(ctx context.Context) ([]model.URLInfo, error) {
|
|||
}
|
||||
|
||||
// loadNone implements the InputNone policy.
|
||||
func (il *InputLoader) loadNone() ([]model.URLInfo, error) {
|
||||
func (il *InputLoader) loadNone() ([]model.OOAPIURLInfo, error) {
|
||||
if len(il.StaticInputs) > 0 || len(il.SourceFiles) > 0 {
|
||||
return nil, ErrNoInputExpected
|
||||
}
|
||||
// Note that we need to return a single empty entry.
|
||||
return []model.URLInfo{{}}, nil
|
||||
return []model.OOAPIURLInfo{{}}, nil
|
||||
}
|
||||
|
||||
// loadOptional implements the InputOptional policy.
|
||||
func (il *InputLoader) loadOptional() ([]model.URLInfo, error) {
|
||||
func (il *InputLoader) loadOptional() ([]model.OOAPIURLInfo, error) {
|
||||
inputs, err := il.loadLocal()
|
||||
if err == nil && len(inputs) <= 0 {
|
||||
// Note that we need to return a single empty entry.
|
||||
inputs = []model.URLInfo{{}}
|
||||
inputs = []model.OOAPIURLInfo{{}}
|
||||
}
|
||||
return inputs, err
|
||||
}
|
||||
|
||||
// loadStrictlyRequired implements the InputStrictlyRequired policy.
|
||||
func (il *InputLoader) loadStrictlyRequired(ctx context.Context) ([]model.URLInfo, error) {
|
||||
func (il *InputLoader) loadStrictlyRequired(ctx context.Context) ([]model.OOAPIURLInfo, error) {
|
||||
inputs, err := il.loadLocal()
|
||||
if err != nil || len(inputs) > 0 {
|
||||
return inputs, err
|
||||
|
@ -154,7 +154,7 @@ func (il *InputLoader) loadStrictlyRequired(ctx context.Context) ([]model.URLInf
|
|||
}
|
||||
|
||||
// loadOrQueryBackend implements the InputOrQueryBackend policy.
|
||||
func (il *InputLoader) loadOrQueryBackend(ctx context.Context) ([]model.URLInfo, error) {
|
||||
func (il *InputLoader) loadOrQueryBackend(ctx context.Context) ([]model.OOAPIURLInfo, error) {
|
||||
inputs, err := il.loadLocal()
|
||||
if err != nil || len(inputs) > 0 {
|
||||
return inputs, err
|
||||
|
@ -202,12 +202,12 @@ func StaticBareInputForExperiment(name string) ([]string, error) {
|
|||
|
||||
// staticInputForExperiment returns the static input for the given experiment
|
||||
// or an error if there's no static input for the experiment.
|
||||
func staticInputForExperiment(name string) ([]model.URLInfo, error) {
|
||||
func staticInputForExperiment(name string) ([]model.OOAPIURLInfo, error) {
|
||||
return stringListToModelURLInfo(StaticBareInputForExperiment(name))
|
||||
}
|
||||
|
||||
// loadOrStaticDefault implements the InputOrStaticDefault policy.
|
||||
func (il *InputLoader) loadOrStaticDefault(ctx context.Context) ([]model.URLInfo, error) {
|
||||
func (il *InputLoader) loadOrStaticDefault(ctx context.Context) ([]model.OOAPIURLInfo, error) {
|
||||
inputs, err := il.loadLocal()
|
||||
if err != nil || len(inputs) > 0 {
|
||||
return inputs, err
|
||||
|
@ -216,10 +216,10 @@ func (il *InputLoader) loadOrStaticDefault(ctx context.Context) ([]model.URLInfo
|
|||
}
|
||||
|
||||
// loadLocal loads inputs from StaticInputs and SourceFiles.
|
||||
func (il *InputLoader) loadLocal() ([]model.URLInfo, error) {
|
||||
inputs := []model.URLInfo{}
|
||||
func (il *InputLoader) loadLocal() ([]model.OOAPIURLInfo, error) {
|
||||
inputs := []model.OOAPIURLInfo{}
|
||||
for _, input := range il.StaticInputs {
|
||||
inputs = append(inputs, model.URLInfo{URL: input})
|
||||
inputs = append(inputs, model.OOAPIURLInfo{URL: input})
|
||||
}
|
||||
for _, filepath := range il.SourceFiles {
|
||||
extra, err := il.readfile(filepath, fsx.OpenFile)
|
||||
|
@ -240,8 +240,8 @@ type inputLoaderOpenFn func(filepath string) (fs.File, error)
|
|||
|
||||
// readfile reads inputs from the specified file. The open argument should be
|
||||
// compatible with stdlib's fs.Open and helps us with unit testing.
|
||||
func (il *InputLoader) readfile(filepath string, open inputLoaderOpenFn) ([]model.URLInfo, error) {
|
||||
inputs := []model.URLInfo{}
|
||||
func (il *InputLoader) readfile(filepath string, open inputLoaderOpenFn) ([]model.OOAPIURLInfo, error) {
|
||||
inputs := []model.OOAPIURLInfo{}
|
||||
filep, err := open(filepath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -254,7 +254,7 @@ func (il *InputLoader) readfile(filepath string, open inputLoaderOpenFn) ([]mode
|
|||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if line != "" {
|
||||
inputs = append(inputs, model.URLInfo{URL: line})
|
||||
inputs = append(inputs, model.OOAPIURLInfo{URL: line})
|
||||
}
|
||||
}
|
||||
if scanner.Err() != nil {
|
||||
|
@ -264,14 +264,14 @@ func (il *InputLoader) readfile(filepath string, open inputLoaderOpenFn) ([]mode
|
|||
}
|
||||
|
||||
// loadRemote loads inputs from a remote source.
|
||||
func (il *InputLoader) loadRemote(ctx context.Context) ([]model.URLInfo, error) {
|
||||
func (il *InputLoader) loadRemote(ctx context.Context) ([]model.OOAPIURLInfo, error) {
|
||||
config := il.CheckInConfig
|
||||
if config == nil {
|
||||
// Note: Session.CheckIn documentation says it will fill in
|
||||
// any field with a required value with a reasonable default
|
||||
// if such value is missing. So, here we just need to be
|
||||
// concerned about NOT passing it a NULL pointer.
|
||||
config = &model.CheckInConfig{}
|
||||
config = &model.OOAPICheckInConfig{}
|
||||
}
|
||||
reply, err := il.checkIn(ctx, config)
|
||||
if err != nil {
|
||||
|
@ -287,7 +287,7 @@ func (il *InputLoader) loadRemote(ctx context.Context) ([]model.URLInfo, error)
|
|||
// the URLs that are not part of the requested categories. This is done for
|
||||
// robustness, just in case we or the API do something wrong.
|
||||
func (il *InputLoader) checkIn(
|
||||
ctx context.Context, config *model.CheckInConfig) (*model.CheckInInfo, error) {
|
||||
ctx context.Context, config *model.OOAPICheckInConfig) (*model.OOAPICheckInInfo, error) {
|
||||
reply, err := il.Session.CheckIn(ctx, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -304,7 +304,7 @@ func (il *InputLoader) checkIn(
|
|||
// preventMistakes makes the code more robust with respect to any possible
|
||||
// integration issue where the backend returns to us URLs that don't
|
||||
// belong to the category codes we requested.
|
||||
func (il *InputLoader) preventMistakes(input []model.URLInfo, categories []string) (output []model.URLInfo) {
|
||||
func (il *InputLoader) preventMistakes(input []model.OOAPIURLInfo, categories []string) (output []model.OOAPIURLInfo) {
|
||||
if len(categories) <= 0 {
|
||||
return input
|
||||
}
|
||||
|
@ -338,16 +338,16 @@ func (il *InputLoader) logger() InputLoaderLogger {
|
|||
// which would have been returned by an hypothetical backend
|
||||
// API serving input for a test for which we don't have an API
|
||||
// yet (e.g., stunreachability and dnscheck).
|
||||
func stringListToModelURLInfo(input []string, err error) ([]model.URLInfo, error) {
|
||||
func stringListToModelURLInfo(input []string, err error) ([]model.OOAPIURLInfo, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var output []model.URLInfo
|
||||
var output []model.OOAPIURLInfo
|
||||
for _, URL := range input {
|
||||
if _, err := url.Parse(URL); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
output = append(output, model.URLInfo{
|
||||
output = append(output, model.OOAPIURLInfo{
|
||||
CategoryCode: "MISC", // hard to find a category
|
||||
CountryCode: "XX", // representing no country
|
||||
URL: URL,
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
|
||||
"github.com/apex/log"
|
||||
engine "github.com/ooni/probe-cli/v3/internal/engine"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/kvstore"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
func TestInputLoaderInputOrQueryBackendWithNoInput(t *testing.T) {
|
||||
|
@ -15,7 +15,7 @@ func TestInputLoaderInputOrQueryBackendWithNoInput(t *testing.T) {
|
|||
t.Skip("skip test in short mode")
|
||||
}
|
||||
sess, err := engine.NewSession(context.Background(), engine.SessionConfig{
|
||||
AvailableProbeServices: []model.Service{{
|
||||
AvailableProbeServices: []model.OOAPIService{{
|
||||
Address: "https://ams-pg-test.ooni.org/",
|
||||
Type: "https",
|
||||
}},
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
|
||||
"github.com/apex/log"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/kvstore"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
func TestInputLoaderInputNoneWithStaticInputs(t *testing.T) {
|
||||
|
@ -113,7 +113,7 @@ func TestInputLoaderInputOptionalWithInput(t *testing.T) {
|
|||
if len(out) != 5 {
|
||||
t.Fatal("not the output length we expected")
|
||||
}
|
||||
expect := []model.URLInfo{
|
||||
expect := []model.OOAPIURLInfo{
|
||||
{URL: "https://www.google.com/"},
|
||||
{URL: "https://www.x.org/"},
|
||||
{URL: "https://www.slashdot.org/"},
|
||||
|
@ -162,7 +162,7 @@ func TestInputLoaderInputStrictlyRequiredWithInput(t *testing.T) {
|
|||
if len(out) != 5 {
|
||||
t.Fatal("not the output length we expected")
|
||||
}
|
||||
expect := []model.URLInfo{
|
||||
expect := []model.OOAPIURLInfo{
|
||||
{URL: "https://www.google.com/"},
|
||||
{URL: "https://www.x.org/"},
|
||||
{URL: "https://www.slashdot.org/"},
|
||||
|
@ -225,7 +225,7 @@ func TestInputLoaderInputOrStaticDefaultWithInput(t *testing.T) {
|
|||
if len(out) != 5 {
|
||||
t.Fatal("not the output length we expected")
|
||||
}
|
||||
expect := []model.URLInfo{
|
||||
expect := []model.OOAPIURLInfo{
|
||||
{URL: "https://www.google.com/"},
|
||||
{URL: "https://www.x.org/"},
|
||||
{URL: "https://www.slashdot.org/"},
|
||||
|
@ -352,7 +352,7 @@ func TestInputLoaderInputOrQueryBackendWithInput(t *testing.T) {
|
|||
if len(out) != 5 {
|
||||
t.Fatal("not the output length we expected")
|
||||
}
|
||||
expect := []model.URLInfo{
|
||||
expect := []model.OOAPIURLInfo{
|
||||
{URL: "https://www.google.com/"},
|
||||
{URL: "https://www.x.org/"},
|
||||
{URL: "https://www.slashdot.org/"},
|
||||
|
@ -446,7 +446,7 @@ func TestInputLoaderReadfileScannerFailure(t *testing.T) {
|
|||
type InputLoaderMockableSession struct {
|
||||
// Output contains the output of CheckIn. It should
|
||||
// be nil when Error is not-nil.
|
||||
Output *model.CheckInInfo
|
||||
Output *model.OOAPICheckInInfo
|
||||
|
||||
// Error is the error to be returned by CheckIn. It
|
||||
// should be nil when Output is not-nil.
|
||||
|
@ -455,7 +455,7 @@ type InputLoaderMockableSession struct {
|
|||
|
||||
// CheckIn implements InputLoaderSession.CheckIn.
|
||||
func (sess *InputLoaderMockableSession) CheckIn(
|
||||
ctx context.Context, config *model.CheckInConfig) (*model.CheckInInfo, error) {
|
||||
ctx context.Context, config *model.OOAPICheckInConfig) (*model.OOAPICheckInInfo, error) {
|
||||
if sess.Output == nil && sess.Error == nil {
|
||||
return nil, errors.New("both Output and Error are nil")
|
||||
}
|
||||
|
@ -480,7 +480,7 @@ func TestInputLoaderCheckInFailure(t *testing.T) {
|
|||
func TestInputLoaderCheckInSuccessWithNilWebConnectivity(t *testing.T) {
|
||||
il := &InputLoader{
|
||||
Session: &InputLoaderMockableSession{
|
||||
Output: &model.CheckInInfo{},
|
||||
Output: &model.OOAPICheckInInfo{},
|
||||
},
|
||||
}
|
||||
out, err := il.loadRemote(context.Background())
|
||||
|
@ -495,8 +495,8 @@ func TestInputLoaderCheckInSuccessWithNilWebConnectivity(t *testing.T) {
|
|||
func TestInputLoaderCheckInSuccessWithNoURLs(t *testing.T) {
|
||||
il := &InputLoader{
|
||||
Session: &InputLoaderMockableSession{
|
||||
Output: &model.CheckInInfo{
|
||||
WebConnectivity: &model.CheckInInfoWebConnectivity{},
|
||||
Output: &model.OOAPICheckInInfo{
|
||||
WebConnectivity: &model.OOAPICheckInInfoWebConnectivity{},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ func TestInputLoaderCheckInSuccessWithNoURLs(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestInputLoaderCheckInSuccessWithSomeURLs(t *testing.T) {
|
||||
expect := []model.URLInfo{{
|
||||
expect := []model.OOAPIURLInfo{{
|
||||
CategoryCode: "NEWS",
|
||||
CountryCode: "IT",
|
||||
URL: "https://repubblica.it",
|
||||
|
@ -521,8 +521,8 @@ func TestInputLoaderCheckInSuccessWithSomeURLs(t *testing.T) {
|
|||
}}
|
||||
il := &InputLoader{
|
||||
Session: &InputLoaderMockableSession{
|
||||
Output: &model.CheckInInfo{
|
||||
WebConnectivity: &model.CheckInInfoWebConnectivity{
|
||||
Output: &model.OOAPICheckInInfo{
|
||||
WebConnectivity: &model.OOAPICheckInInfoWebConnectivity{
|
||||
URLs: expect,
|
||||
},
|
||||
},
|
||||
|
@ -538,7 +538,7 @@ func TestInputLoaderCheckInSuccessWithSomeURLs(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPreventMistakesWithCategories(t *testing.T) {
|
||||
input := []model.URLInfo{{
|
||||
input := []model.OOAPIURLInfo{{
|
||||
CategoryCode: "NEWS",
|
||||
URL: "https://repubblica.it/",
|
||||
CountryCode: "IT",
|
||||
|
@ -551,7 +551,7 @@ func TestPreventMistakesWithCategories(t *testing.T) {
|
|||
URL: "https://addons.mozilla.org/",
|
||||
CountryCode: "XX",
|
||||
}}
|
||||
desired := []model.URLInfo{{
|
||||
desired := []model.OOAPIURLInfo{{
|
||||
CategoryCode: "NEWS",
|
||||
URL: "https://repubblica.it/",
|
||||
CountryCode: "IT",
|
||||
|
@ -568,7 +568,7 @@ func TestPreventMistakesWithCategories(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPreventMistakesWithoutCategoriesAndNil(t *testing.T) {
|
||||
input := []model.URLInfo{{
|
||||
input := []model.OOAPIURLInfo{{
|
||||
CategoryCode: "NEWS",
|
||||
URL: "https://repubblica.it/",
|
||||
CountryCode: "IT",
|
||||
|
@ -589,7 +589,7 @@ func TestPreventMistakesWithoutCategoriesAndNil(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPreventMistakesWithoutCategoriesAndEmpty(t *testing.T) {
|
||||
input := []model.URLInfo{{
|
||||
input := []model.OOAPIURLInfo{{
|
||||
CategoryCode: "NEWS",
|
||||
URL: "https://repubblica.it/",
|
||||
CountryCode: "IT",
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
// InputProcessorExperiment is the Experiment
|
||||
|
@ -49,7 +49,7 @@ type InputProcessor struct {
|
|||
Experiment InputProcessorExperimentWrapper
|
||||
|
||||
// Inputs is the list of inputs to measure.
|
||||
Inputs []model.URLInfo
|
||||
Inputs []model.OOAPIURLInfo
|
||||
|
||||
// MaxRuntime is the optional maximum runtime
|
||||
// when looping over a list of inputs (e.g. when
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
type FakeInputProcessorExperiment struct {
|
||||
|
@ -44,7 +44,7 @@ func TestInputProcessorMeasurementFailed(t *testing.T) {
|
|||
Experiment: NewInputProcessorExperimentWrapper(
|
||||
&FakeInputProcessorExperiment{Err: expected},
|
||||
),
|
||||
Inputs: []model.URLInfo{{
|
||||
Inputs: []model.OOAPIURLInfo{{
|
||||
URL: "https://www.kernel.org/",
|
||||
}},
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ func TestInputProcessorSubmissionFailed(t *testing.T) {
|
|||
"foo": "bar",
|
||||
},
|
||||
Experiment: NewInputProcessorExperimentWrapper(fipe),
|
||||
Inputs: []model.URLInfo{{
|
||||
Inputs: []model.OOAPIURLInfo{{
|
||||
URL: "https://www.kernel.org/",
|
||||
}},
|
||||
Options: []string{"fake=true"},
|
||||
|
@ -122,7 +122,7 @@ func TestInputProcessorSaveOnDiskFailed(t *testing.T) {
|
|||
Experiment: NewInputProcessorExperimentWrapper(
|
||||
&FakeInputProcessorExperiment{},
|
||||
),
|
||||
Inputs: []model.URLInfo{{
|
||||
Inputs: []model.OOAPIURLInfo{{
|
||||
URL: "https://www.kernel.org/",
|
||||
}},
|
||||
Options: []string{"fake=true"},
|
||||
|
@ -145,7 +145,7 @@ func TestInputProcessorGood(t *testing.T) {
|
|||
submitter := &FakeInputProcessorSubmitter{Err: nil}
|
||||
ip := &InputProcessor{
|
||||
Experiment: NewInputProcessorExperimentWrapper(fipe),
|
||||
Inputs: []model.URLInfo{{
|
||||
Inputs: []model.OOAPIURLInfo{{
|
||||
URL: "https://www.kernel.org/",
|
||||
}, {
|
||||
URL: "https://www.slashdot.org/",
|
||||
|
@ -187,7 +187,7 @@ func TestInputProcessorMaxRuntime(t *testing.T) {
|
|||
submitter := &FakeInputProcessorSubmitter{Err: nil}
|
||||
ip := &InputProcessor{
|
||||
Experiment: NewInputProcessorExperimentWrapper(fipe),
|
||||
Inputs: []model.URLInfo{{
|
||||
Inputs: []model.OOAPIURLInfo{{
|
||||
URL: "https://www.kernel.org/",
|
||||
}, {
|
||||
URL: "https://www.slashdot.org/",
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
package sessionresolver
|
||||
|
||||
// KVStore is a generic key-value store. We use it to store
|
||||
// on disk persistent state used by this package.
|
||||
type KVStore interface {
|
||||
// Get gets the value for the given key.
|
||||
Get(key string) ([]byte, error)
|
||||
|
||||
// Set sets the value of the given key.
|
||||
Set(key string, value []byte) error
|
||||
}
|
||||
|
||||
// Logger defines the common logger interface.
|
||||
type Logger interface {
|
||||
// Debug emits a debug message.
|
||||
Debug(msg string)
|
||||
|
||||
// Debugf formats and emits a debug message.
|
||||
Debugf(format string, v ...interface{})
|
||||
|
||||
// Info emits an informational message.
|
||||
Info(msg string)
|
||||
|
||||
// Infof format and emits an informational message.
|
||||
Infof(format string, v ...interface{})
|
||||
|
||||
// Warn emits a warning message.
|
||||
Warn(msg string)
|
||||
|
||||
// Warnf formats and emits a warning message.
|
||||
Warnf(format string, v ...interface{})
|
||||
}
|
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/bytecounter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
// resolvemaker contains rules for making a resolver.
|
||||
|
@ -67,7 +68,7 @@ func (r *Resolver) byteCounter() *bytecounter.Counter {
|
|||
}
|
||||
|
||||
// logger returns the configured logger or a default
|
||||
func (r *Resolver) logger() Logger {
|
||||
func (r *Resolver) logger() model.Logger {
|
||||
if r.Logger != nil {
|
||||
return r.Logger
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/bytecounter"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/multierror"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
)
|
||||
|
@ -63,11 +64,11 @@ type Resolver struct {
|
|||
// KVStore is the MANDATORY key-value store where you
|
||||
// want us to write statistics about which resolver is
|
||||
// working better in your network.
|
||||
KVStore KVStore
|
||||
KVStore model.KeyValueStore
|
||||
|
||||
// Logger is the optional logger you want us to use
|
||||
// to emit log messages.
|
||||
Logger Logger
|
||||
Logger model.Logger
|
||||
|
||||
// ProxyURL is the optional URL of the socks5 proxy
|
||||
// we should be using. If not set, then we WON'T use
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package engine
|
||||
|
||||
// KVStore is a simple, atomic key-value store. The user of
|
||||
// probe-engine should supply an implementation of this interface,
|
||||
// which will be used by probe-engine to store specific data.
|
||||
type KVStore interface {
|
||||
Get(key string) (value []byte, err error)
|
||||
Set(key string, value []byte) (err error)
|
||||
}
|
|
@ -8,7 +8,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
|
||||
"github.com/ooni/probe-cli/v3/internal/model/mocks"
|
||||
)
|
||||
|
||||
func TestErrorWrapperDialerFailure(t *testing.T) {
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"net"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/quicx"
|
||||
)
|
||||
|
||||
// QUICContextDialer is a dialer for QUIC using Context.
|
||||
|
@ -22,7 +22,7 @@ type QUICContextDialer interface {
|
|||
// QUICListener listens for QUIC connections.
|
||||
type QUICListener interface {
|
||||
// Listen creates a new listening UDPConn.
|
||||
Listen(addr *net.UDPAddr) (quicx.UDPLikeConn, error)
|
||||
Listen(addr *net.UDPAddr) (model.UDPLikeConn, error)
|
||||
}
|
||||
|
||||
// ErrorWrapperQUICListener is a QUICListener that wraps errors.
|
||||
|
@ -34,7 +34,7 @@ type ErrorWrapperQUICListener struct {
|
|||
var _ QUICListener = &ErrorWrapperQUICListener{}
|
||||
|
||||
// Listen implements QUICListener.Listen.
|
||||
func (qls *ErrorWrapperQUICListener) Listen(addr *net.UDPAddr) (quicx.UDPLikeConn, error) {
|
||||
func (qls *ErrorWrapperQUICListener) Listen(addr *net.UDPAddr) (model.UDPLikeConn, error) {
|
||||
pconn, err := qls.QUICListener.Listen(addr)
|
||||
if err != nil {
|
||||
return nil, SafeErrWrapperBuilder{
|
||||
|
@ -45,15 +45,15 @@ func (qls *ErrorWrapperQUICListener) Listen(addr *net.UDPAddr) (quicx.UDPLikeCon
|
|||
return &errorWrapperUDPConn{pconn}, nil
|
||||
}
|
||||
|
||||
// errorWrapperUDPConn is a quicx.UDPLikeConn that wraps errors.
|
||||
// errorWrapperUDPConn is a model.UDPLikeConn that wraps errors.
|
||||
type errorWrapperUDPConn struct {
|
||||
// UDPLikeConn is the underlying conn.
|
||||
quicx.UDPLikeConn
|
||||
model.UDPLikeConn
|
||||
}
|
||||
|
||||
var _ quicx.UDPLikeConn = &errorWrapperUDPConn{}
|
||||
var _ model.UDPLikeConn = &errorWrapperUDPConn{}
|
||||
|
||||
// WriteTo implements quicx.UDPLikeConn.WriteTo.
|
||||
// WriteTo implements model.UDPLikeConn.WriteTo.
|
||||
func (c *errorWrapperUDPConn) WriteTo(p []byte, addr net.Addr) (int, error) {
|
||||
count, err := c.UDPLikeConn.WriteTo(p, addr)
|
||||
if err != nil {
|
||||
|
@ -65,7 +65,7 @@ func (c *errorWrapperUDPConn) WriteTo(p []byte, addr net.Addr) (int, error) {
|
|||
return count, nil
|
||||
}
|
||||
|
||||
// ReadFrom implements quicx.UDPLikeConn.ReadFrom.
|
||||
// ReadFrom implements model.UDPLikeConn.ReadFrom.
|
||||
func (c *errorWrapperUDPConn) ReadFrom(b []byte) (int, net.Addr, error) {
|
||||
n, addr, err := c.UDPLikeConn.ReadFrom(b)
|
||||
if err != nil {
|
||||
|
|
|
@ -9,15 +9,16 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/model/mocks"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/quicx"
|
||||
nlmocks "github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
|
||||
)
|
||||
|
||||
func TestErrorWrapperQUICListenerSuccess(t *testing.T) {
|
||||
ql := &ErrorWrapperQUICListener{
|
||||
QUICListener: &mocks.QUICListener{
|
||||
MockListen: func(addr *net.UDPAddr) (quicx.UDPLikeConn, error) {
|
||||
MockListen: func(addr *net.UDPAddr) (model.UDPLikeConn, error) {
|
||||
return &net.UDPConn{}, nil
|
||||
},
|
||||
},
|
||||
|
@ -32,7 +33,7 @@ func TestErrorWrapperQUICListenerSuccess(t *testing.T) {
|
|||
func TestErrorWrapperQUICListenerFailure(t *testing.T) {
|
||||
ql := &ErrorWrapperQUICListener{
|
||||
QUICListener: &mocks.QUICListener{
|
||||
MockListen: func(addr *net.UDPAddr) (quicx.UDPLikeConn, error) {
|
||||
MockListen: func(addr *net.UDPAddr) (model.UDPLikeConn, error) {
|
||||
return nil, io.EOF
|
||||
},
|
||||
},
|
||||
|
@ -130,7 +131,7 @@ func TestErrorWrapperUDPConnReadFromFailure(t *testing.T) {
|
|||
|
||||
func TestErrorWrapperQUICDialerFailure(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
d := &ErrorWrapperQUICDialer{Dialer: &mocks.QUICContextDialer{
|
||||
d := &ErrorWrapperQUICDialer{Dialer: &nlmocks.QUICContextDialer{
|
||||
MockDialContext: func(ctx context.Context, network, address string, tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error) {
|
||||
return nil, io.EOF
|
||||
},
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user