Use ooni/probe-engine: episode 1 (#42)
This commit is contained in:
+12
-13
@@ -4,7 +4,6 @@ import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
@@ -17,6 +16,7 @@ import (
|
||||
"github.com/ooni/probe-cli/internal/output"
|
||||
"github.com/ooni/probe-cli/utils"
|
||||
"github.com/ooni/probe-cli/utils/strcase"
|
||||
"github.com/ooni/probe-cli/version"
|
||||
)
|
||||
|
||||
// Nettest interface. Every Nettest should implement this.
|
||||
@@ -70,7 +70,10 @@ func (c *Controller) SetNettestIndex(i, n int) {
|
||||
// Init should be called once to initialise the nettest
|
||||
func (c *Controller) Init(nt *mk.Nettest) error {
|
||||
log.Debugf("Init: %v", nt)
|
||||
c.Ctx.LocationLookup()
|
||||
err := c.Ctx.MaybeLocationLookup()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.msmts = make(map[int64]*database.Measurement)
|
||||
|
||||
@@ -79,8 +82,8 @@ func (c *Controller) Init(nt *mk.Nettest) error {
|
||||
testName := strcase.ToSnake(nt.Name)
|
||||
resultID := c.res.ID
|
||||
reportFilePath := c.msmtPath
|
||||
geoIPCountryPath := filepath.Join(utils.GeoIPDir(c.Ctx.Home), "GeoLite2-Country.mmdb")
|
||||
geoIPASNPath := filepath.Join(utils.GeoIPDir(c.Ctx.Home), "GeoLite2-ASN.mmdb")
|
||||
geoIPCountryPath := c.Ctx.Session.CountryDatabasePath()
|
||||
geoIPASNPath := c.Ctx.Session.ASNDatabasePath()
|
||||
msmtPath := c.msmtPath
|
||||
|
||||
log.Debugf("OutputPath: %s", msmtPath)
|
||||
@@ -90,26 +93,22 @@ func (c *Controller) Init(nt *mk.Nettest) error {
|
||||
IncludeCountry: c.Ctx.Config.Sharing.IncludeCountry,
|
||||
LogLevel: "INFO",
|
||||
|
||||
ProbeCC: c.Ctx.Location.CountryCode,
|
||||
ProbeASN: fmt.Sprintf("AS%d", c.Ctx.Location.ASN),
|
||||
ProbeIP: c.Ctx.Location.IP,
|
||||
ProbeCC: c.Ctx.Session.ProbeCC(),
|
||||
ProbeASN: c.Ctx.Session.ProbeASNString(),
|
||||
ProbeIP: c.Ctx.Session.ProbeIP(),
|
||||
|
||||
DisableReportFile: false,
|
||||
DisableCollector: !c.Ctx.Config.Sharing.UploadResults,
|
||||
RandomizeInput: false, // It's important to disable input randomization to ensure the URLs are written in sync to the DB
|
||||
SoftwareName: "ooniprobe-desktop",
|
||||
SoftwareVersion: ooni.Version,
|
||||
SoftwareVersion: version.Version,
|
||||
CollectorBaseURL: c.Ctx.Config.Advanced.CollectorURL,
|
||||
BouncerBaseURL: c.Ctx.Config.Advanced.BouncerURL,
|
||||
|
||||
OutputPath: msmtPath,
|
||||
GeoIPCountryPath: geoIPCountryPath,
|
||||
GeoIPASNPath: geoIPASNPath,
|
||||
}
|
||||
|
||||
sslCertFile := os.Getenv("SSL_CERT_FILE")
|
||||
if sslCertFile != "" {
|
||||
nt.Options.CaBundlePath = sslCertFile
|
||||
CaBundlePath: c.Ctx.Session.CABundlePath(),
|
||||
}
|
||||
|
||||
log.Debugf("CaBundlePath: %s", nt.Options.CaBundlePath)
|
||||
|
||||
@@ -37,7 +37,7 @@ func lookupURLs(ctl *nettests.Controller) ([]string, map[int64]int64, error) {
|
||||
// XXX pass in the configuration for category codes
|
||||
reqURL := fmt.Sprintf("%s/api/v1/urls?probe_cc=%s",
|
||||
orchestrateBaseURL,
|
||||
ctl.Ctx.Location.CountryCode)
|
||||
ctl.Ctx.Session.ProbeCC())
|
||||
|
||||
resp, err := http.Get(reqURL)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user