feat(webconnectivity@v0.5): record late DNS replies (#883)

Part of https://github.com/ooni/probe/issues/2237
This commit is contained in:
Simone Basso 2022-08-26 18:32:36 +02:00 committed by GitHub
parent 1a1d3126ae
commit c3964e43b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 1 deletions

View File

@ -249,6 +249,21 @@ func (t *DNSResolvers) lookupHostUDP(parentCtx context.Context, udpAddress strin
ol.Stop(err)
out <- addrs
// wait for late DNS replies
t.WaitGroup.Add(1)
go t.waitForLateReplies(parentCtx, trace)
}
// Waits for late DNS replies.
func (t *DNSResolvers) waitForLateReplies(parentCtx context.Context, trace *measurexlite.Trace) {
defer t.WaitGroup.Done()
const lateTimeout = 500 * time.Millisecond
events := trace.DelayedDNSResponseWithTimeout(parentCtx, lateTimeout)
if length := len(events); length > 0 {
t.Logger.Warnf("got %d late DNS replies", length)
}
t.TestKeys.AppendDNSLateReplies(events...)
}
// Divides queries generated by Do53 in Do53-proper queries and other queries.

View File

@ -36,7 +36,7 @@ func (m *Measurer) ExperimentName() string {
// ExperimentVersion implements model.ExperimentMeasurer.
func (m *Measurer) ExperimentVersion() string {
return "0.5.0"
return "0.5.1"
}
// Run implements model.ExperimentMeasurer.

View File

@ -30,6 +30,10 @@ type TestKeys struct {
// Do53 contains ancillary observations collected by Do53 resolvers.
Do53 *TestKeysDo53 `json:"x_do53"`
// DNSLateReplies contains late replies we didn't expect to receive from
// a resolver (which may raise eyebrows if they're different).
DNSLateReplies []*model.ArchivalDNSLookupResult `json:"x_dns_late_replies"`
// Queries contains DNS queries.
Queries []*model.ArchivalDNSLookupResult `json:"queries"`
@ -161,6 +165,13 @@ func (tk *TestKeys) AppendNetworkEvents(v ...*model.ArchivalNetworkEvent) {
tk.mu.Unlock()
}
// AppendDNSLateReplies appends to DNSLateReplies.
func (tk *TestKeys) AppendDNSLateReplies(v ...*model.ArchivalDNSLookupResult) {
tk.mu.Lock()
tk.DNSLateReplies = append(tk.DNSLateReplies, v...)
tk.mu.Unlock()
}
// AppendQueries appends to Queries.
func (tk *TestKeys) AppendQueries(v ...*model.ArchivalDNSLookupResult) {
tk.mu.Lock()