From f626a015c93813f3b5b409577b26d6fd41a74861 Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Fri, 20 May 2022 11:47:22 +0200 Subject: [PATCH] feat(ooniprobe): add vanilla_tor to experimental (#745) While there make vanilla_tor only run in unattended mode. While there also make torsf unattended-mode only. See https://github.com/ooni/probe/issues/2101 See https://github.com/ooni/probe/issues/2057 --- cmd/ooniprobe/internal/nettests/groups.go | 1 + cmd/ooniprobe/internal/nettests/run.go | 18 ++++++++++++++++++ cmd/ooniprobe/internal/nettests/torsf.go | 2 ++ cmd/ooniprobe/internal/nettests/vanillator.go | 16 ++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 cmd/ooniprobe/internal/nettests/vanillator.go diff --git a/cmd/ooniprobe/internal/nettests/groups.go b/cmd/ooniprobe/internal/nettests/groups.go index a2a5370..623d2ea 100644 --- a/cmd/ooniprobe/internal/nettests/groups.go +++ b/cmd/ooniprobe/internal/nettests/groups.go @@ -57,6 +57,7 @@ var All = map[string]Group{ DNSCheck{}, STUNReachability{}, TorSf{}, + VanillaTor{}, }, UnattendedOK: true, }, diff --git a/cmd/ooniprobe/internal/nettests/run.go b/cmd/ooniprobe/internal/nettests/run.go index fe5175c..5b28acc 100644 --- a/cmd/ooniprobe/internal/nettests/run.go +++ b/cmd/ooniprobe/internal/nettests/run.go @@ -103,6 +103,12 @@ func RunGroup(config RunGroupConfig) error { log.Debugf("context is terminated, stopping group.Nettests early") break } + if config.RunType != model.RunTypeTimed { + if _, background := nt.(onlyBackground); background { + log.Debug("we only run this nettest in background mode") + continue + } + } log.Debugf("Running test %T", nt) ctl := NewController(nt, config.Probe, result, sess) ctl.InputFiles = config.InputFiles @@ -131,3 +137,15 @@ func RunGroup(config RunGroupConfig) error { } return nil } + +// onlyBackground is the interface implements by nettests that we don't +// want to run in manual mode because they take too much runtime +// +// See: +// +// - https://github.com/ooni/probe/issues/2101 +// +// - https://github.com/ooni/probe/issues/2057 +type onlyBackground interface { + onlyBackground() +} diff --git a/cmd/ooniprobe/internal/nettests/torsf.go b/cmd/ooniprobe/internal/nettests/torsf.go index d488188..494dae4 100644 --- a/cmd/ooniprobe/internal/nettests/torsf.go +++ b/cmd/ooniprobe/internal/nettests/torsf.go @@ -12,3 +12,5 @@ func (h TorSf) Run(ctl *Controller) error { } return ctl.Run(builder, []string{""}) } + +func (h TorSf) onlyBackground() {} diff --git a/cmd/ooniprobe/internal/nettests/vanillator.go b/cmd/ooniprobe/internal/nettests/vanillator.go new file mode 100644 index 0000000..11d7266 --- /dev/null +++ b/cmd/ooniprobe/internal/nettests/vanillator.go @@ -0,0 +1,16 @@ +package nettests + +// VanillaTor test implementation +type VanillaTor struct { +} + +// Run starts the test +func (h VanillaTor) Run(ctl *Controller) error { + builder, err := ctl.Session.NewExperimentBuilder("vanilla_tor") + if err != nil { + return err + } + return ctl.Run(builder, []string{""}) +} + +func (h VanillaTor) onlyBackground() {}