-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(netxlite): reject replies with wrong queryID (#732)
This diff has been extracted from bassosimone/ooni-2022-04-websteps-illustrated@c2f7cca See ooni/probe#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.
- Loading branch information
1 parent
f5b801a
commit 9d2301c
Showing
18 changed files
with
261 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
package mocks | ||
|
||
import "github.com/ooni/probe-cli/v3/internal/model" | ||
import ( | ||
"github.com/miekg/dns" | ||
"github.com/ooni/probe-cli/v3/internal/model" | ||
) | ||
|
||
// DNSDecoder allows mocking dnsx.DNSDecoder. | ||
type DNSDecoder struct { | ||
MockDecodeLookupHost func(qtype uint16, reply []byte) ([]string, error) | ||
MockDecodeLookupHost func(qtype uint16, reply []byte, queryID uint16) ([]string, error) | ||
|
||
MockDecodeHTTPS func(reply []byte) (*model.HTTPSSvc, error) | ||
MockDecodeHTTPS func(reply []byte, queryID uint16) (*model.HTTPSSvc, error) | ||
|
||
MockDecodeReply func(reply []byte) (*dns.Msg, error) | ||
} | ||
|
||
// DecodeLookupHost calls MockDecodeLookupHost. | ||
func (e *DNSDecoder) DecodeLookupHost(qtype uint16, reply []byte) ([]string, error) { | ||
return e.MockDecodeLookupHost(qtype, reply) | ||
func (e *DNSDecoder) DecodeLookupHost(qtype uint16, reply []byte, queryID uint16) ([]string, error) { | ||
return e.MockDecodeLookupHost(qtype, reply, queryID) | ||
} | ||
|
||
// DecodeHTTPS calls MockDecodeHTTPS. | ||
func (e *DNSDecoder) DecodeHTTPS(reply []byte) (*model.HTTPSSvc, error) { | ||
return e.MockDecodeHTTPS(reply) | ||
func (e *DNSDecoder) DecodeHTTPS(reply []byte, queryID uint16) (*model.HTTPSSvc, error) { | ||
return e.MockDecodeHTTPS(reply, queryID) | ||
} | ||
|
||
// DecodeReply calls MockDecodeReply. | ||
func (e *DNSDecoder) DecodeReply(reply []byte) (*dns.Msg, error) { | ||
return e.MockDecodeReply(reply) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.