feat: record delayed DNS responses in dnsping (#878)
See https://github.com/ooni/probe/issues/2231 Co-authored-by: decfox <decfox@github.com> Co-authored-by: Simone Basso <bassosimone@gmail.com>
This commit is contained in:
parent
6ef3febf69
commit
0ef1f24617
|
@ -19,7 +19,7 @@ import (
|
|||
|
||||
const (
|
||||
testName = "dnsping"
|
||||
testVersion = "0.2.0"
|
||||
testVersion = "0.3.0"
|
||||
)
|
||||
|
||||
// Config contains the experiment configuration.
|
||||
|
@ -147,13 +147,22 @@ func (m *Measurer) dnsRoundTrip(ctx context.Context, index int64, zeroTime time.
|
|||
resolver := trace.NewParallelUDPResolver(logger, dialer, address)
|
||||
_, err := resolver.LookupHost(ctx, domain)
|
||||
ol.Stop(err)
|
||||
delayedResp := trace.DelayedDNSResponseWithTimeout(ctx, 250*time.Millisecond)
|
||||
for _, lookup := range trace.DNSLookupsFromRoundTrip() {
|
||||
// make sure we only include the query types we care about (in principle, there
|
||||
// should be no other query, so we're doing this just for robustness).
|
||||
if lookup.QueryType == "A" || lookup.QueryType == "AAAA" {
|
||||
pings = append(pings, &SinglePing{
|
||||
Query: lookup,
|
||||
})
|
||||
sp := &SinglePing{
|
||||
Query: lookup,
|
||||
DelayedResponses: []*model.ArchivalDNSLookupResult{},
|
||||
}
|
||||
// record the delayed responses of the corresponding query
|
||||
for _, resp := range delayedResp {
|
||||
if resp.QueryType == lookup.QueryType {
|
||||
sp.DelayedResponses = append(sp.DelayedResponses, resp)
|
||||
}
|
||||
}
|
||||
pings = append(pings, sp)
|
||||
}
|
||||
}
|
||||
tk.addPings(pings)
|
||||
|
|
|
@ -50,7 +50,7 @@ func TestMeasurer_run(t *testing.T) {
|
|||
if m.ExperimentName() != "dnsping" {
|
||||
t.Fatal("invalid experiment name")
|
||||
}
|
||||
if m.ExperimentVersion() != "0.2.0" {
|
||||
if m.ExperimentVersion() != "0.3.0" {
|
||||
t.Fatal("invalid experiment version")
|
||||
}
|
||||
ctx := context.Background()
|
||||
|
|
|
@ -16,7 +16,8 @@ type TestKeys struct {
|
|||
|
||||
// SinglePing contains the results of a single ping.
|
||||
type SinglePing struct {
|
||||
Query *model.ArchivalDNSLookupResult `json:"query"`
|
||||
Query *model.ArchivalDNSLookupResult `json:"query"`
|
||||
DelayedResponses []*model.ArchivalDNSLookupResult `json:"delayed_responses"`
|
||||
}
|
||||
|
||||
// NewTestKeys creates new dnsping TestKeys
|
||||
|
|
Loading…
Reference in New Issue
Block a user