feat: dnsping using step-by-step (#831)
Reference issue for this pull request: https://github.com/ooni/probe/issues/2159 This diff refactors the `dnsping` experiment to use the [step-by-step measurement style](https://github.com/ooni/probe-cli/blob/master/docs/design/dd-003-step-by-step.md). Co-authored-by: decfox <decfox@github.com> Co-authored-by: Simone Basso <bassosimone@gmail.com>
This commit is contained in:
parent
8aad36a257
commit
5501b2201a
16 changed files with 747 additions and 77 deletions
35
internal/engine/experiment/dnsping/testkeys.go
Normal file
35
internal/engine/experiment/dnsping/testkeys.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package dnsping
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
// TestKeys contains the experiment results.
|
||||
type TestKeys struct {
|
||||
Pings []*SinglePing `json:"pings"`
|
||||
|
||||
// mu provides mutual exclusion
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
// SinglePing contains the results of a single ping.
|
||||
type SinglePing struct {
|
||||
Query *model.ArchivalDNSLookupResult `json:"query"`
|
||||
}
|
||||
|
||||
// NewTestKeys creates new dnsping TestKeys
|
||||
func NewTestKeys() *TestKeys {
|
||||
return &TestKeys{
|
||||
Pings: []*SinglePing{},
|
||||
mu: sync.Mutex{},
|
||||
}
|
||||
}
|
||||
|
||||
// addSinglePing adds []*SinglePing to the test keys
|
||||
func (tk *TestKeys) addPings(pings []*SinglePing) {
|
||||
tk.mu.Lock()
|
||||
tk.Pings = append(tk.Pings, pings...)
|
||||
tk.mu.Unlock()
|
||||
}
|
||||
Loading…
Reference in a new issue