feat(torsf): add default_timeout test keys (#709)

See https://github.com/ooni/probe/issues/2061
This commit is contained in:
DecFox 2022-05-06 14:17:26 +05:30 committed by GitHub
parent 4c55102789
commit b81af5b058
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,6 +42,9 @@ type TestKeys struct {
// BootstrapTime contains the bootstrap time on success.
BootstrapTime float64 `json:"bootstrap_time"`
// DefaultTimeout contains the default timeout for torsf
DefaultTimeout float64 `json:"default_timeout"`
// Failure contains the failure string or nil.
Failure *string `json:"failure"`
@ -113,7 +116,7 @@ func (m *Measurer) Run(
tkch := make(chan *TestKeys)
ticker := time.NewTicker(2 * time.Second)
defer ticker.Stop()
go m.bootstrap(ctx, sess, tkch, ptl, sfdialer)
go m.bootstrap(ctx, maxRuntime, sess, tkch, ptl, sfdialer)
for {
select {
case tk := <-tkch:
@ -159,10 +162,11 @@ func (m *Measurer) setup(ctx context.Context,
}
// bootstrap runs the bootstrap.
func (m *Measurer) bootstrap(ctx context.Context, sess model.ExperimentSession,
func (m *Measurer) bootstrap(ctx context.Context, timeout time.Duration, sess model.ExperimentSession,
out chan<- *TestKeys, ptl *ptx.Listener, sfdialer *ptx.SnowflakeDialer) {
tk := &TestKeys{
BootstrapTime: 0,
DefaultTimeout: timeout.Seconds(),
Failure: nil,
PersistentDatadir: !m.config.DisablePersistentDatadir,
RendezvousMethod: sfdialer.RendezvousMethod.Name(),