diff --git a/cmd/ooniprobe/internal/cli/run/run.go b/cmd/ooniprobe/internal/cli/run/run.go index 5e8ca40..32d27cd 100644 --- a/cmd/ooniprobe/internal/cli/run/run.go +++ b/cmd/ooniprobe/internal/cli/run/run.go @@ -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)) } diff --git a/cmd/ooniprobe/internal/log/handlers/cli/results.go b/cmd/ooniprobe/internal/log/handlers/cli/results.go index 09ca641..9350bdd 100644 --- a/cmd/ooniprobe/internal/log/handlers/cli/results.go +++ b/cmd/ooniprobe/internal/log/handlers/cli/results.go @@ -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 { diff --git a/cmd/ooniprobe/internal/nettests/dnscheck.go b/cmd/ooniprobe/internal/nettests/dnscheck.go new file mode 100644 index 0000000..02cf963 --- /dev/null +++ b/cmd/ooniprobe/internal/nettests/dnscheck.go @@ -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 ` 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) +} diff --git a/cmd/ooniprobe/internal/nettests/groups.go b/cmd/ooniprobe/internal/nettests/groups.go index e2735b7..5c4d9bc 100644 --- a/cmd/ooniprobe/internal/nettests/groups.go +++ b/cmd/ooniprobe/internal/nettests/groups.go @@ -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{}, + }, + }, } diff --git a/cmd/ooniprobe/internal/nettests/signal.go b/cmd/ooniprobe/internal/nettests/signal.go index 9b17d34..3a2df6b 100644 --- a/cmd/ooniprobe/internal/nettests/signal.go +++ b/cmd/ooniprobe/internal/nettests/signal.go @@ -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{""}) } diff --git a/cmd/ooniprobe/internal/nettests/stunreachability.go b/cmd/ooniprobe/internal/nettests/stunreachability.go new file mode 100644 index 0000000..68fb40e --- /dev/null +++ b/cmd/ooniprobe/internal/nettests/stunreachability.go @@ -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{""}) +}