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:
parent
c1b06a2d09
commit
ce052b665e
26 changed files with 859 additions and 75 deletions
|
|
@ -6,6 +6,7 @@ package netxlite
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
|
|
@ -111,4 +112,22 @@ func (d *DNSDecoderMiekg) DecodeLookupHost(qtype uint16, data []byte, queryID ui
|
|||
return addrs, nil
|
||||
}
|
||||
|
||||
func (d *DNSDecoderMiekg) DecodeNS(data []byte, queryID uint16) ([]*net.NS, error) {
|
||||
reply, err := d.parseReply(data, queryID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := []*net.NS{}
|
||||
for _, answer := range reply.Answer {
|
||||
switch avalue := answer.(type) {
|
||||
case *dns.NS:
|
||||
out = append(out, &net.NS{Host: avalue.Ns})
|
||||
}
|
||||
}
|
||||
if len(out) < 1 {
|
||||
return nil, ErrOODNSNoAnswer
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
var _ model.DNSDecoder = &DNSDecoderMiekg{}
|
||||
|
|
|
|||
Loading…
Reference in a new issue