Skip to content

Commit

Permalink
libminiooni: stop using --{bouncer,collector}-base-url
Browse files Browse the repository at this point in the history
Part of #621
  • Loading branch information
bassosimone committed May 27, 2020
1 parent f240976 commit d334e19
Showing 1 changed file with 42 additions and 30 deletions.
72 changes: 42 additions & 30 deletions libminiooni/libminiooni.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,21 @@ import (

// Options contains the options you can set from the CLI.
type Options struct {
Annotations []string
BouncerURL string
CollectorURL string
Inputs []string
ExtraOptions []string
NoBouncer bool
NoGeoIP bool
NoJSON bool
NoCollector bool
Proxy string
ReportFile string
SelfCensorSpec string
TorArgs []string
TorBinary string
Tunnel string
Verbose bool
Annotations []string
Inputs []string
ExtraOptions []string
NoBouncer bool
NoGeoIP bool
NoJSON bool
NoCollector bool
ProbeServicesURL string
Proxy string
ReportFile string
SelfCensorSpec string
TorArgs []string
TorBinary string
Tunnel string
Verbose bool
}

const (
Expand All @@ -52,20 +51,23 @@ const (
)

var (
globalOptions Options
startTime = time.Now()
bouncerURLUnused string
collectorURLUnused string
globalOptions Options
startTime = time.Now()
)

func init() {
getopt.FlagLong(
&globalOptions.Annotations, "annotation", 'A', "Add annotaton", "KEY=VALUE",
)
getopt.FlagLong(
&globalOptions.BouncerURL, "bouncer", 'b', "Set bouncer base URL", "URL",
&bouncerURLUnused, "bouncer", 'b',
"Unsupported option that used to set the bouncer base URL", "URL",
)
getopt.FlagLong(
&globalOptions.CollectorURL, "collector", 'c',
"Set collector base URL", "URL",
&collectorURLUnused, "collector", 'c',
"Unsupported option that used to set the collector base URL", "URL",
)
getopt.FlagLong(
&globalOptions.Inputs, "input", 'i',
Expand All @@ -80,14 +82,18 @@ func init() {
)
getopt.FlagLong(
&globalOptions.NoGeoIP, "no-geoip", 'g',
"Disable GeoIP lookup (not implemented!)",
"Unsupported option that used to disable GeoIP lookup",
)
getopt.FlagLong(
&globalOptions.NoJSON, "no-json", 'N', "Disable writing to disk",
)
getopt.FlagLong(
&globalOptions.NoCollector, "no-collector", 'n', "Don't use a collector",
)
getopt.FlagLong(
&globalOptions.ProbeServicesURL, "probe-services-url", 0,
"Set the URL of the probe-services instance you want to use", "URL",
)
getopt.FlagLong(
&globalOptions.Proxy, "proxy", 'P', "Set the proxy URL", "URL",
)
Expand Down Expand Up @@ -215,6 +221,15 @@ func gethomedir() string {
// 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.
func MainWithConfiguration(experimentName string, currentOptions Options) {
fatalIfFalse(
bouncerURLUnused == "",
"-b,--bouncer is not supported anymore, use --probe-services-url instead",
)
fatalIfFalse(
collectorURLUnused == "",
"-c,--collector is not supported anymore, use --probe-services-url instead",
)

extraOptions := mustMakeMap(currentOptions.ExtraOptions)
annotations := mustMakeMap(currentOptions.Annotations)

Expand Down Expand Up @@ -265,18 +280,15 @@ func MainWithConfiguration(experimentName string, currentOptions Options) {
TorArgs: currentOptions.TorArgs,
TorBinary: currentOptions.TorBinary,
}
if currentOptions.BouncerURL != "" {
if currentOptions.ProbeServicesURL != "" {
// TODO(bassosimone): in a follow-up commit we will unify
// these two config variables into a single variable
config.AvailableBouncers = []model.Service{{
Address: currentOptions.BouncerURL,
Address: currentOptions.ProbeServicesURL,
Type: "https",
}}
}
if currentOptions.CollectorURL != "" {
// Implementation note: setting the collector before doing the lookup
// is totally fine because it's a maybe lookup, meaning that any bit
// of information already available will not be looked up again.
config.AvailableCollectors = []model.Service{{
Address: currentOptions.CollectorURL,
Address: currentOptions.ProbeServicesURL,
Type: "https",
}}
}
Expand Down

0 comments on commit d334e19

Please sign in to comment.