2022-08-31 10:20:04 +02:00
|
|
|
// Command miniooni is a simple binary for research and QA purposes
|
|
|
|
// with a CLI interface similar to MK and OONI Probe v2.x.
|
2021-03-29 19:03:53 +02:00
|
|
|
package main
|
2021-03-29 18:46:26 +02:00
|
|
|
|
2021-02-02 12:05:47 +01:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path"
|
2022-08-31 13:07:24 +02:00
|
|
|
"runtime/debug"
|
2022-08-31 12:44:46 +02:00
|
|
|
"strings"
|
2021-02-02 12:05:47 +01:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/apex/log"
|
2021-02-03 11:21:10 +01:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/engine"
|
refactor: flatten and separate (#353)
* refactor(atomicx): move outside the engine package
After merging probe-engine into probe-cli, my impression is that we have
too much unnecessary nesting of packages in this repository.
The idea of this commit and of a bunch of following commits will instead
be to reduce the nesting and simplify the structure.
While there, improve the documentation.
* fix: always use the atomicx package
For consistency, never use sync/atomic and always use ./internal/atomicx
so we can just grep and make sure we're not risking to crash if we make
a subtle mistake on a 32 bit platform.
While there, mention in the contributing guidelines that we want to
always prefer the ./internal/atomicx package over sync/atomic.
* fix(atomicx): remove unnecessary constructor
We don't need a constructor here. The default constructed `&Int64{}`
instance is already usable and the constructor does not add anything to
what we are doing, rather it just creates extra confusion.
* cleanup(atomicx): we are not using Float64
Because atomicx.Float64 is unused, we can safely zap it.
* cleanup(atomicx): simplify impl and improve tests
We can simplify the implementation by using defer and by letting
the Load() method call Add(0).
We can improve tests by making many goroutines updated the
atomic int64 value concurrently.
* refactor(fsx): can live in the ./internal pkg
Let us reduce the amount of nesting. While there, ensure that the
package only exports the bare minimum, and improve the documentation
of the tests, to ease reading the code.
* refactor: move runtimex to ./internal
* refactor: move shellx into the ./internal package
While there, remove unnecessary dependency between packages.
While there, specify in the contributing guidelines that
one should use x/sys/execabs instead of os/exec.
* refactor: move ooapi into the ./internal pkg
* refactor(humanize): move to ./internal and better docs
* refactor: move platform to ./internal
* refactor(randx): move to ./internal
* refactor(multierror): move into the ./internal pkg
* refactor(kvstore): all kvstores in ./internal
Rather than having part of the kvstore inside ./internal/engine/kvstore
and part in ./internal/engine/kvstore.go, let us put every piece of code
that is kvstore related into the ./internal/kvstore package.
* fix(kvstore): always return ErrNoSuchKey on Get() error
It should help to use the kvstore everywhere removing all the
copies that are lingering around the tree.
* sessionresolver: make KVStore mandatory
Simplifies implementation. While there, use the ./internal/kvstore
package rather than having our private implementation.
* fix(ooapi): use the ./internal/kvstore package
* fix(platform): better documentation
2021-06-04 10:34:18 +02:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/humanize"
|
2022-05-25 10:19:03 +02:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/legacy/assetsdir"
|
2022-09-05 10:06:44 +02:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/logx"
|
2022-01-03 13:53:23 +01:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/model"
|
2022-08-31 12:44:46 +02:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/registry"
|
2022-07-08 14:20:49 +02:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
2021-02-04 11:00:27 +01:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/version"
|
2022-08-31 12:44:46 +02:00
|
|
|
"github.com/spf13/cobra"
|
2021-02-02 12:05:47 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// Options contains the options you can set from the CLI.
|
|
|
|
type Options struct {
|
2022-10-03 16:52:20 +02:00
|
|
|
Annotations []string
|
|
|
|
Emoji bool
|
|
|
|
ExtraOptions []string
|
|
|
|
HomeDir string
|
|
|
|
Inputs []string
|
|
|
|
InputFilePaths []string
|
|
|
|
MaxRuntime int64
|
|
|
|
NoJSON bool
|
|
|
|
NoCollector bool
|
|
|
|
ProbeServicesURL string
|
|
|
|
Proxy string
|
|
|
|
Random bool
|
|
|
|
RepeatEvery int64
|
|
|
|
ReportFile string
|
|
|
|
SnowflakeRendezvous string
|
|
|
|
TorArgs []string
|
|
|
|
TorBinary string
|
|
|
|
Tunnel string
|
|
|
|
Verbose bool
|
|
|
|
Yes bool
|
2021-02-02 12:05:47 +01:00
|
|
|
}
|
|
|
|
|
2022-08-31 12:44:46 +02:00
|
|
|
// main is the main function of miniooni.
|
|
|
|
func main() {
|
|
|
|
var globalOptions Options
|
|
|
|
rootCmd := &cobra.Command{
|
|
|
|
Use: "miniooni",
|
|
|
|
Short: "miniooni is OONI's research client",
|
|
|
|
Args: cobra.NoArgs,
|
|
|
|
Version: version.Version,
|
|
|
|
}
|
|
|
|
rootCmd.SetVersionTemplate("{{ .Version }}\n")
|
|
|
|
flags := rootCmd.PersistentFlags()
|
2021-02-02 12:05:47 +01:00
|
|
|
|
2022-08-31 12:44:46 +02:00
|
|
|
flags.StringSliceVarP(
|
|
|
|
&globalOptions.Annotations,
|
|
|
|
"annotation",
|
|
|
|
"A",
|
|
|
|
[]string{},
|
|
|
|
"add KEY=VALUE annotation to the report (can be repeated multiple times)",
|
2021-03-29 20:38:23 +02:00
|
|
|
)
|
2022-08-31 12:44:46 +02:00
|
|
|
|
2022-09-05 10:06:44 +02:00
|
|
|
flags.BoolVar(
|
|
|
|
&globalOptions.Emoji,
|
|
|
|
"emoji",
|
|
|
|
false,
|
|
|
|
"whether to use emojis when logging",
|
|
|
|
)
|
|
|
|
|
2022-08-31 12:44:46 +02:00
|
|
|
flags.StringVar(
|
|
|
|
&globalOptions.HomeDir,
|
|
|
|
"home",
|
|
|
|
"",
|
|
|
|
"force specific home directory",
|
2021-02-02 12:05:47 +01:00
|
|
|
)
|
2022-08-31 12:44:46 +02:00
|
|
|
|
|
|
|
flags.BoolVarP(
|
|
|
|
&globalOptions.NoJSON,
|
|
|
|
"no-json",
|
|
|
|
"N",
|
|
|
|
false,
|
|
|
|
"disable writing to disk",
|
2021-02-02 12:05:47 +01:00
|
|
|
)
|
2022-08-31 12:44:46 +02:00
|
|
|
|
|
|
|
flags.BoolVarP(
|
|
|
|
&globalOptions.NoCollector,
|
|
|
|
"no-collector",
|
|
|
|
"n",
|
|
|
|
false,
|
|
|
|
"do not submit measurements to the OONI collector",
|
2021-02-02 12:05:47 +01:00
|
|
|
)
|
2022-08-31 12:44:46 +02:00
|
|
|
|
|
|
|
flags.StringVar(
|
|
|
|
&globalOptions.ProbeServicesURL,
|
|
|
|
"probe-services",
|
|
|
|
"",
|
|
|
|
"URL of the OONI backend instance you want to use",
|
2021-02-02 12:05:47 +01:00
|
|
|
)
|
2022-08-31 12:44:46 +02:00
|
|
|
|
|
|
|
flags.StringVar(
|
|
|
|
&globalOptions.Proxy,
|
|
|
|
"proxy",
|
|
|
|
"",
|
|
|
|
"set proxy URL to communicate with the OONI backend (mutually exclusive with --tunnel)",
|
2022-07-08 17:04:31 +02:00
|
|
|
)
|
2022-08-31 12:44:46 +02:00
|
|
|
|
|
|
|
flags.Int64Var(
|
|
|
|
&globalOptions.RepeatEvery,
|
|
|
|
"repeat-every",
|
|
|
|
0,
|
|
|
|
"wait the given number of seconds and then repeat the same measurement",
|
2021-02-02 12:05:47 +01:00
|
|
|
)
|
2022-08-31 12:44:46 +02:00
|
|
|
|
|
|
|
flags.StringVarP(
|
|
|
|
&globalOptions.ReportFile,
|
|
|
|
"reportfile",
|
|
|
|
"o",
|
|
|
|
"",
|
|
|
|
"set the output report file path (default: \"report.jsonl\")",
|
2021-02-02 12:05:47 +01:00
|
|
|
)
|
2022-08-31 12:44:46 +02:00
|
|
|
|
2022-10-03 16:52:20 +02:00
|
|
|
flags.StringVar(
|
|
|
|
&globalOptions.SnowflakeRendezvous,
|
|
|
|
"snowflake-rendezvous",
|
|
|
|
"domain_fronting",
|
|
|
|
"rendezvous method for --tunnel=torsf (one of: \"domain_fronting\" and \"amp\")",
|
|
|
|
)
|
|
|
|
|
2022-08-31 12:44:46 +02:00
|
|
|
flags.StringSliceVar(
|
|
|
|
&globalOptions.TorArgs,
|
|
|
|
"tor-args",
|
|
|
|
[]string{},
|
|
|
|
"extra arguments for the tor binary (may be specified multiple times)",
|
2021-02-02 12:05:47 +01:00
|
|
|
)
|
2022-08-31 12:44:46 +02:00
|
|
|
|
|
|
|
flags.StringVar(
|
|
|
|
&globalOptions.TorBinary,
|
|
|
|
"tor-binary",
|
|
|
|
"",
|
|
|
|
"execute a specific tor binary",
|
2021-02-02 12:05:47 +01:00
|
|
|
)
|
2022-08-31 12:44:46 +02:00
|
|
|
|
|
|
|
flags.StringVar(
|
|
|
|
&globalOptions.Tunnel,
|
|
|
|
"tunnel",
|
|
|
|
"",
|
2022-10-03 16:52:20 +02:00
|
|
|
"tunnel to use to communicate with the OONI backend (one of: psiphon, tor, torsf)",
|
2021-02-02 12:05:47 +01:00
|
|
|
)
|
2022-08-31 12:44:46 +02:00
|
|
|
|
|
|
|
flags.BoolVarP(
|
|
|
|
&globalOptions.Verbose,
|
|
|
|
"verbose",
|
|
|
|
"v",
|
|
|
|
false,
|
|
|
|
"increase verbosity level",
|
2021-03-08 18:31:42 +01:00
|
|
|
)
|
2022-08-31 12:44:46 +02:00
|
|
|
|
|
|
|
flags.BoolVarP(
|
|
|
|
&globalOptions.Yes,
|
|
|
|
"yes",
|
|
|
|
"y",
|
|
|
|
false,
|
|
|
|
"assume yes as the answer to all questions",
|
2021-02-02 12:05:47 +01:00
|
|
|
)
|
2022-08-31 12:44:46 +02:00
|
|
|
|
|
|
|
rootCmd.MarkFlagsMutuallyExclusive("proxy", "tunnel")
|
|
|
|
|
|
|
|
registerAllExperiments(rootCmd, &globalOptions)
|
|
|
|
registerOONIRun(rootCmd, &globalOptions)
|
|
|
|
|
|
|
|
if err := rootCmd.Execute(); err != nil {
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2021-02-02 12:05:47 +01:00
|
|
|
}
|
|
|
|
|
2022-08-31 12:44:46 +02:00
|
|
|
// TODO(bassosimone): the current implementation is basically a cobra application
|
|
|
|
// where we hammered the previous miniooni code to make it work. We should
|
|
|
|
// obviously strive for more correctness. For example, it's a bit disgusting
|
|
|
|
// that MainWithConfiguration is invoked for both oonirun and random experiments.
|
|
|
|
|
|
|
|
// registerOONIRun registers the oonirun subcommand
|
|
|
|
func registerOONIRun(rootCmd *cobra.Command, globalOptions *Options) {
|
|
|
|
subCmd := &cobra.Command{
|
|
|
|
Use: "oonirun",
|
|
|
|
Short: "Runs a given OONI Run v2 link",
|
|
|
|
Args: cobra.NoArgs,
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
MainWithConfiguration(cmd.Use, globalOptions)
|
|
|
|
},
|
2021-03-08 18:31:42 +01:00
|
|
|
}
|
2022-08-31 12:44:46 +02:00
|
|
|
rootCmd.AddCommand(subCmd)
|
|
|
|
flags := subCmd.Flags()
|
|
|
|
flags.StringSliceVarP(
|
|
|
|
&globalOptions.Inputs,
|
|
|
|
"input",
|
|
|
|
"i",
|
|
|
|
[]string{},
|
|
|
|
"URL of the OONI Run v2 descriptor to run (may be specified multiple times)",
|
|
|
|
)
|
2022-09-29 11:43:23 +02:00
|
|
|
flags.StringSliceVarP(
|
|
|
|
&globalOptions.InputFilePaths,
|
|
|
|
"input-file",
|
|
|
|
"f",
|
|
|
|
[]string{},
|
|
|
|
"Path to the OONI Run v2 descriptor to run (may be specified multiple times)",
|
|
|
|
)
|
2021-02-02 12:05:47 +01:00
|
|
|
}
|
|
|
|
|
2022-08-31 12:44:46 +02:00
|
|
|
// registerAllExperiments registers a subcommand for each experiment
|
|
|
|
func registerAllExperiments(rootCmd *cobra.Command, globalOptions *Options) {
|
|
|
|
for name, factory := range registry.AllExperiments {
|
|
|
|
subCmd := &cobra.Command{
|
|
|
|
Use: name,
|
|
|
|
Short: fmt.Sprintf("Runs the %s experiment", name),
|
|
|
|
Args: cobra.NoArgs,
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
MainWithConfiguration(cmd.Use, globalOptions)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
rootCmd.AddCommand(subCmd)
|
|
|
|
flags := subCmd.Flags()
|
|
|
|
|
|
|
|
switch factory.InputPolicy() {
|
|
|
|
case model.InputOrQueryBackend,
|
|
|
|
model.InputStrictlyRequired,
|
|
|
|
model.InputOptional,
|
|
|
|
model.InputOrStaticDefault:
|
|
|
|
|
|
|
|
flags.StringSliceVarP(
|
|
|
|
&globalOptions.InputFilePaths,
|
|
|
|
"input-file",
|
|
|
|
"f",
|
|
|
|
[]string{},
|
|
|
|
"path to file to supply test dependent input (may be specified multiple times)",
|
|
|
|
)
|
|
|
|
|
|
|
|
flags.StringSliceVarP(
|
|
|
|
&globalOptions.Inputs,
|
|
|
|
"input",
|
|
|
|
"i",
|
|
|
|
[]string{},
|
|
|
|
"add test-dependent input (may be specified multiple times)",
|
|
|
|
)
|
|
|
|
|
|
|
|
flags.Int64Var(
|
|
|
|
&globalOptions.MaxRuntime,
|
|
|
|
"max-runtime",
|
|
|
|
0,
|
|
|
|
"maximum runtime in seconds for the experiment (zero means infinite)",
|
|
|
|
)
|
|
|
|
|
|
|
|
flags.BoolVar(
|
|
|
|
&globalOptions.Random,
|
|
|
|
"random",
|
|
|
|
false,
|
|
|
|
"randomize the inputs list",
|
|
|
|
)
|
|
|
|
|
|
|
|
default:
|
|
|
|
// nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
if doc := documentationForOptions(name, factory); doc != "" {
|
|
|
|
flags.StringSliceVarP(
|
|
|
|
&globalOptions.ExtraOptions,
|
|
|
|
"option",
|
|
|
|
"O",
|
|
|
|
[]string{},
|
|
|
|
doc,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-05 15:28:13 +02:00
|
|
|
|
2021-02-02 12:05:47 +01:00
|
|
|
// MainWithConfiguration is the miniooni main with a specific configuration
|
|
|
|
// represented by the experiment name and the current options.
|
|
|
|
//
|
|
|
|
// This function will panic in case of a fatal error. It is up to you that
|
|
|
|
// integrate this function to either handle the panic of ignore it.
|
2022-08-31 12:44:46 +02:00
|
|
|
func MainWithConfiguration(experimentName string, currentOptions *Options) {
|
|
|
|
runtimex.PanicOnError(engine.CheckEmbeddedPsiphonConfig(), "Invalid embedded psiphon config")
|
2021-04-05 15:28:13 +02:00
|
|
|
if currentOptions.Tunnel != "" {
|
|
|
|
currentOptions.Proxy = fmt.Sprintf("%s:///", currentOptions.Tunnel)
|
|
|
|
}
|
2021-03-29 20:38:23 +02:00
|
|
|
|
2022-09-05 10:06:44 +02:00
|
|
|
logHandler := logx.NewHandlerWithDefaultSettings()
|
|
|
|
logHandler.Emoji = currentOptions.Emoji
|
|
|
|
logger := &log.Logger{Level: log.InfoLevel, Handler: logHandler}
|
2021-02-02 12:05:47 +01:00
|
|
|
if currentOptions.Verbose {
|
|
|
|
logger.Level = log.DebugLevel
|
|
|
|
}
|
|
|
|
if currentOptions.ReportFile == "" {
|
|
|
|
currentOptions.ReportFile = "report.jsonl"
|
|
|
|
}
|
|
|
|
log.Log = logger
|
2022-07-08 17:04:31 +02:00
|
|
|
for {
|
|
|
|
mainSingleIteration(logger, experimentName, currentOptions)
|
|
|
|
if currentOptions.RepeatEvery <= 0 {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
log.Infof("waiting %ds before repeating the measurement", currentOptions.RepeatEvery)
|
|
|
|
log.Info("use Ctrl-C to interrupt miniooni")
|
|
|
|
time.Sleep(time.Duration(currentOptions.RepeatEvery) * time.Second)
|
|
|
|
}
|
|
|
|
}
|
2021-02-02 12:05:47 +01:00
|
|
|
|
2022-07-08 17:04:31 +02:00
|
|
|
// mainSingleIteration runs a single iteration. There may be multiple iterations
|
|
|
|
// when the user specifies the --repeat-every command line flag.
|
2022-08-31 12:44:46 +02:00
|
|
|
func mainSingleIteration(logger model.Logger, experimentName string, currentOptions *Options) {
|
2022-08-31 13:07:24 +02:00
|
|
|
|
|
|
|
// We allow the inner code to fail but we stop propagating the panic here
|
|
|
|
// such that --repeat-every works as intended anyway
|
|
|
|
if currentOptions.RepeatEvery > 0 {
|
|
|
|
defer func() {
|
|
|
|
if r := recover(); r != nil {
|
|
|
|
log.Warnf("recovered from panic: %+v\n%s\n", r, debug.Stack())
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
2022-08-31 10:20:04 +02:00
|
|
|
extraOptions := mustMakeMapStringAny(currentOptions.ExtraOptions)
|
|
|
|
annotations := mustMakeMapStringString(currentOptions.Annotations)
|
2022-07-08 14:20:49 +02:00
|
|
|
|
|
|
|
ctx := context.Background()
|
|
|
|
|
2021-02-12 08:17:16 +01:00
|
|
|
//Mon Jan 2 15:04:05 -0700 MST 2006
|
|
|
|
log.Infof("Current time: %s", time.Now().Format("2006-01-02 15:04:05 MST"))
|
|
|
|
|
2021-02-02 12:05:47 +01:00
|
|
|
homeDir := gethomedir(currentOptions.HomeDir)
|
2022-08-31 18:40:27 +02:00
|
|
|
runtimex.Assert(homeDir != "", "home directory is empty")
|
2021-02-02 12:05:47 +01:00
|
|
|
miniooniDir := path.Join(homeDir, ".miniooni")
|
2021-06-08 19:40:17 +02:00
|
|
|
err := os.MkdirAll(miniooniDir, 0700)
|
2022-07-08 14:20:49 +02:00
|
|
|
runtimex.PanicOnError(err, "cannot create $HOME/.miniooni directory")
|
2021-04-01 16:57:31 +02:00
|
|
|
|
|
|
|
// We cleanup the assets files used by versions of ooniprobe
|
|
|
|
// older than v3.9.0, where we started embedding the assets
|
|
|
|
// into the binary and use that directly. This cleanup doesn't
|
|
|
|
// remove the whole directory but only known files inside it
|
|
|
|
// and then the directory itself, if empty. We explicitly discard
|
|
|
|
// the return value as it does not matter to us here.
|
2021-02-02 12:05:47 +01:00
|
|
|
assetsDir := path.Join(miniooniDir, "assets")
|
2021-04-01 16:57:31 +02:00
|
|
|
_, _ = assetsdir.Cleanup(assetsDir)
|
|
|
|
|
2021-02-02 12:05:47 +01:00
|
|
|
log.Debugf("miniooni state directory: %s", miniooniDir)
|
|
|
|
log.Info("miniooni home directory: $HOME/.miniooni")
|
|
|
|
|
2022-08-31 10:20:04 +02:00
|
|
|
acquireUserConsent(miniooniDir, currentOptions)
|
2021-02-02 12:05:47 +01:00
|
|
|
|
2022-08-31 10:20:04 +02:00
|
|
|
sess := newSessionOrPanic(ctx, currentOptions, miniooniDir, logger)
|
2021-02-02 12:05:47 +01:00
|
|
|
defer func() {
|
|
|
|
sess.Close()
|
|
|
|
log.Infof("whole session: recv %s, sent %s",
|
refactor: flatten and separate (#353)
* refactor(atomicx): move outside the engine package
After merging probe-engine into probe-cli, my impression is that we have
too much unnecessary nesting of packages in this repository.
The idea of this commit and of a bunch of following commits will instead
be to reduce the nesting and simplify the structure.
While there, improve the documentation.
* fix: always use the atomicx package
For consistency, never use sync/atomic and always use ./internal/atomicx
so we can just grep and make sure we're not risking to crash if we make
a subtle mistake on a 32 bit platform.
While there, mention in the contributing guidelines that we want to
always prefer the ./internal/atomicx package over sync/atomic.
* fix(atomicx): remove unnecessary constructor
We don't need a constructor here. The default constructed `&Int64{}`
instance is already usable and the constructor does not add anything to
what we are doing, rather it just creates extra confusion.
* cleanup(atomicx): we are not using Float64
Because atomicx.Float64 is unused, we can safely zap it.
* cleanup(atomicx): simplify impl and improve tests
We can simplify the implementation by using defer and by letting
the Load() method call Add(0).
We can improve tests by making many goroutines updated the
atomic int64 value concurrently.
* refactor(fsx): can live in the ./internal pkg
Let us reduce the amount of nesting. While there, ensure that the
package only exports the bare minimum, and improve the documentation
of the tests, to ease reading the code.
* refactor: move runtimex to ./internal
* refactor: move shellx into the ./internal package
While there, remove unnecessary dependency between packages.
While there, specify in the contributing guidelines that
one should use x/sys/execabs instead of os/exec.
* refactor: move ooapi into the ./internal pkg
* refactor(humanize): move to ./internal and better docs
* refactor: move platform to ./internal
* refactor(randx): move to ./internal
* refactor(multierror): move into the ./internal pkg
* refactor(kvstore): all kvstores in ./internal
Rather than having part of the kvstore inside ./internal/engine/kvstore
and part in ./internal/engine/kvstore.go, let us put every piece of code
that is kvstore related into the ./internal/kvstore package.
* fix(kvstore): always return ErrNoSuchKey on Get() error
It should help to use the kvstore everywhere removing all the
copies that are lingering around the tree.
* sessionresolver: make KVStore mandatory
Simplifies implementation. While there, use the ./internal/kvstore
package rather than having our private implementation.
* fix(ooapi): use the ./internal/kvstore package
* fix(platform): better documentation
2021-06-04 10:34:18 +02:00
|
|
|
humanize.SI(sess.KibiBytesReceived()*1024, "byte"),
|
|
|
|
humanize.SI(sess.KibiBytesSent()*1024, "byte"),
|
2021-02-02 12:05:47 +01:00
|
|
|
)
|
|
|
|
}()
|
2022-08-31 10:20:04 +02:00
|
|
|
lookupBackendsOrPanic(ctx, sess)
|
|
|
|
lookupLocationOrPanic(ctx, sess)
|
2021-02-02 12:05:47 +01:00
|
|
|
|
2022-07-08 15:17:52 +02:00
|
|
|
// We handle the oonirun experiment name specially. The user must specify
|
|
|
|
// `miniooni -i {OONIRunURL} oonirun` to run a OONI Run URL (v1 or v2).
|
|
|
|
if experimentName == "oonirun" {
|
|
|
|
ooniRunMain(ctx, sess, currentOptions, annotations)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise just run OONI experiments as we normally do.
|
2022-08-31 10:20:04 +02:00
|
|
|
runx(ctx, sess, experimentName, annotations, extraOptions, currentOptions)
|
2022-07-08 15:17:52 +02:00
|
|
|
}
|
2022-08-31 12:44:46 +02:00
|
|
|
|
|
|
|
func documentationForOptions(name string, factory *registry.Factory) string {
|
|
|
|
var sb strings.Builder
|
|
|
|
options, err := factory.Options()
|
|
|
|
if err != nil || len(options) < 1 {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
fmt.Fprint(&sb, "Pass KEY=VALUE options to the experiment. Available options:\n")
|
|
|
|
for name, info := range options {
|
|
|
|
if info.Doc == "" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
fmt.Fprintf(&sb, "\n")
|
|
|
|
fmt.Fprintf(&sb, " -O, --option %s=<%s>\n", name, info.Type)
|
|
|
|
fmt.Fprintf(&sb, " %s\n", info.Doc)
|
|
|
|
}
|
|
|
|
return sb.String()
|
|
|
|
}
|