feat(netxlite): implements NS queries (#734)

This diff has been extracted from eb0bf38957.

See https://github.com/ooni/probe/issues/2096.

While there, skip the broken tests caused by issue
https://github.com/ooni/probe/issues/2098.
This commit is contained in:
Simone Basso 2022-05-16 10:46:53 +02:00 committed by GitHub
commit ce052b665e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 859 additions and 75 deletions

View file

@ -6,6 +6,7 @@ package netxlite
import (
"context"
"net"
"github.com/miekg/dns"
"github.com/ooni/probe-cli/v3/internal/atomicx"
@ -129,3 +130,18 @@ func (r *ParallelResolver) lookupHost(ctx context.Context, hostname string,
err: err,
}
}
// LookupNS implements Resolver.LookupNS.
func (r *ParallelResolver) LookupNS(
ctx context.Context, hostname string) ([]*net.NS, error) {
querydata, queryID, err := r.Encoder.Encode(
hostname, dns.TypeNS, r.Txp.RequiresPadding())
if err != nil {
return nil, err
}
replydata, err := r.Txp.RoundTrip(ctx, querydata)
if err != nil {
return nil, err
}
return r.Decoder.DecodeNS(replydata, queryID)
}