fix(ooniprobe): use ooniprobe-cli-unattended for unattended runs (#714)

This diff changes the software name used by unattended runs for which
we did not override the default software name (`ooniprobe-cli`).

It will become `ooniprobe-cli-unattended`. This software name is in line
with the one we use for Android, iOS, and desktop unattended runs.

While working in this diff, I introduced string constants for the run
types and a string constant for the default software name.

See https://github.com/ooni/probe/issues/2081.
This commit is contained in:
Simone Basso
2022-04-29 13:41:09 +02:00
committed by GitHub
parent 596bdf6e57
commit d3c5196474
19 changed files with 72 additions and 37 deletions
+2 -1
View File
@@ -8,6 +8,7 @@ import (
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/cli/root"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/ooni"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/output"
"github.com/ooni/probe-cli/v3/internal/model"
)
func init() {
@@ -36,7 +37,7 @@ func dogeoip(config dogeoipconfig) error {
return err
}
engine, err := probeCLI.NewProbeEngine(context.Background())
engine, err := probeCLI.NewProbeEngine(context.Background(), model.RunTypeManual)
if err != nil {
return err
}
+1 -1
View File
@@ -40,7 +40,7 @@ func init() {
softwareName := Cmd.Flag(
"software-name", "Override application name",
).Default("ooniprobe-cli").String()
).Default(ooni.DefaultSoftwareName).String()
softwareVersion := Cmd.Flag(
"software-version", "Override the application version",
).Default(version.Version).String()
+6 -5
View File
@@ -8,6 +8,7 @@ import (
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/cli/root"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/nettests"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/ooni"
"github.com/ooni/probe-cli/v3/internal/model"
)
func init() {
@@ -32,7 +33,7 @@ func init() {
return nil
})
functionalRun := func(runType string, pred func(name string, gr nettests.Group) bool) error {
functionalRun := func(runType model.RunType, pred func(name string, gr nettests.Group) bool) error {
for name, group := range nettests.All {
if !pred(name, group) {
continue
@@ -52,7 +53,7 @@ func init() {
genRunWithGroupName := func(targetName string) func(*kingpin.ParseContext) error {
return func(*kingpin.ParseContext) error {
return functionalRun("manual", func(groupName string, gr nettests.Group) bool {
return functionalRun(model.RunTypeManual, func(groupName string, gr nettests.Group) bool {
return groupName == targetName
})
}
@@ -68,7 +69,7 @@ func init() {
Probe: probe,
InputFiles: *inputFile,
Inputs: *input,
RunType: "manual",
RunType: model.RunTypeManual,
})
})
@@ -80,14 +81,14 @@ func init() {
unattendedCmd := cmd.Command("unattended", "")
unattendedCmd.Action(func(_ *kingpin.ParseContext) error {
return functionalRun("timed", func(name string, gr nettests.Group) bool {
return functionalRun(model.RunTypeTimed, func(name string, gr nettests.Group) bool {
return gr.UnattendedOK
})
})
allCmd := cmd.Command("all", "").Default()
allCmd.Action(func(_ *kingpin.ParseContext) error {
return functionalRun("manual", func(name string, gr nettests.Group) bool {
return functionalRun(model.RunTypeManual, func(name string, gr nettests.Group) bool {
return true
})
})