feat: use ooni/probe-engine@286613b74e and cleanup (#177)
* feat: use ooni/probe-engine@286613b74e and cleanup 1. zap unused configuration settings from the config file but do not bump the version number because doing that _may_ interact in unexpected ways with probe-desktop (hence https://github.com/ooni/probe/issues/1297) and also because we've just _removed_ stuff for now, therefore any previous configuration file will continue to work, except that we'll be ignoring a bunch of options. In a future version of probe-cli I'll spend some time to further improve config file management. 2. accordingly, make sure all current configuration files that are around in the tree are current and only feature supported options. 3. update to ooni/probe-engine@286613b74e, which contains a bunch of APIs that should allow us to simplify the interaction between the cli and the engine, by sharing code more cleverly. 4. zap GetTestKeys because now we use code in probe-engine instead. 5. zap LogSummary because it was not being used. 6. the main change related to cleaning up the config and to the update to the latest probe-engine is that include_{cc,asn,ip} settings are gone and we now share the CC and the ASN and we never share the IP addr. Reference issue: https://github.com/ooni/probe/issues/1283. After this change is landed, there's a bunch more work to do to further unify cli and engine. The final state will be that the cli uses ~the code used by miniooni, so it will have a bunch of desirable options. * fix: bindata after recent changes
This commit is contained in:
parent
e4ef279b80
commit
95906fbcce
|
@ -2,18 +2,12 @@
|
||||||
"_version": 1,
|
"_version": 1,
|
||||||
"_informed_consent": false,
|
"_informed_consent": false,
|
||||||
"sharing": {
|
"sharing": {
|
||||||
"include_ip": false,
|
|
||||||
"include_asn": true,
|
|
||||||
"include_country": true,
|
|
||||||
"upload_results": true
|
"upload_results": true
|
||||||
},
|
},
|
||||||
"nettests": {
|
"nettests": {
|
||||||
"websites_url_limit": 0
|
"websites_url_limit": 0
|
||||||
},
|
},
|
||||||
"advanced": {
|
"advanced": {
|
||||||
"use_domain_fronting": false,
|
"send_crash_reports": true
|
||||||
"send_crash_reports": true,
|
|
||||||
"collector_url": "",
|
|
||||||
"bouncer_url": "https://bouncer.ooni.io"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -13,7 +13,7 @@ require (
|
||||||
github.com/mattn/go-colorable v0.1.8
|
github.com/mattn/go-colorable v0.1.8
|
||||||
github.com/mattn/go-sqlite3 v1.14.5 // indirect
|
github.com/mattn/go-sqlite3 v1.14.5 // indirect
|
||||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
|
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
|
||||||
github.com/ooni/probe-engine v0.20.2
|
github.com/ooni/probe-engine v0.20.1-0.20201126115133-286613b74e6c
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/rubenv/sql-migrate v0.0.0-20200616145509-8d140a17f351
|
github.com/rubenv/sql-migrate v0.0.0-20200616145509-8d140a17f351
|
||||||
github.com/sirupsen/logrus v1.7.0 // indirect
|
github.com/sirupsen/logrus v1.7.0 // indirect
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -350,8 +350,8 @@ github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa
|
||||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||||
github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
|
github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
|
||||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||||
github.com/ooni/probe-engine v0.20.2 h1:QO4HsHw5lG8vshtV0MQwINuYlVnVPPqaVCq8Zx+9guQ=
|
github.com/ooni/probe-engine v0.20.1-0.20201126115133-286613b74e6c h1:+4uKh4ljd5Lui16QAKSKLw4Ld2NACDnuW7lxnUDZ8n8=
|
||||||
github.com/ooni/probe-engine v0.20.2/go.mod h1:58nNKsvU/jPjsQ8OZJFNu06l6yRJYYWfNE1JwGmbRwc=
|
github.com/ooni/probe-engine v0.20.1-0.20201126115133-286613b74e6c/go.mod h1:58nNKsvU/jPjsQ8OZJFNu06l6yRJYYWfNE1JwGmbRwc=
|
||||||
github.com/ooni/psiphon v0.1.0 h1:fUcDpzZSd2McI5GomHtwusQllYPQoq3ETM3GMfQxCQQ=
|
github.com/ooni/psiphon v0.1.0 h1:fUcDpzZSd2McI5GomHtwusQllYPQoq3ETM3GMfQxCQQ=
|
||||||
github.com/ooni/psiphon v0.1.0/go.mod h1:p+l7SBAGTH3bw9ALcLvlrz6ry+isIM2f51Y5yOhgmTQ=
|
github.com/ooni/psiphon v0.1.0/go.mod h1:p+l7SBAGTH3bw9ALcLvlrz6ry+isIM2f51Y5yOhgmTQ=
|
||||||
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
|
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
|
||||||
|
|
|
@ -80,7 +80,7 @@ func (fi bindataFileInfo) Sys() interface{} {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _bindataDataDefaultconfigJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x5c\x8f\x41\x4e\xc4\x30\x0c\x45\xf7\x3d\x85\x95\x35\x9a\x81\x6d\x2f\x63\x65\x12\x0f\xb5\x94\xda\x95\xed\x0c\x42\x68\xee\x8e\x5a\xaa\x52\xd8\xfe\x97\x9f\xff\xfc\x35\x00\x24\x7c\x90\x39\xab\xa4\x11\xde\x5e\xb6\x80\xe5\xae\x36\x53\xc5\xa2\xe2\x24\x91\x46\xb8\xe7\xe6\xb4\x51\x9f\xb2\xb1\xbc\xa7\x11\xd6\x36\x40\x62\x29\xad\x57\x42\x5e\xce\xef\x4e\x20\xfb\xfa\x77\x58\xff\x0f\x8a\x76\x09\xfb\xfc\x0b\xfb\xd2\x34\x57\x34\xf2\xde\xc2\x77\x36\x00\x3c\xb7\x75\xa1\x08\xf2\x2d\xdf\xe7\x3f\xe8\xe6\x1c\xe4\xd8\xad\x61\xe3\x99\x57\xdd\xd7\xa3\x90\xeb\x23\x4b\xa1\xfa\x5b\xe8\x4e\x58\x75\xce\x2c\x78\x37\x95\xf8\x39\xe6\x2c\xee\x24\x15\x8b\x65\x9f\xd0\x68\x51\x3b\x34\x76\x5e\xb4\x35\x2a\xa1\xb6\x6e\xa6\x11\x52\xda\xc1\x4d\xbb\x14\x3a\xe2\x29\x62\xf1\xf1\x7a\xdd\xe3\x8b\xaa\xf0\x85\x35\xad\x72\xc3\x73\xf8\x0e\x00\x00\xff\xff\xfb\x1f\x97\x64\x7e\x01\x00\x00")
|
var _bindataDataDefaultconfigJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\x8d\x31\x0e\xc2\x30\x0c\x45\xf7\x9c\xc2\xca\xcc\x00\x6b\x2e\x63\x85\xe6\x97\x46\x4a\x9d\xca\x4e\xca\x80\x7a\x77\xd4\x08\x81\x58\x9f\xdf\xf3\x7f\x39\x22\xcf\x3b\xd4\x72\x15\x1f\xe8\x76\x19\x20\xcb\x5c\x75\x45\xe2\xa9\x8a\x41\x9a\x0f\x34\xc7\x62\x18\x57\x5b\xa2\x66\x79\xf8\x40\x67\x4d\xe4\xfb\x56\x6a\x4c\xac\xb0\x5e\x9a\xf9\x40\x4d\x3b\x1c\xd1\x31\x74\x41\x6b\xb0\xc1\x3f\xfe\x13\x77\xcb\x0d\xc6\x5d\x0b\x97\xbc\xe6\xf3\xff\xf5\x1b\xc4\xb4\x47\x99\x90\x7e\x81\x41\x12\x4f\x1a\x6d\x61\xc5\x56\xf5\x6f\xc4\x1d\xee\x1d\x00\x00\xff\xff\x5e\x8a\x1a\x13\xc6\x00\x00\x00")
|
||||||
|
|
||||||
func bindataDataDefaultconfigJsonBytes() ([]byte, error) {
|
func bindataDataDefaultconfigJsonBytes() ([]byte, error) {
|
||||||
return bindataRead(
|
return bindataRead(
|
||||||
|
|
|
@ -134,8 +134,6 @@ func Onboarding(config *config.Config) error {
|
||||||
config.Lock()
|
config.Lock()
|
||||||
config.InformedConsent = true
|
config.InformedConsent = true
|
||||||
config.Advanced.SendCrashReports = settings.SendCrashReports
|
config.Advanced.SendCrashReports = settings.SendCrashReports
|
||||||
config.Sharing.IncludeIP = settings.IncludeIP
|
|
||||||
config.Sharing.IncludeASN = settings.IncludeNetwork
|
|
||||||
config.Sharing.UploadResults = settings.UploadResults
|
config.Sharing.UploadResults = settings.UploadResults
|
||||||
config.Unlock()
|
config.Unlock()
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ func TestParseConfig(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
if config.Sharing.IncludeASN == false {
|
if config.Sharing.UploadResults != true {
|
||||||
t.Error("network should be included")
|
t.Fatal("not the expected value for UploadResults")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +58,6 @@ func TestUpdateConfig(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
origIncludeIP := config.Sharing.IncludeIP
|
|
||||||
origIncludeASN := config.Sharing.IncludeASN
|
|
||||||
origUploadResults := config.Sharing.UploadResults
|
origUploadResults := config.Sharing.UploadResults
|
||||||
origInformedConsent := config.InformedConsent
|
origInformedConsent := config.InformedConsent
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -79,12 +77,6 @@ func TestUpdateConfig(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
if newConfig.Sharing.IncludeIP != origIncludeIP {
|
|
||||||
t.Error("includeIP differs")
|
|
||||||
}
|
|
||||||
if newConfig.Sharing.IncludeASN != origIncludeASN {
|
|
||||||
t.Error("includeASN differs")
|
|
||||||
}
|
|
||||||
if newConfig.Sharing.UploadResults != origUploadResults {
|
if newConfig.Sharing.UploadResults != origUploadResults {
|
||||||
t.Error("UploadResults differs")
|
t.Error("UploadResults differs")
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,6 @@ var websiteCategories = []string{
|
||||||
|
|
||||||
// Sharing settings
|
// Sharing settings
|
||||||
type Sharing struct {
|
type Sharing struct {
|
||||||
IncludeIP bool `json:"include_ip"`
|
|
||||||
IncludeASN bool `json:"include_asn"`
|
|
||||||
UploadResults bool `json:"upload_results"`
|
UploadResults bool `json:"upload_results"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
8
internal/config/testdata/valid-config.json
vendored
8
internal/config/testdata/valid-config.json
vendored
|
@ -2,18 +2,12 @@
|
||||||
"_version": 1,
|
"_version": 1,
|
||||||
"_informed_consent": false,
|
"_informed_consent": false,
|
||||||
"sharing": {
|
"sharing": {
|
||||||
"include_ip": false,
|
|
||||||
"include_asn": true,
|
|
||||||
"include_country": true,
|
|
||||||
"upload_results": true
|
"upload_results": true
|
||||||
},
|
},
|
||||||
"nettests": {
|
"nettests": {
|
||||||
"websites_url_limit": 0
|
"websites_url_limit": 0
|
||||||
},
|
},
|
||||||
"advanced": {
|
"advanced": {
|
||||||
"use_domain_fronting": false,
|
"send_crash_reports": true
|
||||||
"send_crash_reports": true,
|
|
||||||
"collector_url": "",
|
|
||||||
"bouncer_url": "https://bouncer.ooni.io"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package nettests
|
package nettests
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Dash test implementation
|
// Dash test implementation
|
||||||
type Dash struct {
|
type Dash struct {
|
||||||
}
|
}
|
||||||
|
@ -16,48 +12,3 @@ func (d Dash) Run(ctl *Controller) error {
|
||||||
}
|
}
|
||||||
return ctl.Run(builder, []string{""})
|
return ctl.Run(builder, []string{""})
|
||||||
}
|
}
|
||||||
|
|
||||||
// DashTestKeys for the test
|
|
||||||
// TODO: process 'receiver_data' to provide an array of performance for a chart.
|
|
||||||
type DashTestKeys struct {
|
|
||||||
Latency float64 `json:"connect_latency"`
|
|
||||||
Bitrate float64 `json:"median_bitrate"`
|
|
||||||
Delay float64 `json:"min_playout_delay"`
|
|
||||||
IsAnomaly bool `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTestKeys generates a summary for a test run
|
|
||||||
func (d Dash) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
|
|
||||||
var err error
|
|
||||||
|
|
||||||
testKeys := DashTestKeys{IsAnomaly: false}
|
|
||||||
|
|
||||||
simple, ok := tk["simple"].(map[string]interface{})
|
|
||||||
if !ok {
|
|
||||||
return testKeys, errors.New("simple key is not of the expected type")
|
|
||||||
}
|
|
||||||
|
|
||||||
latency, ok := simple["connect_latency"].(float64)
|
|
||||||
if !ok {
|
|
||||||
err = errors.Wrap(err, "connect_latency is invalid")
|
|
||||||
}
|
|
||||||
testKeys.Latency = latency
|
|
||||||
|
|
||||||
bitrate, ok := simple["median_bitrate"].(float64)
|
|
||||||
if !ok {
|
|
||||||
err = errors.Wrap(err, "median_bitrate is invalid")
|
|
||||||
}
|
|
||||||
testKeys.Bitrate = bitrate
|
|
||||||
|
|
||||||
delay, ok := simple["min_playout_delay"].(float64)
|
|
||||||
if !ok {
|
|
||||||
err = errors.Wrap(err, "min_playout_delay is invalid")
|
|
||||||
}
|
|
||||||
testKeys.Delay = delay
|
|
||||||
return testKeys, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogSummary writes the summary to the standard output
|
|
||||||
func (d Dash) LogSummary(s string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -14,40 +14,3 @@ func (h FacebookMessenger) Run(ctl *Controller) error {
|
||||||
}
|
}
|
||||||
return ctl.Run(builder, []string{""})
|
return ctl.Run(builder, []string{""})
|
||||||
}
|
}
|
||||||
|
|
||||||
// FacebookMessengerTestKeys for the test
|
|
||||||
type FacebookMessengerTestKeys struct {
|
|
||||||
DNSBlocking bool `json:"facebook_dns_blocking"`
|
|
||||||
TCPBlocking bool `json:"facebook_tcp_blocking"`
|
|
||||||
IsAnomaly bool `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTestKeys generates a summary for a test run
|
|
||||||
func (h FacebookMessenger) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
|
|
||||||
var (
|
|
||||||
dnsBlocking bool
|
|
||||||
tcpBlocking bool
|
|
||||||
)
|
|
||||||
if tk["facebook_dns_blocking"] == nil {
|
|
||||||
dnsBlocking = false
|
|
||||||
} else {
|
|
||||||
dnsBlocking = tk["facebook_dns_blocking"].(bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
if tk["facebook_tcp_blocking"] == nil {
|
|
||||||
tcpBlocking = false
|
|
||||||
} else {
|
|
||||||
tcpBlocking = tk["facebook_tcp_blocking"].(bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
return FacebookMessengerTestKeys{
|
|
||||||
DNSBlocking: dnsBlocking,
|
|
||||||
TCPBlocking: tcpBlocking,
|
|
||||||
IsAnomaly: dnsBlocking || tcpBlocking,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogSummary writes the summary to the standard output
|
|
||||||
func (h FacebookMessenger) LogSummary(s string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package nettests
|
package nettests
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
// HTTPHeaderFieldManipulation test implementation
|
// HTTPHeaderFieldManipulation test implementation
|
||||||
type HTTPHeaderFieldManipulation struct {
|
type HTTPHeaderFieldManipulation struct {
|
||||||
}
|
}
|
||||||
|
@ -18,31 +14,3 @@ func (h HTTPHeaderFieldManipulation) Run(ctl *Controller) error {
|
||||||
}
|
}
|
||||||
return ctl.Run(builder, []string{""})
|
return ctl.Run(builder, []string{""})
|
||||||
}
|
}
|
||||||
|
|
||||||
// HTTPHeaderFieldManipulationTestKeys for the test
|
|
||||||
type HTTPHeaderFieldManipulationTestKeys struct {
|
|
||||||
IsAnomaly bool `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTestKeys returns a projection of the tests keys needed for the views
|
|
||||||
func (h HTTPHeaderFieldManipulation) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
|
|
||||||
testKeys := HTTPHeaderFieldManipulationTestKeys{IsAnomaly: false}
|
|
||||||
tampering, ok := tk["tampering"].(map[string]interface{})
|
|
||||||
if !ok {
|
|
||||||
return testKeys, errors.New("tampering testkey is invalid")
|
|
||||||
}
|
|
||||||
for _, v := range tampering {
|
|
||||||
t, ok := v.(bool)
|
|
||||||
// Ignore non booleans in the tampering map
|
|
||||||
if ok && t == true {
|
|
||||||
testKeys.IsAnomaly = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return testKeys, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogSummary writes the summary to the standard output
|
|
||||||
func (h HTTPHeaderFieldManipulation) LogSummary(s string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package nettests
|
package nettests
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
// HTTPInvalidRequestLine test implementation
|
// HTTPInvalidRequestLine test implementation
|
||||||
type HTTPInvalidRequestLine struct {
|
type HTTPInvalidRequestLine struct {
|
||||||
}
|
}
|
||||||
|
@ -18,26 +14,3 @@ func (h HTTPInvalidRequestLine) Run(ctl *Controller) error {
|
||||||
}
|
}
|
||||||
return ctl.Run(builder, []string{""})
|
return ctl.Run(builder, []string{""})
|
||||||
}
|
}
|
||||||
|
|
||||||
// HTTPInvalidRequestLineTestKeys for the test
|
|
||||||
type HTTPInvalidRequestLineTestKeys struct {
|
|
||||||
IsAnomaly bool `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTestKeys generates a summary for a test run
|
|
||||||
func (h HTTPInvalidRequestLine) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
|
|
||||||
testKeys := HTTPInvalidRequestLineTestKeys{IsAnomaly: false}
|
|
||||||
|
|
||||||
tampering, ok := tk["tampering"].(bool)
|
|
||||||
if !ok {
|
|
||||||
return testKeys, errors.New("tampering is not bool")
|
|
||||||
}
|
|
||||||
testKeys.IsAnomaly = tampering
|
|
||||||
|
|
||||||
return testKeys, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogSummary writes the summary to the standard output
|
|
||||||
func (h HTTPInvalidRequestLine) LogSummary(s string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package nettests
|
package nettests
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NDT test implementation. We use v7 of NDT since 2020-03-12.
|
// NDT test implementation. We use v7 of NDT since 2020-03-12.
|
||||||
type NDT struct {
|
type NDT struct {
|
||||||
}
|
}
|
||||||
|
@ -17,67 +13,3 @@ func (n NDT) Run(ctl *Controller) error {
|
||||||
}
|
}
|
||||||
return ctl.Run(builder, []string{""})
|
return ctl.Run(builder, []string{""})
|
||||||
}
|
}
|
||||||
|
|
||||||
// NDTTestKeys for the test
|
|
||||||
type NDTTestKeys struct {
|
|
||||||
Upload float64 `json:"upload"`
|
|
||||||
Download float64 `json:"download"`
|
|
||||||
Ping float64 `json:"ping"`
|
|
||||||
MaxRTT float64 `json:"max_rtt"`
|
|
||||||
AvgRTT float64 `json:"avg_rtt"`
|
|
||||||
MinRTT float64 `json:"min_rtt"`
|
|
||||||
MSS float64 `json:"mss"`
|
|
||||||
RetransmitRate float64 `json:"retransmit_rate"`
|
|
||||||
IsAnomaly bool `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTestKeys generates a summary for a test run
|
|
||||||
func (n NDT) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
|
|
||||||
var err error
|
|
||||||
testKeys := NDTTestKeys{IsAnomaly: false}
|
|
||||||
|
|
||||||
summary, ok := tk["summary"].(map[string]interface{})
|
|
||||||
if !ok {
|
|
||||||
return testKeys, errors.New("summary key is invalid")
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX there is likely a better pattern for this
|
|
||||||
testKeys.Upload, ok = summary["upload"].(float64)
|
|
||||||
if !ok {
|
|
||||||
err = errors.Wrap(err, "upload key invalid")
|
|
||||||
}
|
|
||||||
testKeys.Download, ok = summary["download"].(float64)
|
|
||||||
if !ok {
|
|
||||||
err = errors.Wrap(err, "download key invalid")
|
|
||||||
}
|
|
||||||
testKeys.Ping, ok = summary["ping"].(float64)
|
|
||||||
if !ok {
|
|
||||||
err = errors.Wrap(err, "ping key invalid")
|
|
||||||
}
|
|
||||||
testKeys.MaxRTT, ok = summary["max_rtt"].(float64)
|
|
||||||
if !ok {
|
|
||||||
err = errors.Wrap(err, "max_rtt key invalid")
|
|
||||||
}
|
|
||||||
testKeys.AvgRTT, ok = summary["avg_rtt"].(float64)
|
|
||||||
if !ok {
|
|
||||||
err = errors.Wrap(err, "avg_rtt key invalid")
|
|
||||||
}
|
|
||||||
testKeys.MinRTT, ok = summary["min_rtt"].(float64)
|
|
||||||
if !ok {
|
|
||||||
err = errors.Wrap(err, "min_rtt key invalid")
|
|
||||||
}
|
|
||||||
testKeys.MSS, ok = summary["mss"].(float64)
|
|
||||||
if !ok {
|
|
||||||
err = errors.Wrap(err, "mss key invalid")
|
|
||||||
}
|
|
||||||
testKeys.RetransmitRate, ok = summary["retransmit_rate"].(float64)
|
|
||||||
if !ok {
|
|
||||||
err = errors.Wrap(err, "retransmit_rate key invalid")
|
|
||||||
}
|
|
||||||
return testKeys, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogSummary writes the summary to the standard output
|
|
||||||
func (n NDT) LogSummary(s string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -18,8 +18,6 @@ import (
|
||||||
// Nettest interface. Every Nettest should implement this.
|
// Nettest interface. Every Nettest should implement this.
|
||||||
type Nettest interface {
|
type Nettest interface {
|
||||||
Run(*Controller) error
|
Run(*Controller) error
|
||||||
GetTestKeys(map[string]interface{}) (interface{}, error)
|
|
||||||
LogSummary(string) error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewController creates a nettest controller
|
// NewController creates a nettest controller
|
||||||
|
@ -168,12 +166,7 @@ func (c *Controller) Run(builder *engine.ExperimentBuilder, inputs []string) err
|
||||||
// is an inconsistency between the code that generate the measurement
|
// is an inconsistency between the code that generate the measurement
|
||||||
// and the code that process the measurement. We do have some data
|
// and the code that process the measurement. We do have some data
|
||||||
// but we're not gonna have a summary. To be reconsidered.
|
// but we're not gonna have a summary. To be reconsidered.
|
||||||
genericTk, err := measurement.MakeGenericTestKeys()
|
tk, err := exp.GetSummaryKeys(measurement)
|
||||||
if err != nil {
|
|
||||||
log.WithError(err).Error("failed to cast the test keys")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
tk, err := c.nt.GetTestKeys(genericTk)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("failed to obtain testKeys")
|
log.WithError(err).Error("failed to obtain testKeys")
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package nettests
|
package nettests
|
||||||
|
|
||||||
import "github.com/pkg/errors"
|
|
||||||
|
|
||||||
// Psiphon test implementation
|
// Psiphon test implementation
|
||||||
type Psiphon struct {
|
type Psiphon struct {
|
||||||
}
|
}
|
||||||
|
@ -16,36 +14,3 @@ func (h Psiphon) Run(ctl *Controller) error {
|
||||||
}
|
}
|
||||||
return ctl.Run(builder, []string{""})
|
return ctl.Run(builder, []string{""})
|
||||||
}
|
}
|
||||||
|
|
||||||
// PsiphonTestKeys contains the test keys
|
|
||||||
type PsiphonTestKeys struct {
|
|
||||||
IsAnomaly bool `json:"-"`
|
|
||||||
BootstrapTime float64 `json:"bootstrap_time"`
|
|
||||||
Failure string `json:"failure"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTestKeys generates a summary for a test run
|
|
||||||
func (h Psiphon) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
|
|
||||||
var (
|
|
||||||
ok bool
|
|
||||||
testKeys PsiphonTestKeys
|
|
||||||
)
|
|
||||||
if tk["failure"] != nil {
|
|
||||||
testKeys.IsAnomaly = true
|
|
||||||
failure, ok := tk["failure"].(*string)
|
|
||||||
if !ok {
|
|
||||||
return testKeys, errors.New("failure key invalid")
|
|
||||||
}
|
|
||||||
testKeys.Failure = *failure
|
|
||||||
}
|
|
||||||
testKeys.BootstrapTime, ok = tk["bootstrap_time"].(float64)
|
|
||||||
if !ok {
|
|
||||||
return testKeys, errors.New("bootstrap_time key invalid")
|
|
||||||
}
|
|
||||||
return testKeys, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogSummary writes the summary to the standard output
|
|
||||||
func (h Psiphon) LogSummary(s string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -14,48 +14,3 @@ func (h Telegram) Run(ctl *Controller) error {
|
||||||
}
|
}
|
||||||
return ctl.Run(builder, []string{""})
|
return ctl.Run(builder, []string{""})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TelegramTestKeys for the test
|
|
||||||
type TelegramTestKeys struct {
|
|
||||||
HTTPBlocking bool `json:"telegram_http_blocking"`
|
|
||||||
TCPBlocking bool `json:"telegram_tcp_blocking"`
|
|
||||||
WebBlocking bool `json:"telegram_web_blocking"`
|
|
||||||
IsAnomaly bool `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTestKeys generates a summary for a test run
|
|
||||||
func (h Telegram) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
|
|
||||||
var (
|
|
||||||
tcpBlocking bool
|
|
||||||
httpBlocking bool
|
|
||||||
webBlocking bool
|
|
||||||
)
|
|
||||||
|
|
||||||
if tk["telegram_tcp_blocking"] == nil {
|
|
||||||
tcpBlocking = false
|
|
||||||
} else {
|
|
||||||
tcpBlocking = tk["telegram_tcp_blocking"].(bool)
|
|
||||||
}
|
|
||||||
if tk["telegram_http_blocking"] == nil {
|
|
||||||
httpBlocking = false
|
|
||||||
} else {
|
|
||||||
httpBlocking = tk["telegram_http_blocking"].(bool)
|
|
||||||
}
|
|
||||||
if tk["telegram_web_status"] == nil {
|
|
||||||
webBlocking = false
|
|
||||||
} else {
|
|
||||||
webBlocking = tk["telegram_web_status"].(string) == "blocked"
|
|
||||||
}
|
|
||||||
|
|
||||||
return TelegramTestKeys{
|
|
||||||
TCPBlocking: tcpBlocking,
|
|
||||||
HTTPBlocking: httpBlocking,
|
|
||||||
WebBlocking: webBlocking,
|
|
||||||
IsAnomaly: webBlocking || httpBlocking || tcpBlocking,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogSummary writes the summary to the standard output
|
|
||||||
func (h Telegram) LogSummary(s string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -14,59 +14,3 @@ func (h Tor) Run(ctl *Controller) error {
|
||||||
}
|
}
|
||||||
return ctl.Run(builder, []string{""})
|
return ctl.Run(builder, []string{""})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TorTestKeys contains the test keys
|
|
||||||
type TorTestKeys struct {
|
|
||||||
DirPortTotal int64 `json:"dir_port_total"`
|
|
||||||
DirPortAccessible int64 `json:"dir_port_accessible"`
|
|
||||||
IsAnomaly bool `json:"-"`
|
|
||||||
OBFS4Total int64 `json:"obfs4_total"`
|
|
||||||
OBFS4Accessible int64 `json:"obfs4_accessible"`
|
|
||||||
ORPortDirauthTotal int64 `json:"or_port_dirauth_total"`
|
|
||||||
ORPortDirauthAccessible int64 `json:"or_port_dirauth_accessible"`
|
|
||||||
ORPortTotal int64 `json:"or_port_total"`
|
|
||||||
ORPortAccessible int64 `json:"or_port_accessible"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTestKeys generates a summary for a test run
|
|
||||||
func (h Tor) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
|
|
||||||
testKeys := TorTestKeys{IsAnomaly: false}
|
|
||||||
// Implementation note: when Go marshals into an interface, it marshals to
|
|
||||||
// float64 rather than int64, so we need to do some more work here.
|
|
||||||
//
|
|
||||||
// See <https://golang.org/pkg/encoding/json/#Unmarshal>.
|
|
||||||
if tk["dir_port_total"] != nil {
|
|
||||||
testKeys.DirPortTotal = int64(tk["dir_port_total"].(float64))
|
|
||||||
}
|
|
||||||
if tk["dir_port_accessible"] != nil {
|
|
||||||
testKeys.DirPortAccessible = int64(tk["dir_port_accessible"].(float64))
|
|
||||||
}
|
|
||||||
if tk["obfs4_total"] != nil {
|
|
||||||
testKeys.OBFS4Total = int64(tk["obfs4_total"].(float64))
|
|
||||||
}
|
|
||||||
if tk["obfs4_accessible"] != nil {
|
|
||||||
testKeys.OBFS4Accessible = int64(tk["obfs4_accessible"].(float64))
|
|
||||||
}
|
|
||||||
if tk["or_port_dirauth_total"] != nil {
|
|
||||||
testKeys.ORPortDirauthTotal = int64(tk["or_port_dirauth_total"].(float64))
|
|
||||||
}
|
|
||||||
if tk["or_port_dirauth_accessible"] != nil {
|
|
||||||
testKeys.ORPortDirauthAccessible = int64(tk["or_port_dirauth_accessible"].(float64))
|
|
||||||
}
|
|
||||||
if tk["or_port_total"] != nil {
|
|
||||||
testKeys.ORPortTotal = int64(tk["or_port_total"].(float64))
|
|
||||||
}
|
|
||||||
if tk["or_port_accessible"] != nil {
|
|
||||||
testKeys.ORPortAccessible = int64(tk["or_port_accessible"].(float64))
|
|
||||||
}
|
|
||||||
testKeys.IsAnomaly = ((testKeys.DirPortAccessible <= 0 && testKeys.DirPortTotal > 0) ||
|
|
||||||
(testKeys.OBFS4Accessible <= 0 && testKeys.OBFS4Total > 0) ||
|
|
||||||
(testKeys.ORPortDirauthAccessible <= 0 && testKeys.ORPortDirauthTotal > 0) ||
|
|
||||||
(testKeys.ORPortAccessible <= 0 && testKeys.ORPortTotal > 0))
|
|
||||||
return testKeys, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogSummary writes the summary to the standard output
|
|
||||||
func (h Tor) LogSummary(s string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -52,50 +52,3 @@ func (n WebConnectivity) Run(ctl *Controller) error {
|
||||||
}
|
}
|
||||||
return ctl.Run(builder, urls)
|
return ctl.Run(builder, urls)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebConnectivityTestKeys for the test
|
|
||||||
type WebConnectivityTestKeys struct {
|
|
||||||
Accessible bool `json:"accessible"`
|
|
||||||
Blocking string `json:"blocking"`
|
|
||||||
IsAnomaly bool `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTestKeys generates a summary for a test run
|
|
||||||
func (n WebConnectivity) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
|
|
||||||
var (
|
|
||||||
blocked bool
|
|
||||||
blocking string
|
|
||||||
accessible bool
|
|
||||||
)
|
|
||||||
|
|
||||||
// We need to do these complicated type assertions, because some of the fields
|
|
||||||
// are "nullable" and/or can be of different types
|
|
||||||
switch v := tk["blocking"].(type) {
|
|
||||||
case bool:
|
|
||||||
blocked = false
|
|
||||||
blocking = "none"
|
|
||||||
case string:
|
|
||||||
blocked = true
|
|
||||||
blocking = v
|
|
||||||
default:
|
|
||||||
blocked = false
|
|
||||||
blocking = "none"
|
|
||||||
}
|
|
||||||
|
|
||||||
if tk["accessible"] == nil {
|
|
||||||
accessible = false
|
|
||||||
} else {
|
|
||||||
accessible = tk["accessible"].(bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
return WebConnectivityTestKeys{
|
|
||||||
Accessible: accessible,
|
|
||||||
Blocking: blocking,
|
|
||||||
IsAnomaly: blocked,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogSummary writes the summary to the standard output
|
|
||||||
func (n WebConnectivity) LogSummary(s string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -14,46 +14,3 @@ func (h WhatsApp) Run(ctl *Controller) error {
|
||||||
}
|
}
|
||||||
return ctl.Run(builder, []string{""})
|
return ctl.Run(builder, []string{""})
|
||||||
}
|
}
|
||||||
|
|
||||||
// WhatsAppTestKeys for the test
|
|
||||||
type WhatsAppTestKeys struct {
|
|
||||||
RegistrationServerBlocking bool `json:"registration_server_blocking"`
|
|
||||||
WebBlocking bool `json:"whatsapp_web_blocking"`
|
|
||||||
EndpointsBlocking bool `json:"whatsapp_endpoints_blocking"`
|
|
||||||
IsAnomaly bool `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTestKeys generates a summary for a test run
|
|
||||||
func (h WhatsApp) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
|
|
||||||
var (
|
|
||||||
webBlocking bool
|
|
||||||
registrationBlocking bool
|
|
||||||
endpointsBlocking bool
|
|
||||||
)
|
|
||||||
|
|
||||||
var computeBlocking = func(key string) bool {
|
|
||||||
const blk = "blocked"
|
|
||||||
if tk[key] == nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if tk[key].(string) == blk {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
registrationBlocking = computeBlocking("registration_server_status")
|
|
||||||
webBlocking = computeBlocking("whatsapp_web_status")
|
|
||||||
endpointsBlocking = computeBlocking("whatsapp_endpoints_status")
|
|
||||||
|
|
||||||
return WhatsAppTestKeys{
|
|
||||||
RegistrationServerBlocking: registrationBlocking,
|
|
||||||
WebBlocking: webBlocking,
|
|
||||||
EndpointsBlocking: endpointsBlocking,
|
|
||||||
IsAnomaly: registrationBlocking || webBlocking || endpointsBlocking,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogSummary writes the summary to the standard output
|
|
||||||
func (h WhatsApp) LogSummary(s string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"github.com/ooni/probe-cli/internal/enginex"
|
"github.com/ooni/probe-cli/internal/enginex"
|
||||||
"github.com/ooni/probe-cli/internal/utils"
|
"github.com/ooni/probe-cli/internal/utils"
|
||||||
engine "github.com/ooni/probe-engine"
|
engine "github.com/ooni/probe-engine"
|
||||||
"github.com/ooni/probe-engine/model"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"upper.io/db.v3/lib/sqlbuilder"
|
"upper.io/db.v3/lib/sqlbuilder"
|
||||||
)
|
)
|
||||||
|
@ -200,14 +199,9 @@ func (p *Probe) NewSession() (*engine.Session, error) {
|
||||||
return nil, errors.Wrap(err, "creating engine's kvstore")
|
return nil, errors.Wrap(err, "creating engine's kvstore")
|
||||||
}
|
}
|
||||||
return engine.NewSession(engine.SessionConfig{
|
return engine.NewSession(engine.SessionConfig{
|
||||||
AssetsDir: utils.AssetsDir(p.home),
|
AssetsDir: utils.AssetsDir(p.home),
|
||||||
KVStore: kvstore,
|
KVStore: kvstore,
|
||||||
Logger: enginex.Logger,
|
Logger: enginex.Logger,
|
||||||
PrivacySettings: model.PrivacySettings{
|
|
||||||
IncludeASN: p.config.Sharing.IncludeASN,
|
|
||||||
IncludeCountry: true,
|
|
||||||
IncludeIP: p.config.Sharing.IncludeIP,
|
|
||||||
},
|
|
||||||
SoftwareName: p.softwareName,
|
SoftwareName: p.softwareName,
|
||||||
SoftwareVersion: p.softwareVersion,
|
SoftwareVersion: p.softwareVersion,
|
||||||
TempDir: p.tempDir,
|
TempDir: p.tempDir,
|
||||||
|
|
8
testdata/testing-config.json
vendored
8
testdata/testing-config.json
vendored
|
@ -2,18 +2,12 @@
|
||||||
"_version": 1,
|
"_version": 1,
|
||||||
"_informed_consent": true,
|
"_informed_consent": true,
|
||||||
"sharing": {
|
"sharing": {
|
||||||
"include_ip": true,
|
|
||||||
"include_asn": true,
|
|
||||||
"include_country": true,
|
|
||||||
"upload_results": true
|
"upload_results": true
|
||||||
},
|
},
|
||||||
"nettests": {
|
"nettests": {
|
||||||
"websites_url_limit": 10
|
"websites_url_limit": 10
|
||||||
},
|
},
|
||||||
"advanced": {
|
"advanced": {
|
||||||
"use_domain_fronting": false,
|
"send_crash_reports": true
|
||||||
"send_crash_reports": true,
|
|
||||||
"collector_url": "",
|
|
||||||
"bouncer_url": "https://bouncer.ooni.io"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user