03e7d2ccac
* go.mod go.sum: update all non-probe-engine deps For each line in the go.mod, run `go get -u -v $package` if the line is not an indirect dependency and is not probe-engine. Upgrading probe-engine is going to require the same spell that is used in probe-engine to update psiphon. * go get -v github.com/ooni/probe-engine@v0.5.0 This just pins to the latest probe-engine but we've not manually pinned all the other dependencieds yet. Take care of the trivial API changes in probe-engine as well, such that we can have a working build after this commit. * go.mod go.sum: pin to probe-engine dependencies Basically: remove all indirect dependencies. Merge this go.mod with the one of probe-engine, to pin dependencies. Run `go mod tidy`. * circumvention: add basic implementation of tor This needs to be polished further, of course. But at least we have now added support for running tor in the circumvention group. * Readme.md: document how to update dependencies * go get -v github.com/ooni/probe-engine@fcc9ee0a7afb * go get -v github.com/ooni/probe-engine@4d254f5b2 * nettests/tor.go: implement summary test keys
73 lines
2.5 KiB
Go
73 lines
2.5 KiB
Go
package nettests
|
|
|
|
// Tor test implementation
|
|
type Tor struct {
|
|
}
|
|
|
|
// Run starts the test
|
|
func (h Tor) Run(ctl *Controller) error {
|
|
builder, err := ctl.Ctx.Session.NewExperimentBuilder(
|
|
"tor",
|
|
)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return ctl.Run(builder, []string{""})
|
|
}
|
|
|
|
// TorTestKeys contains the test keys
|
|
type TorTestKeys struct {
|
|
DirPortTotal int64 `json:"dir_port_total"`
|
|
DirPortAccessible int64 `json:"dir_port_accessible"`
|
|
IsAnomaly bool `json:"-"`
|
|
OBFS4Total int64 `json:"obfs4_total"`
|
|
OBFS4Accessible int64 `json:"obfs4_accessible"`
|
|
ORPortDirauthTotal int64 `json:"or_port_dirauth_total"`
|
|
ORPortDirauthAccessible int64 `json:"or_port_dirauth_accessible"`
|
|
ORPortTotal int64 `json:"or_port_total"`
|
|
ORPortAccessible int64 `json:"or_port_accessible"`
|
|
}
|
|
|
|
// GetTestKeys generates a summary for a test run
|
|
func (h Tor) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
|
|
testKeys := TorTestKeys{IsAnomaly: false}
|
|
// Implementation note: when Go marshals into an interface, it marshals to
|
|
// float64 rather than int64, so we need to do some more work here.
|
|
//
|
|
// See <https://golang.org/pkg/encoding/json/#Unmarshal>.
|
|
if tk["dir_port_total"] != nil {
|
|
testKeys.DirPortTotal = int64(tk["dir_port_total"].(float64))
|
|
}
|
|
if tk["dir_port_accessible"] != nil {
|
|
testKeys.DirPortAccessible = int64(tk["dir_port_accessible"].(float64))
|
|
}
|
|
if tk["obfs4_total"] != nil {
|
|
testKeys.OBFS4Total = int64(tk["obfs4_total"].(float64))
|
|
}
|
|
if tk["obfs4_accessible"] != nil {
|
|
testKeys.OBFS4Accessible = int64(tk["obfs4_accessible"].(float64))
|
|
}
|
|
if tk["or_port_dirauth_total"] != nil {
|
|
testKeys.ORPortDirauthTotal = int64(tk["or_port_dirauth_total"].(float64))
|
|
}
|
|
if tk["or_port_dirauth_accessible"] != nil {
|
|
testKeys.ORPortDirauthAccessible = int64(tk["or_port_dirauth_accessible"].(float64))
|
|
}
|
|
if tk["or_port_total"] != nil {
|
|
testKeys.ORPortTotal = int64(tk["or_port_total"].(float64))
|
|
}
|
|
if tk["or_port_accessible"] != nil {
|
|
testKeys.ORPortAccessible = int64(tk["or_port_accessible"].(float64))
|
|
}
|
|
testKeys.IsAnomaly = ((testKeys.DirPortAccessible <= 0 && testKeys.DirPortTotal > 0) ||
|
|
(testKeys.OBFS4Accessible <= 0 && testKeys.OBFS4Total > 0) ||
|
|
(testKeys.ORPortDirauthAccessible <= 0 && testKeys.ORPortDirauthTotal > 0) ||
|
|
(testKeys.ORPortAccessible <= 0 && testKeys.ORPortTotal > 0))
|
|
return testKeys, nil
|
|
}
|
|
|
|
// LogSummary writes the summary to the standard output
|
|
func (h Tor) LogSummary(s string) error {
|
|
return nil
|
|
}
|