Add functions to handling migration from legacy OONI Probe

This commit is contained in:
Arturo Filastò 2018-02-12 12:18:14 +02:00
commit 602a5dc952
6 changed files with 290 additions and 73 deletions

77
ooni.go
View file

@ -4,11 +4,24 @@ import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
homedir "github.com/mitchellh/go-homedir"
"github.com/openobservatory/gooni/config"
"github.com/pkg/errors"
)
// GetOONIHome returns the path to the OONI Home
func GetOONIHome() (string, error) {
home, err := homedir.Dir()
if err != nil {
return "", err
}
path := filepath.Join(home, ".ooni")
return path, nil
}
// Config for the OONI Probe installation
type Config struct {
// Private settings
@ -26,70 +39,6 @@ type Config struct {
// Default config settings
func (c *Config) Default() error {
// This is the default configuration:
/*
_: 'This is your OONI Probe config file. See https://ooni.io/help/ooniprobe-cli for help',
auto_update: true,
sharing: {
include_ip: false,
include_asn: true,
include_gps: true,
upload_results: true,
send_crash_reports: true
},
notifications: {
enabled: true,
notify_on_test_completion: true,
notify_on_news: false
},
automated_testing: {
enabled: false,
enabled_tests: [
'web-connectivity',
'facebook-messenger',
'whatsapp',
'telegram',
'dash',
'ndt',
'http-invalid-request-line',
'http-header-field-manipulation'
],
monthly_allowance: '300MB'
},
test_settings: {
websites: {
enabled_categories: []
},
instant_messaging: {
enabled_tests: [
'facebook-messenger',
'whatsapp',
'telegram'
]
},
performance: {
enabled_tests: [
'ndt'
],
ndt_server: 'auto',
ndt_server_port: 'auto',
dash_server: 'auto',
dash_server_port: 'auto'
},
middlebox: {
enabled_tests: [
'http-invalid-request-line',
'http-header-field-manipulation'
]
}
},
advanced: {
include_country: true,
use_domain_fronting: true
},
_config_version: CONFIG_VERSION,
_informed_consent: false
*/
return nil
}