ooni-probe-cli/cmd/ooniprobe/internal/nettests/stunreachability.go
Simone Basso 1896d2172a
fix(ooniprobe): dnscheck,stunreachability run w/ default input (#633)
This diff is part of https://github.com/ooni/probe/issues/1814 and
teaches `ooniprobe` to run dnscheck and stunreachability by using the
default static input feature of the `InputLoader`.

I've manually tested that we can still run `websites` like
we did before (including category filtering).

I've also manually tested that now we can run `experimental` and
get parseable results for dnscheck and stunreachability.

With this diff in, we have fixed the original problem highlighted in
the https://github.com/ooni/probe/issues/1814 issue.

Yet, because of the way in which I solved the problem, there is
more work to do. My changes have broken stunreachability for
mobile and now it's time I apply fixes to make it work again.

This diff was extracted from https://github.com/ooni/probe-cli/pull/539,
which at this point only basically contains the remaining fixes to
ensure we can run stunreachability on mobile.

Co-authored-by: Arturo Filastò <arturo@filasto.net>

Co-authored-by: Arturo Filastò <arturo@filasto.net>
2021-12-03 16:10:55 +01:00

43 lines
1.0 KiB
Go

package nettests
import (
"context"
engine "github.com/ooni/probe-cli/v3/internal/engine"
"github.com/ooni/probe-cli/v3/internal/engine/model"
)
// STUNReachability nettest implementation.
type STUNReachability struct{}
func (n STUNReachability) lookupURLs(ctl *Controller) ([]string, error) {
inputloader := &engine.InputLoader{
CheckInConfig: &model.CheckInConfig{
// not needed because we have default static input in the engine
},
ExperimentName: "stunreachability",
InputPolicy: engine.InputOrStaticDefault,
Session: ctl.Session,
SourceFiles: ctl.InputFiles,
StaticInputs: ctl.Inputs,
}
testlist, err := inputloader.Load(context.Background())
if err != nil {
return nil, err
}
return ctl.BuildAndSetInputIdxMap(ctl.Probe.DB(), testlist)
}
// Run starts the nettest.
func (n STUNReachability) Run(ctl *Controller) error {
builder, err := ctl.Session.NewExperimentBuilder("stunreachability")
if err != nil {
return err
}
urls, err := n.lookupURLs(ctl)
if err != nil {
return err
}
return ctl.Run(builder, urls)
}