Documentation
¶
Overview ¶
Package dnstest runs fake DNS servers on loopback for tests: plain DNS over UDP and TCP, DNS over TLS, DNS over HTTPS, DNS over QUIC, and a server that never answers. Each counts the queries it sees.
Index ¶
- func Answer(query []byte, truncated bool) ([]byte, bool)
- func CloseQuietly(c io.Closer)
- func SelfSignedCert(t *testing.T, name string) (tls.Certificate, *x509.CertPool)
- func StartDoH(t *testing.T) (hostPort string, roots *x509.CertPool, queries *atomic.Int32)
- func StartSilent(t *testing.T) (hostPort string, queries *atomic.Int32)
- type DNS
- type DoQ
- type DoT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Answer ¶
Answer builds a response to query. A truncated response carries no answers. A full response to an A query carries one A record.
func CloseQuietly ¶
CloseQuietly closes c in a test helper, where a close error changes nothing.
func SelfSignedCert ¶
SelfSignedCert returns a certificate for name and a pool that trusts it.
Types ¶
type DNS ¶
DNS answers A queries with 192.0.2.1 over TCP. Over UDP it only sets the truncation bit, so a lookup succeeds only if it retries over TCP.
type DoQ ¶
type DoQ struct {
HostPort string
Conns atomic.Int32
Queries atomic.Int32
NonzeroIDs atomic.Int32 // RFC 9250 requires message ID 0
Unfinished atomic.Int32 // streams whose query had no FIN after it
}
DoQ counts what a DNS over QUIC server sees.