feat: refactor dns implementation in measurexlite (#857)
* refactor: remove query-based mapping and introducing resolver wrapper * refactor dnsping to adapt to measurexlite * dnsping: extra comments * Apply suggestions from code review * Update internal/measurexlite/dns_test.go See https://github.com/ooni/probe/issues/2208 Co-authored-by: decfox <decfox@github.com> Co-authored-by: Simone Basso <bassosimone@gmail.com>
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
"github.com/ooni/probe-cli/v3/internal/measurexlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
@@ -148,18 +147,16 @@ 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)
|
||||
// Add the dns.TypeA ping
|
||||
pings = append(pings, m.makePingFromLookup(<-trace.DNSLookup[dns.TypeA]))
|
||||
// Add the dns.TypeAAAA ping
|
||||
pings = append(pings, m.makePingFromLookup(<-trace.DNSLookup[dns.TypeAAAA]))
|
||||
tk.addPings(pings)
|
||||
}
|
||||
|
||||
// makePingfromLookup returns a SinglePing from the result of a single query
|
||||
func (m *Measurer) makePingFromLookup(lookup *model.ArchivalDNSLookupResult) (pings *SinglePing) {
|
||||
return &SinglePing{
|
||||
Query: lookup,
|
||||
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,
|
||||
})
|
||||
}
|
||||
}
|
||||
tk.addPings(pings)
|
||||
}
|
||||
|
||||
// NewExperimentMeasurer creates a new ExperimentMeasurer.
|
||||
|
||||
Reference in New Issue
Block a user