refactor: signal et al. are now experimental nettests (#243)

* refactor: signal et al. are now experimental nettests

We move signal into the experimental nettests group. While there,
also start adding dnscheck and stunreachability as well.

It seems there's more work to be done to correctly represent
the results of dnscheck, but this is fine!

The experimental section is here exactly for this reason!

In terms of UI, the new command is `ooniprobe run experimental`.

We will most likely move signal out of experimental soon, since it's
already working quite well. We need to keep it here for one more
cycle because the desktop app is not ready for it.

See the following issues:

1. https://github.com/ooni/probe/issues/1378

2. https://github.com/ooni/probe/issues/1262

* fix(dnscheck): spell check

* fix: improve documentation
This commit is contained in:
Simone Basso 2021-03-08 13:38:34 +01:00 committed by GitHub
parent f5461323db
commit da95fa9365
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 93 additions and 7 deletions

View File

@ -69,7 +69,8 @@ func init() {
})
})
easyRuns := []string{"im", "performance", "circumvention", "middlebox"}
easyRuns := []string{
"im", "performance", "circumvention", "middlebox", "experimental"}
for _, name := range easyRuns {
cmd.Command(name, "").Action(genRunWithGroupName(name))
}

View File

@ -76,6 +76,13 @@ var summarizers = map[string]func(uint64, uint64, string) []string{
"",
}
},
"experimental": func(totalCount uint64, anomalyCount uint64, ss string) []string {
return []string{
fmt.Sprintf("%d tested", totalCount),
fmt.Sprintf("%d blocked", anomalyCount),
"",
}
},
}
func makeSummary(name string, totalCount uint64, anomalyCount uint64, ss string) []string {

View File

@ -0,0 +1,60 @@
package nettests
import (
"encoding/json"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/dnscheck"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/run"
"github.com/ooni/probe-cli/v3/internal/engine/runtimex"
)
// DNSCheck nettest implementation.
type DNSCheck struct{}
var dnsCheckDefaultInput []string
func dnsCheckMustMakeInput(input *run.StructuredInput) string {
data, err := json.Marshal(input)
runtimex.PanicOnError(err, "json.Marshal failed")
return string(data)
}
func init() {
// The following code just adds a minimal set of URLs to
// test using DNSCheck, so we start exposing it.
//
// TODO(bassosimone):
//
// 1. we should be getting input from the backend instead of
// having an hardcoded list of inputs here.
//
// 2. we should modify dnscheck to accept http3://... as a
// shortcut for https://... with h3. If we don't do that, we
// are stuck with the h3 results hiding h2 results in OONI
// Explorer because they use the same URL.
//
// 3. it seems we have the problem that dnscheck results
// appear as the `run` nettest in `ooniprobe list <ID>` because
// dnscheck is run using the `run` functionality.
dnsCheckDefaultInput = append(dnsCheckDefaultInput, dnsCheckMustMakeInput(
&run.StructuredInput{
DNSCheck: dnscheck.Config{},
Name: "dnscheck",
Input: "https://dns.google/dns-query",
}))
dnsCheckDefaultInput = append(dnsCheckDefaultInput, dnsCheckMustMakeInput(
&run.StructuredInput{
DNSCheck: dnscheck.Config{},
Name: "dnscheck",
Input: "https://cloudflare-dns.com/dns-query",
}))
}
// Run starts the nettest.
func (n DNSCheck) Run(ctl *Controller) error {
builder, err := ctl.Session.NewExperimentBuilder("run")
if err != nil {
return err
}
return ctl.Run(builder, dnsCheckDefaultInput)
}

View File

@ -35,7 +35,6 @@ var All = map[string]Group{
Label: "Instant Messaging",
Nettests: []Nettest{
FacebookMessenger{},
Signal{},
Telegram{},
WhatsApp{},
},
@ -50,4 +49,12 @@ var All = map[string]Group{
},
UnattendedOK: true,
},
"experimental": {
Label: "Experimental Nettests",
Nettests: []Nettest{
DNSCheck{},
STUNReachability{},
Signal{},
},
},
}

View File

@ -1,10 +1,9 @@
package nettests
// Signal test implementation
type Signal struct {
}
// Signal nettest implementation.
type Signal struct{}
// Run starts the test
// Run starts the nettest.
func (h Signal) Run(ctl *Controller) error {
builder, err := ctl.Session.NewExperimentBuilder(
"signal",
@ -12,6 +11,5 @@ func (h Signal) Run(ctl *Controller) error {
if err != nil {
return err
}
return ctl.Run(builder, []string{""})
}

View File

@ -0,0 +1,13 @@
package nettests
// STUNReachability nettest implementation.
type STUNReachability struct{}
// Run starts the nettest.
func (n STUNReachability) Run(ctl *Controller) error {
builder, err := ctl.Session.NewExperimentBuilder("stun_reachability")
if err != nil {
return err
}
return ctl.Run(builder, []string{""})
}