feat(miniooni): add the --censor flag (#571)
This flag is similar to the previous --self-censor-spec and tells miniooni what censorship to implement for itself. This concludes the design at https://github.com/ooni/probe/issues/1803#issuecomment-957323297
This commit is contained in:
parent
100cc559a2
commit
6f90d29bfa
|
@ -20,6 +20,9 @@ import (
|
||||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||||
"github.com/ooni/probe-cli/v3/internal/humanize"
|
"github.com/ooni/probe-cli/v3/internal/humanize"
|
||||||
"github.com/ooni/probe-cli/v3/internal/kvstore"
|
"github.com/ooni/probe-cli/v3/internal/kvstore"
|
||||||
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||||
|
"github.com/ooni/probe-cli/v3/internal/netxlite/filtering"
|
||||||
|
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||||
"github.com/ooni/probe-cli/v3/internal/version"
|
"github.com/ooni/probe-cli/v3/internal/version"
|
||||||
"github.com/pborman/getopt/v2"
|
"github.com/pborman/getopt/v2"
|
||||||
)
|
)
|
||||||
|
@ -27,6 +30,7 @@ import (
|
||||||
// Options contains the options you can set from the CLI.
|
// Options contains the options you can set from the CLI.
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Annotations []string
|
Annotations []string
|
||||||
|
Censor string
|
||||||
ExtraOptions []string
|
ExtraOptions []string
|
||||||
HomeDir string
|
HomeDir string
|
||||||
Inputs []string
|
Inputs []string
|
||||||
|
@ -61,6 +65,10 @@ func init() {
|
||||||
getopt.FlagLong(
|
getopt.FlagLong(
|
||||||
&globalOptions.Annotations, "annotation", 'A', "Add annotaton", "KEY=VALUE",
|
&globalOptions.Annotations, "annotation", 'A', "Add annotaton", "KEY=VALUE",
|
||||||
)
|
)
|
||||||
|
getopt.FlagLong(
|
||||||
|
&globalOptions.Censor, "censor", 0,
|
||||||
|
"Specifies censorship rules to apply for QA purposes", "FILE",
|
||||||
|
)
|
||||||
getopt.FlagLong(
|
getopt.FlagLong(
|
||||||
&globalOptions.ExtraOptions, "option", 'O',
|
&globalOptions.ExtraOptions, "option", 'O',
|
||||||
"Pass an option to the experiment", "KEY=VALUE",
|
"Pass an option to the experiment", "KEY=VALUE",
|
||||||
|
@ -307,6 +315,17 @@ func MainWithConfiguration(experimentName string, currentOptions Options) {
|
||||||
}
|
}
|
||||||
log.Log = logger
|
log.Log = logger
|
||||||
|
|
||||||
|
if currentOptions.Censor != "" {
|
||||||
|
config, err := filtering.NewTProxyConfig(currentOptions.Censor)
|
||||||
|
runtimex.PanicOnError(err, "cannot parse --censor file as JSON")
|
||||||
|
tproxy, err := filtering.NewTProxy(config, log.Log)
|
||||||
|
runtimex.PanicOnError(err, "cannot create tproxy instance")
|
||||||
|
defer tproxy.Close()
|
||||||
|
netxlite.TProxy = tproxy
|
||||||
|
log.Infof("miniooni: disabling submission with --censor to avoid pulluting OONI data")
|
||||||
|
currentOptions.NoCollector = true
|
||||||
|
}
|
||||||
|
|
||||||
//Mon Jan 2 15:04:05 -0700 MST 2006
|
//Mon Jan 2 15:04:05 -0700 MST 2006
|
||||||
log.Infof("Current time: %s", time.Now().Format("2006-01-02 15:04:05 MST"))
|
log.Infof("Current time: %s", time.Now().Format("2006-01-02 15:04:05 MST"))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user