Add functions to handling migration from legacy OONI Probe
This commit is contained in:
@@ -1,14 +1,87 @@
|
||||
package config
|
||||
|
||||
type websiteSettings struct {
|
||||
var websiteCategories = []string{
|
||||
"ALDR",
|
||||
"ANON",
|
||||
"COMM",
|
||||
"COMT",
|
||||
"CTRL",
|
||||
"CULTR",
|
||||
"DATE",
|
||||
"ECON",
|
||||
"ENV",
|
||||
"FILE",
|
||||
"GAME",
|
||||
"GMB",
|
||||
"GOVT",
|
||||
"GRP",
|
||||
"HACK",
|
||||
"HATE",
|
||||
"HOST",
|
||||
"HUMR",
|
||||
"IGO",
|
||||
"LGBT",
|
||||
"MILX",
|
||||
"MMED",
|
||||
"NEWS",
|
||||
"POLR",
|
||||
"PORN",
|
||||
"PROV",
|
||||
"PUBH",
|
||||
"REL",
|
||||
"SRCH",
|
||||
"XED",
|
||||
}
|
||||
|
||||
// NettestConfig represents the configuration for a particular nettest
|
||||
type NettestConfig struct {
|
||||
Name string
|
||||
Options string
|
||||
}
|
||||
|
||||
// Websites test group
|
||||
type Websites struct {
|
||||
EnabledCategories []string `json:"enabled_categories"`
|
||||
}
|
||||
|
||||
type instantMessagingSettings struct {
|
||||
// NettestConfigs returns a list configured enabled tests for the group
|
||||
func (s *Websites) NettestConfigs() []NettestConfig {
|
||||
var nts []NettestConfig
|
||||
nts = append(nts, NettestConfig{"web_connectivity", "options"})
|
||||
return nts
|
||||
}
|
||||
|
||||
// InstantMessaging nettest group
|
||||
type InstantMessaging struct {
|
||||
EnabledTests []string `json:"enabled_tests"`
|
||||
}
|
||||
|
||||
type performanceSettings struct {
|
||||
func (s *InstantMessaging) isEnabled(nt string) bool {
|
||||
for _, v := range s.EnabledTests {
|
||||
if v == nt {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// NettestConfigs returns a list configured enabled tests for the group
|
||||
func (s *InstantMessaging) NettestConfigs() []NettestConfig {
|
||||
var nts []NettestConfig
|
||||
if s.isEnabled("facebook_messenger") {
|
||||
nts = append(nts, NettestConfig{"facebook_messenger", "options"})
|
||||
}
|
||||
if s.isEnabled("telegram") {
|
||||
nts = append(nts, NettestConfig{"telegram", "options"})
|
||||
}
|
||||
if s.isEnabled("whatsapp") {
|
||||
nts = append(nts, NettestConfig{"whatsapp", "options"})
|
||||
}
|
||||
return nts
|
||||
}
|
||||
|
||||
// Performance nettest group
|
||||
type Performance struct {
|
||||
EnabledTests []string `json:"enabled_tests"`
|
||||
NDTServer string `json:"ndt_server"`
|
||||
NDTServerPort string `json:"ndt_server_port"`
|
||||
@@ -16,14 +89,15 @@ type performanceSettings struct {
|
||||
DashServerPort string `json:"dash_server_port"`
|
||||
}
|
||||
|
||||
type middleboxSettings struct {
|
||||
// Middlebox nettest group
|
||||
type Middlebox struct {
|
||||
EnabledTests []string `json:"enabled_tests"`
|
||||
}
|
||||
|
||||
// NettestGroups related settings
|
||||
type NettestGroups struct {
|
||||
Websites websiteSettings `json:"websites"`
|
||||
InstantMessaging instantMessagingSettings `json:"instant_messaging"`
|
||||
Performance performanceSettings `json:"performance"`
|
||||
Middlebox middleboxSettings `json:"middlebox"`
|
||||
Websites Websites `json:"websites"`
|
||||
InstantMessaging InstantMessaging `json:"instant_messaging"`
|
||||
Performance Performance `json:"performance"`
|
||||
Middlebox Middlebox `json:"middlebox"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user