feat: dnsping using step-by-step (#831)
Reference issue for this pull request: https://github.com/ooni/probe/issues/2159 This diff refactors the `dnsping` experiment to use the [step-by-step measurement style](https://github.com/ooni/probe-cli/blob/master/docs/design/dd-003-step-by-step.md). Co-authored-by: decfox <decfox@github.com> Co-authored-by: Simone Basso <bassosimone@gmail.com>
This commit is contained in:
parent
8aad36a257
commit
5501b2201a
16 changed files with 747 additions and 77 deletions
|
|
@ -98,9 +98,13 @@ type parallelResolverResult struct {
|
|||
func (r *ParallelResolver) lookupHost(ctx context.Context, hostname string,
|
||||
qtype uint16, out chan<- *parallelResolverResult) {
|
||||
encoder := &DNSEncoderMiekg{}
|
||||
trace := ContextTraceOrDefault(ctx)
|
||||
query := encoder.Encode(hostname, qtype, r.Txp.RequiresPadding())
|
||||
started := trace.TimeNow()
|
||||
response, err := r.Txp.RoundTrip(ctx, query)
|
||||
finished := trace.TimeNow()
|
||||
if err != nil {
|
||||
trace.OnDNSRoundTripForLookupHost(started, r, query, response, []string{}, err, finished)
|
||||
out <- ¶llelResolverResult{
|
||||
addrs: []string{},
|
||||
err: err,
|
||||
|
|
@ -108,6 +112,7 @@ func (r *ParallelResolver) lookupHost(ctx context.Context, hostname string,
|
|||
return
|
||||
}
|
||||
addrs, err := response.DecodeLookupHost()
|
||||
trace.OnDNSRoundTripForLookupHost(started, r, query, response, addrs, err, finished)
|
||||
out <- ¶llelResolverResult{
|
||||
addrs: addrs,
|
||||
err: err,
|
||||
|
|
|
|||
Loading…
Reference in a new issue