From 1f94b20be5f15e3c8bc990874a7b00968727a738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Wed, 12 Feb 2020 15:07:19 +0100 Subject: [PATCH 1/2] Add support for parsing the enabled websites category codes This implements: https://github.com/ooni/probe/issues/1012 --- config/settings.go | 1 + nettests/web_connectivity.go | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/config/settings.go b/config/settings.go index 09051f6..9cb046b 100644 --- a/config/settings.go +++ b/config/settings.go @@ -51,4 +51,5 @@ type Advanced struct { // Nettests related settings type Nettests struct { WebsitesURLLimit int64 `json:"websites_url_limit"` + WebsitesEnabledCategoryCodes []string `json:"websites_enabled_category_codes"` } diff --git a/nettests/web_connectivity.go b/nettests/web_connectivity.go index 750cd78..a52098e 100644 --- a/nettests/web_connectivity.go +++ b/nettests/web_connectivity.go @@ -6,11 +6,12 @@ import ( engine "github.com/ooni/probe-engine" ) -func lookupURLs(ctl *Controller, limit int64) ([]string, map[int64]int64, error) { +func lookupURLs(ctl *Controller, limit int64, categories []string) ([]string, map[int64]int64, error) { var urls []string urlIDMap := make(map[int64]int64) testlist, err := ctl.Ctx.Session.QueryTestListsURLs(&engine.TestListsURLsConfig{ Limit: limit, + Categories: categories, }) if err != nil { return nil, nil, err @@ -37,7 +38,8 @@ type WebConnectivity struct { // Run starts the test func (n WebConnectivity) Run(ctl *Controller) error { - urls, urlIDMap, err := lookupURLs(ctl, ctl.Ctx.Config.Nettests.WebsitesURLLimit) + log.Infof("Enabled category codes are the following %v", ctl.Ctx.Config.Nettests.WebsitesEnabledCategoryCodes) + urls, urlIDMap, err := lookupURLs(ctl, ctl.Ctx.Config.Nettests.WebsitesURLLimit, ctl.Ctx.Config.Nettests.WebsitesEnabledCategoryCodes) if err != nil { return err } From f47391e24cdc21a5f2a7632911245c1530003b3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Wed, 12 Feb 2020 15:08:36 +0100 Subject: [PATCH 2/2] Make log line be debug level --- nettests/web_connectivity.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nettests/web_connectivity.go b/nettests/web_connectivity.go index a52098e..f1ee0fb 100644 --- a/nettests/web_connectivity.go +++ b/nettests/web_connectivity.go @@ -38,7 +38,7 @@ type WebConnectivity struct { // Run starts the test func (n WebConnectivity) Run(ctl *Controller) error { - log.Infof("Enabled category codes are the following %v", ctl.Ctx.Config.Nettests.WebsitesEnabledCategoryCodes) + log.Debugf("Enabled category codes are the following %v", ctl.Ctx.Config.Nettests.WebsitesEnabledCategoryCodes) urls, urlIDMap, err := lookupURLs(ctl, ctl.Ctx.Config.Nettests.WebsitesURLLimit, ctl.Ctx.Config.Nettests.WebsitesEnabledCategoryCodes) if err != nil { return err