Merge pull request #109 from ooni/config/category-codes

Config/category codes
This commit is contained in:
Arturo Filastò 2020-02-13 14:21:19 +01:00 committed by GitHub
commit 5d45fb8028
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -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"`
}

View File

@ -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.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
}