Skip to content

Commit

Permalink
feat: more changes to facilitate debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Mar 21, 2023
1 parent 6e72744 commit a372027
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
69 changes: 69 additions & 0 deletions internal/cmd/testtorsf/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//go:build ooni_libtor

package main

import (
"context"
"net/http"
"time"

"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/experiment/torsf"
"github.com/ooni/probe-cli/v3/internal/kvstore"
"github.com/ooni/probe-cli/v3/internal/model"
"github.com/ooni/probe-cli/v3/internal/model/mocks"
"github.com/ooni/probe-cli/v3/internal/runtimex"
)

func runit() {
measurer := torsf.NewExperimentMeasurer(torsf.Config{
DisablePersistentDatadir: false,
DisableProgress: false,
RendezvousMethod: "",
})
meas := &model.Measurement{}
err := measurer.Run(
context.Background(),
&model.ExperimentArgs{
Callbacks: model.NewPrinterCallbacks(model.DiscardLogger),
Measurement: meas,
Session: &mocks.Session{
MockDefaultHTTPClient: func() model.HTTPClient {
return http.DefaultClient
},
MockKeyValueStore: func() model.KeyValueStore {
return &kvstore.Memory{}
},
MockLogger: func() model.Logger {
return log.Log
},
MockSoftwareName: func() string {
return "miniooni"
},
MockSoftwareVersion: func() string {
return "0.1.0-dev"
},
MockTempDir: func() string {
return "x/tmp"
},
MockTunnelDir: func() string {
return "x/tunnel"
},
MockUserAgent: func() string {
return model.HTTPHeaderUserAgent
},
},
},
)
runtimex.PanicOnError(err, "measurer.Run failed")
tk := meas.TestKeys.(*torsf.TestKeys)
runtimex.Assert(tk.Success, "did not succeed")
}

func main() {
for {
runit()
log.Info("************* now let's wait a bit ********************************")
time.Sleep(45 * time.Second)
}
}
2 changes: 1 addition & 1 deletion internal/tunnel/torembed.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build ooni_libtor && android
//go:build ooni_libtor && (android || linux)

package tunnel

Expand Down

0 comments on commit a372027

Please sign in to comment.