Skip to content

Commit

Permalink
Merge pull request #92 from ooni/develop
Browse files Browse the repository at this point in the history
Release 3.0.0-rc.5
  • Loading branch information
bassosimone authored Dec 28, 2019
2 parents 5e868fe + 628766d commit c4a87ea
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/dist
/ooni.cov
/ooniprobe
/coverage.cov
/testdata/gotmp
*.njson
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/kr/pty v1.1.8 // indirect
github.com/mattn/go-colorable v0.1.4
github.com/mattn/go-isatty v0.0.11 // indirect
github.com/ooni/probe-engine v0.3.0
github.com/ooni/probe-engine v0.4.0
github.com/pkg/errors v0.8.1
github.com/rubenv/sql-migrate v0.0.0-20191213152630-06338513c237
golang.org/x/sys v0.0.0-20191224085550-c709ea063b76 // indirect
Expand Down
76 changes: 4 additions & 72 deletions go.sum

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions internal/cli/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ func init() {
middleboxCmd.Action(func(_ *kingpin.ParseContext) error {
return runNettestGroup("middlebox", ctx, network)
})
circumventionCmd := cmd.Command("circumvention", "")
circumventionCmd.Action(func(_ *kingpin.ParseContext) error {
return runNettestGroup("circumvention", ctx, network)
})
allCmd := cmd.Command("all", "").Default()
allCmd.Action(func(_ *kingpin.ParseContext) error {
log.Infof("Running %s tests", color.BlueString("all"))
Expand Down
9 changes: 6 additions & 3 deletions internal/log/handlers/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,13 @@ func (h *Handler) TypedLog(t string, e *log.Entry) error {
case "progress":
perc := e.Fields.Get("percentage").(float64) * 100
eta := e.Fields.Get("eta").(float64)
s := fmt.Sprintf(" %s %-25s (%ss left)",
var etaMessage string
if eta >= 0 {
etaMessage = fmt.Sprintf("(%ss left)", bold.Sprintf("%.2f", eta))
}
s := fmt.Sprintf(" %s %-25s %s",
bold.Sprintf("%.2f%%", perc),
e.Message,
bold.Sprintf("%.2f", eta))
e.Message, etaMessage)
fmt.Fprint(h.Writer, s)
fmt.Fprintln(h.Writer)
return nil
Expand Down
7 changes: 7 additions & 0 deletions internal/log/handlers/cli/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ var summarizers = map[string]func(uint64, uint64, string) []string{
"",
}
},
"circumvention": func(totalCount uint64, anomalyCount uint64, ss string) []string {
return []string{
fmt.Sprintf("Detected: %v", anomalyCount > 0),
"",
"",
}
},
}

func makeSummary(name string, totalCount uint64, anomalyCount uint64, ss string) []string {
Expand Down
6 changes: 6 additions & 0 deletions nettests/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ var NettestGroups = map[string]NettestGroup{
WhatsApp{},
},
},
"circumvention": NettestGroup{
Label: "Circumvention Tools",
Nettests: []Nettest{
Psiphon{},
},
},
}
6 changes: 4 additions & 2 deletions nettests/nettests.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,14 @@ func (c *Controller) OnProgress(perc float64, msg string) {
log.Debugf("OnProgress: %f - %s", perc, msg)
var eta float64
eta = -1.0
if c.numInputs >= 1 {
if c.numInputs > 1 {
// make the percentage relative to the current input over all inputs
floor := (float64(c.curInputIdx) / float64(c.numInputs))
step := 1.0 / float64(c.numInputs)
perc = floor + perc*step
eta = (float64(time.Now().Sub(c.ntStartTime).Seconds()) / float64(c.curInputIdx)) * float64(c.numInputs-c.curInputIdx)
if c.curInputIdx > 0 {
eta = (time.Now().Sub(c.ntStartTime).Seconds() / float64(c.curInputIdx)) * float64(c.numInputs-c.curInputIdx)
}
}
if c.ntCount > 0 {
// make the percentage relative to the current nettest over all nettests
Expand Down
33 changes: 33 additions & 0 deletions nettests/psiphon.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package nettests

// Psiphon test implementation
type Psiphon struct {
}

// Run starts the test
func (h Psiphon) Run(ctl *Controller) error {
builder, err := ctl.Ctx.Session.NewExperimentBuilder(
"psiphon",
)
if err != nil {
return err
}
return ctl.Run(builder, []string{""})
}

// PsiphonTestKeys contains the test keys
type PsiphonTestKeys struct {
IsAnomaly bool `json:"-"`
}

// GetTestKeys generates a summary for a test run
func (h Psiphon) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
return PsiphonTestKeys{
IsAnomaly: tk["failure"] != nil,
}, nil
}

// LogSummary writes the summary to the standard output
func (h Psiphon) LogSummary(s string) error {
return nil
}
3 changes: 0 additions & 3 deletions nettests/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ func (h Telegram) Run(ctl *Controller) error {
if err != nil {
return err
}
if err := builder.SetOptionString("LogLevel", "INFO"); err != nil {
return err
}
return ctl.Run(builder, []string{""})
}

Expand Down
8 changes: 8 additions & 0 deletions ooni.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,15 @@ func (c *Context) Init() error {
}
c.TempDir = tempDir

kvstore, err := engine.NewFileSystemKVStore(
utils.EngineDir(c.Home),
)
if err != nil {
return errors.Wrap(err, "creating engine's kvstore")
}

sess, err := engine.NewSession(engine.SessionConfig{
KVStore: kvstore,
Logger: enginex.Logger,
SoftwareName: "ooniprobe-desktop",
SoftwareVersion: version.Version,
Expand Down
6 changes: 6 additions & 0 deletions utils/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ func AssetsDir(home string) string {
return filepath.Join(home, "assets")
}

// EngineDir returns the directory where ooni/probe-engine should
// store its private data given a specific OONI Home.
func EngineDir(home string) string {
return filepath.Join(home, "engine")
}

// DBDir returns the database dir for the given name
func DBDir(home string, name string) string {
return filepath.Join(home, "db", fmt.Sprintf("%s.sqlite3", name))
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package version

const (
// Version is the software version
Version = "3.0.0-rc.4"
Version = "3.0.0-rc.5"

// UserAgent is the OONI user-agent header
UserAgent = "ooniprobe-desktop/" + Version
Expand Down

0 comments on commit c4a87ea

Please sign in to comment.