fix(netxlite): reject replies with wrong queryID (#732)
This diff has been extracted from c2f7ccab0e
See https://github.com/ooni/probe/issues/2096
While there, export DecodeReply to decode a raw reply without
interpreting the Rcode or parsing the results, which seems a
nice extra feature to have to more flexibly parse DNS replies
in other parts of the codebase.
This commit is contained in:
parent
f5b801ae95
commit
9d2301cae2
18 changed files with 261 additions and 128 deletions
|
|
@ -85,7 +85,7 @@ func (r *ParallelResolver) LookupHost(ctx context.Context, hostname string) ([]s
|
|||
// LookupHTTPS implements Resolver.LookupHTTPS.
|
||||
func (r *ParallelResolver) LookupHTTPS(
|
||||
ctx context.Context, hostname string) (*model.HTTPSSvc, error) {
|
||||
querydata, err := r.Encoder.Encode(
|
||||
querydata, queryID, err := r.Encoder.Encode(
|
||||
hostname, dns.TypeHTTPS, r.Txp.RequiresPadding())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -94,7 +94,7 @@ func (r *ParallelResolver) LookupHTTPS(
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return r.Decoder.DecodeHTTPS(replydata)
|
||||
return r.Decoder.DecodeHTTPS(replydata, queryID)
|
||||
}
|
||||
|
||||
// parallelResolverResult is the internal representation of a
|
||||
|
|
@ -107,7 +107,7 @@ type parallelResolverResult struct {
|
|||
// lookupHost issues a lookup host query for the specified qtype (e.g., dns.A).
|
||||
func (r *ParallelResolver) lookupHost(ctx context.Context, hostname string,
|
||||
qtype uint16, out chan<- *parallelResolverResult) {
|
||||
querydata, err := r.Encoder.Encode(hostname, qtype, r.Txp.RequiresPadding())
|
||||
querydata, queryID, err := r.Encoder.Encode(hostname, qtype, r.Txp.RequiresPadding())
|
||||
if err != nil {
|
||||
out <- ¶llelResolverResult{
|
||||
addrs: []string{},
|
||||
|
|
@ -123,7 +123,7 @@ func (r *ParallelResolver) lookupHost(ctx context.Context, hostname string,
|
|||
}
|
||||
return
|
||||
}
|
||||
addrs, err := r.Decoder.DecodeLookupHost(qtype, replydata)
|
||||
addrs, err := r.Decoder.DecodeLookupHost(qtype, replydata, queryID)
|
||||
out <- ¶llelResolverResult{
|
||||
addrs: addrs,
|
||||
err: err,
|
||||
|
|
|
|||
Loading…
Reference in a new issue