Workaround for: https://github.com/measurement-kit/measurement-kit/issues/1635
This commit is contained in:
parent
74614b33fb
commit
f0926cc38d
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
"github.com/measurement-kit/go-measurement-kit"
|
"github.com/measurement-kit/go-measurement-kit"
|
||||||
|
homedir "github.com/mitchellh/go-homedir"
|
||||||
ooni "github.com/ooni/probe-cli"
|
ooni "github.com/ooni/probe-cli"
|
||||||
"github.com/ooni/probe-cli/internal/cli/version"
|
"github.com/ooni/probe-cli/internal/cli/version"
|
||||||
"github.com/ooni/probe-cli/internal/colors"
|
"github.com/ooni/probe-cli/internal/colors"
|
||||||
|
@ -68,11 +69,56 @@ func (c *Controller) Init(nt *mk.Nettest) error {
|
||||||
ReportFilePath: c.msmtPath,
|
ReportFilePath: c.msmtPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("OutputPath: %s", c.msmtPath)
|
// This is to workaround homedirs having UTF-8 characters in them.
|
||||||
|
// See: https://github.com/measurement-kit/measurement-kit/issues/1635
|
||||||
|
geoIPCountryPath := filepath.Join(utils.GeoIPDir(c.Ctx.Home), "GeoIP.dat")
|
||||||
|
geoIPASNPath := filepath.Join(utils.GeoIPDir(c.Ctx.Home), "GeoIPASNum.dat")
|
||||||
|
caBundlePath := getCaBundlePath()
|
||||||
|
msmtPath := c.msmtPath
|
||||||
|
|
||||||
|
userHome, err := homedir.Dir()
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error("failed to figure out the homedir")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
relPath, err := filepath.Rel(userHome, caBundlePath)
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error("caBundlePath is not relative to the users home")
|
||||||
|
} else {
|
||||||
|
caBundlePath = relPath
|
||||||
|
}
|
||||||
|
relPath, err = filepath.Rel(userHome, geoIPASNPath)
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error("geoIPASNPath is not relative to the users home")
|
||||||
|
} else {
|
||||||
|
geoIPASNPath = relPath
|
||||||
|
}
|
||||||
|
relPath, err = filepath.Rel(userHome, geoIPCountryPath)
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error("geoIPCountryPath is not relative to the users home")
|
||||||
|
} else {
|
||||||
|
geoIPCountryPath = relPath
|
||||||
|
}
|
||||||
|
relPath, err = filepath.Rel(userHome, msmtPath)
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error("msmtPath is not relative to the users home")
|
||||||
|
} else {
|
||||||
|
msmtPath = relPath
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("Chdir to: %s", userHome)
|
||||||
|
if err := os.Chdir(userHome); err != nil {
|
||||||
|
log.WithError(err).Errorf("failed to chdir to %s", userHome)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("OutputPath: %s", msmtPath)
|
||||||
nt.Options = mk.NettestOptions{
|
nt.Options = mk.NettestOptions{
|
||||||
IncludeIP: c.Ctx.Config.Sharing.IncludeIP,
|
IncludeIP: c.Ctx.Config.Sharing.IncludeIP,
|
||||||
IncludeASN: c.Ctx.Config.Sharing.IncludeASN,
|
IncludeASN: c.Ctx.Config.Sharing.IncludeASN,
|
||||||
IncludeCountry: c.Ctx.Config.Advanced.IncludeCountry,
|
IncludeCountry: c.Ctx.Config.Advanced.IncludeCountry,
|
||||||
|
LogLevel: "DEBUG",
|
||||||
|
|
||||||
ProbeCC: c.Ctx.Location.CountryCode,
|
ProbeCC: c.Ctx.Location.CountryCode,
|
||||||
ProbeASN: fmt.Sprintf("AS%d", c.Ctx.Location.ASN),
|
ProbeASN: fmt.Sprintf("AS%d", c.Ctx.Location.ASN),
|
||||||
|
@ -82,12 +128,13 @@ func (c *Controller) Init(nt *mk.Nettest) error {
|
||||||
SoftwareName: "ooniprobe",
|
SoftwareName: "ooniprobe",
|
||||||
SoftwareVersion: version.Version,
|
SoftwareVersion: version.Version,
|
||||||
|
|
||||||
// XXX
|
OutputPath: msmtPath,
|
||||||
GeoIPCountryPath: filepath.Join(utils.GeoIPDir(c.Ctx.Home), "GeoIP.dat"),
|
GeoIPCountryPath: geoIPCountryPath,
|
||||||
GeoIPASNPath: filepath.Join(utils.GeoIPDir(c.Ctx.Home), "GeoIPASNum.dat"),
|
GeoIPASNPath: geoIPASNPath,
|
||||||
OutputPath: c.msmtPath,
|
CaBundlePath: caBundlePath,
|
||||||
CaBundlePath: getCaBundlePath(),
|
|
||||||
}
|
}
|
||||||
|
log.Debugf("GeoIPASNPath: %s", nt.Options.GeoIPASNPath)
|
||||||
|
log.Debugf("GeoIPCountryPath: %s", nt.Options.GeoIPCountryPath)
|
||||||
|
|
||||||
nt.On("log", func(e mk.Event) {
|
nt.On("log", func(e mk.Event) {
|
||||||
level := e.Value.LogLevel
|
level := e.Value.LogLevel
|
||||||
|
|
Loading…
Reference in New Issue
Block a user