2021-03-08 13:38:34 +01:00
|
|
|
package nettests
|
|
|
|
|
2021-12-03 16:10:55 +01:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
engine "github.com/ooni/probe-cli/v3/internal/engine"
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
|
|
|
)
|
|
|
|
|
2021-03-08 13:38:34 +01:00
|
|
|
// STUNReachability nettest implementation.
|
|
|
|
type STUNReachability struct{}
|
|
|
|
|
2021-12-03 16:10:55 +01:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2021-03-08 13:38:34 +01:00
|
|
|
// Run starts the nettest.
|
|
|
|
func (n STUNReachability) Run(ctl *Controller) error {
|
2021-03-11 19:35:22 +01:00
|
|
|
builder, err := ctl.Session.NewExperimentBuilder("stunreachability")
|
2021-03-08 13:38:34 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-12-03 16:10:55 +01:00
|
|
|
urls, err := n.lookupURLs(ctl)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return ctl.Run(builder, urls)
|
2021-03-08 13:38:34 +01:00
|
|
|
}
|