2021-09-09 21:24:27 +02:00
|
|
|
package mocks
|
|
|
|
|
2021-09-28 12:42:01 +02:00
|
|
|
import "github.com/ooni/probe-cli/v3/internal/netxlite/dnsx"
|
2021-09-27 23:09:41 +02:00
|
|
|
|
|
|
|
// HTTPSSvc is the result of HTTPS queries.
|
2021-09-28 12:42:01 +02:00
|
|
|
type HTTPSSvc = dnsx.HTTPSSvc
|
2021-09-27 23:09:41 +02:00
|
|
|
|
2021-09-28 10:47:59 +02:00
|
|
|
// DNSDecoder allows mocking dnsx.DNSDecoder.
|
|
|
|
type DNSDecoder struct {
|
2021-09-27 23:09:41 +02:00
|
|
|
MockDecodeLookupHost func(qtype uint16, reply []byte) ([]string, error)
|
|
|
|
|
|
|
|
MockDecodeHTTPS func(reply []byte) (*HTTPSSvc, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// DecodeLookupHost calls MockDecodeLookupHost.
|
2021-09-28 10:47:59 +02:00
|
|
|
func (e *DNSDecoder) DecodeLookupHost(qtype uint16, reply []byte) ([]string, error) {
|
2021-09-27 23:09:41 +02:00
|
|
|
return e.MockDecodeLookupHost(qtype, reply)
|
2021-09-09 21:24:27 +02:00
|
|
|
}
|
|
|
|
|
2021-09-27 23:09:41 +02:00
|
|
|
// DecodeHTTPS calls MockDecodeHTTPS.
|
2021-09-28 10:47:59 +02:00
|
|
|
func (e *DNSDecoder) DecodeHTTPS(reply []byte) (*HTTPSSvc, error) {
|
2021-09-27 23:09:41 +02:00
|
|
|
return e.MockDecodeHTTPS(reply)
|
2021-09-09 21:24:27 +02:00
|
|
|
}
|