From 0d2118649250e5564b3ffc2c2feab0d58927ebc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Fri, 21 Sep 2018 18:54:44 +0200 Subject: [PATCH] Add support for custom collectors and bouncers --- Gopkg.lock | 2 +- config/settings.go | 6 ++++-- config/testdata/valid-config.json | 4 +++- data/default-config.json | 4 +++- internal/cli/run/run.go | 10 ++++++++++ nettests/nettests.go | 2 ++ 6 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index cc34202..99abf1b 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -68,7 +68,7 @@ branch = "master" name = "github.com/measurement-kit/go-measurement-kit" packages = ["."] - revision = "18bd1b84e534aacc7292c22da5c900b6d7bff41b" + revision = "cf0ee00807adfae92a6ec595ef985c7110903369" [[projects]] branch = "master" diff --git a/config/settings.go b/config/settings.go index 49ca276..f10e28f 100644 --- a/config/settings.go +++ b/config/settings.go @@ -119,8 +119,10 @@ type Sharing struct { // Advanced settings type Advanced struct { - UseDomainFronting bool `json:"use_domain_fronting"` - SendCrashReports bool `json:"send_crash_reports"` + UseDomainFronting bool `json:"use_domain_fronting"` + SendCrashReports bool `json:"send_crash_reports"` + CollectorURL string `json:"collector_url"` + BouncerURL string `json:"bouncer_url"` } // AutomatedTesting settings diff --git a/config/testdata/valid-config.json b/config/testdata/valid-config.json index a3fecb9..7c1188d 100644 --- a/config/testdata/valid-config.json +++ b/config/testdata/valid-config.json @@ -58,6 +58,8 @@ }, "advanced": { "use_domain_fronting": false, - "send_crash_reports": true + "send_crash_reports": true, + "bouncer_url": "https://bouncer.ooni.io/", + "collector_url": "https://c.collector.ooni.io/", } } diff --git a/data/default-config.json b/data/default-config.json index 6f6c042..ff36f28 100644 --- a/data/default-config.json +++ b/data/default-config.json @@ -59,6 +59,8 @@ }, "advanced": { "use_domain_fronting": false, - "send_crash_reports": true + "send_crash_reports": true, + "collector_url": "", + "bouncer_url": "https://bouncer.ooni.io/" } } diff --git a/internal/cli/run/run.go b/internal/cli/run/run.go index e88a483..d7d1c24 100644 --- a/internal/cli/run/run.go +++ b/internal/cli/run/run.go @@ -27,6 +27,8 @@ func init() { strings.Join(nettestGroupNames, ", "))).Required().String() noCollector := cmd.Flag("no-collector", "Disable uploading measurements to a collector").Bool() + collectorURL := cmd.Flag("collector-url", "Specify the address of a custom collector").String() + bouncerURL := cmd.Flag("bouncer-url", "Specify the address of a custom bouncer").String() cmd.Action(func(_ *kingpin.ParseContext) error { log.Infof("Starting %s", *nettestGroup) @@ -44,6 +46,14 @@ func init() { if *noCollector == true { ctx.Config.Sharing.UploadResults = false } + if *collectorURL != "" { + ctx.Config.Advanced.CollectorURL = *collectorURL + } + if *bouncerURL != "" { + ctx.Config.Advanced.BouncerURL = *bouncerURL + } + log.Debugf("Using collector %s", ctx.Config.Advanced.CollectorURL) + log.Debugf("Using bouncer %s", ctx.Config.Advanced.CollectorURL) group, ok := groups.NettestGroups[*nettestGroup] if !ok { diff --git a/nettests/nettests.go b/nettests/nettests.go index 1348fea..4ac5ef7 100644 --- a/nettests/nettests.go +++ b/nettests/nettests.go @@ -96,6 +96,8 @@ func (c *Controller) Init(nt *mk.Nettest) error { RandomizeInput: false, // It's important to disable input randomization to ensure the URLs are written in sync to the DB SoftwareName: "ooniprobe-desktop", SoftwareVersion: ooni.Version, + CollectorBaseURL: c.Ctx.Config.Advanced.CollectorURL, + BouncerBaseURL: c.Ctx.Config.Advanced.BouncerURL, OutputPath: msmtPath, GeoIPCountryPath: geoIPCountryPath,