feat(ooniprobe): propagate the RunType CheckIn hint (#274)

This diff propagates the RunType CheckIn hint such that we run
using less URLs when running in the background.

Part of https://github.com/ooni/probe/issues/1299.
This commit is contained in:
Simone Basso 2021-03-30 11:59:29 +02:00 committed by GitHub
commit dae02ce5b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 17 deletions

View file

@ -9,12 +9,15 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/model"
)
// TODO(bassosimone): we should propagate the kind of run
// to here such that we get the right runType.
func lookupURLs(ctl *Controller, categories []string) ([]string, map[int64]int64, 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,
},
@ -24,6 +27,7 @@ func lookupURLs(ctl *Controller, categories []string) ([]string, map[int64]int64
SourceFiles: ctl.InputFiles,
StaticInputs: ctl.Inputs,
}
log.Infof("Calling CheckIn API with %s runType", ctl.RunType)
testlist, err := inputloader.Load(context.Background())
var urls []string
urlIDMap := make(map[int64]int64)