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:
DecFox 2022-08-25 17:29:24 +05:30 committed by GitHub
parent 6ef3febf69
commit 0ef1f24617
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 6 deletions

View File

@ -19,7 +19,7 @@ import (
const ( const (
testName = "dnsping" testName = "dnsping"
testVersion = "0.2.0" testVersion = "0.3.0"
) )
// Config contains the experiment configuration. // 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) resolver := trace.NewParallelUDPResolver(logger, dialer, address)
_, err := resolver.LookupHost(ctx, domain) _, err := resolver.LookupHost(ctx, domain)
ol.Stop(err) ol.Stop(err)
delayedResp := trace.DelayedDNSResponseWithTimeout(ctx, 250*time.Millisecond)
for _, lookup := range trace.DNSLookupsFromRoundTrip() { for _, lookup := range trace.DNSLookupsFromRoundTrip() {
// make sure we only include the query types we care about (in principle, there // 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). // should be no other query, so we're doing this just for robustness).
if lookup.QueryType == "A" || lookup.QueryType == "AAAA" { if lookup.QueryType == "A" || lookup.QueryType == "AAAA" {
pings = append(pings, &SinglePing{ sp := &SinglePing{
Query: lookup, 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) tk.addPings(pings)

View File

@ -50,7 +50,7 @@ func TestMeasurer_run(t *testing.T) {
if m.ExperimentName() != "dnsping" { if m.ExperimentName() != "dnsping" {
t.Fatal("invalid experiment name") t.Fatal("invalid experiment name")
} }
if m.ExperimentVersion() != "0.2.0" { if m.ExperimentVersion() != "0.3.0" {
t.Fatal("invalid experiment version") t.Fatal("invalid experiment version")
} }
ctx := context.Background() ctx := context.Background()

View File

@ -16,7 +16,8 @@ type TestKeys struct {
// SinglePing contains the results of a single ping. // SinglePing contains the results of a single ping.
type SinglePing struct { type SinglePing struct {
Query *model.ArchivalDNSLookupResult `json:"query"` Query *model.ArchivalDNSLookupResult `json:"query"`
DelayedResponses []*model.ArchivalDNSLookupResult `json:"delayed_responses"`
} }
// NewTestKeys creates new dnsping TestKeys // NewTestKeys creates new dnsping TestKeys