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
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 (
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)