1896d2172a
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>
53 lines
1.5 KiB
Go
53 lines
1.5 KiB
Go
package nettests
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/apex/log"
|
|
engine "github.com/ooni/probe-cli/v3/internal/engine"
|
|
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
|
)
|
|
|
|
func (n WebConnectivity) lookupURLs(ctl *Controller, categories []string) ([]string, error) {
|
|
inputloader := &engine.InputLoader{
|
|
CheckInConfig: &model.CheckInConfig{
|
|
// 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{
|
|
CategoryCodes: categories,
|
|
},
|
|
},
|
|
ExperimentName: "web_connectivity",
|
|
InputPolicy: engine.InputOrQueryBackend,
|
|
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)
|
|
}
|
|
|
|
// WebConnectivity test implementation
|
|
type WebConnectivity struct{}
|
|
|
|
// Run starts the test
|
|
func (n WebConnectivity) Run(ctl *Controller) error {
|
|
log.Debugf("Enabled category codes are the following %v", ctl.Probe.Config().Nettests.WebsitesEnabledCategoryCodes)
|
|
urls, err := n.lookupURLs(ctl, ctl.Probe.Config().Nettests.WebsitesEnabledCategoryCodes)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
builder, err := ctl.Session.NewExperimentBuilder("web_connectivity")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return ctl.Run(builder, urls)
|
|
}
|