Get web_connectivity to work with dynamic URL fetching
This commit is contained in:
parent
4bbffa9cd5
commit
00859e87a6
6 changed files with 104 additions and 8 deletions
33
ooni.go
33
ooni.go
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/openobservatory/gooni/config"
|
||||
"github.com/openobservatory/gooni/internal/database"
|
||||
"github.com/openobservatory/gooni/internal/legacy"
|
||||
"github.com/openobservatory/gooni/utils"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
|
@ -35,15 +36,39 @@ func Onboarding(c *Config) error {
|
|||
|
||||
// Context for OONI Probe
|
||||
type Context struct {
|
||||
Config *Config
|
||||
DB *sqlx.DB
|
||||
Config *Config
|
||||
DB *sqlx.DB
|
||||
Location *utils.LocationInfo
|
||||
|
||||
Home string
|
||||
TempDir string
|
||||
|
||||
Home string
|
||||
TempDir string
|
||||
dbPath string
|
||||
configPath string
|
||||
}
|
||||
|
||||
// MaybeLocationLookup will lookup the location of the user unless it's already cached
|
||||
func (c *Context) MaybeLocationLookup() error {
|
||||
if c.Location == nil {
|
||||
return c.LocationLookup()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// LocationLookup lookup the location of the user via geoip
|
||||
func (c *Context) LocationLookup() error {
|
||||
var err error
|
||||
|
||||
dbPath := filepath.Join(c.Home, "geoip")
|
||||
|
||||
c.Location, err = utils.GeoIPLookup(dbPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Init the OONI manager
|
||||
func (c *Context) Init() error {
|
||||
var err error
|
||||
|
|
|
|||
Loading…
Reference in a new issue