2021-03-08 13:38:34 +01:00
|
|
|
package nettests
|
|
|
|
|
|
|
|
import (
|
2021-12-03 16:10:55 +01:00
|
|
|
"context"
|
2021-03-08 13:38:34 +01:00
|
|
|
|
2021-12-03 16:10:55 +01:00
|
|
|
engine "github.com/ooni/probe-cli/v3/internal/engine"
|
2022-01-03 13:53:23 +01:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/model"
|
2021-03-08 13:38:34 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// DNSCheck nettest implementation.
|
|
|
|
type DNSCheck struct{}
|
|
|
|
|
2021-12-03 16:10:55 +01:00
|
|
|
func (n DNSCheck) lookupURLs(ctl *Controller) ([]string, error) {
|
|
|
|
inputloader := &engine.InputLoader{
|
2022-01-03 13:53:23 +01:00
|
|
|
CheckInConfig: &model.OOAPICheckInConfig{
|
2021-12-03 16:10:55 +01:00
|
|
|
// not needed because we have default static input in the engine
|
|
|
|
},
|
|
|
|
ExperimentName: "dnscheck",
|
|
|
|
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)
|
2021-03-08 13:38:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Run starts the nettest.
|
|
|
|
func (n DNSCheck) Run(ctl *Controller) error {
|
2021-12-03 16:10:55 +01:00
|
|
|
builder, err := ctl.Session.NewExperimentBuilder("dnscheck")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
urls, err := n.lookupURLs(ctl)
|
2021-03-08 13:38:34 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-12-03 16:10:55 +01:00
|
|
|
return ctl.Run(builder, urls)
|
2021-03-08 13:38:34 +01:00
|
|
|
}
|