Documentation
¶
Overview ¶
Package dnsproxytest provides utilities for testing dnsproxy module.
Index ¶
Constants ¶
const ( // Timeout is the common timeout for tests and contexts. Timeout = 1 * time.Second // CacheSize is the default size of the cache in bytes. CacheSize = 64 * 1024 // MessageCount is the default number of messages used in tests requiring // multiple DNS requests. MessageCount = 10 // TLSServerName is a common TLS server name value for tests. TLSServerName = "testdns.adguard.com" // Host is a common host for tests. Host = "test.example" // TTL is a common time-to-live value in seconds for tests. TTL = 300 )
Variables ¶
var ( // LocalhostAnyPort is a [netip.AddrPort] having a value of 127.0.0.1:0. LocalhostAnyPort = netip.AddrPortFrom(netutil.IPv4Localhost(), 0) // IPv4 is a common IPv4 address for tests. IPv4 = net.IPv4(192, 0, 2, 1) )
var DefaultTrustedProxies = netutil.SliceSubnetSet{ netip.MustParsePrefix("0.0.0.0/0"), netip.MustParsePrefix("::/0"), }
DefaultTrustedProxies is a set of trusted proxies that includes all possible IP addresses.
Functions ¶
func NewTLSConfig ¶ added in v0.85.0
NewTLSConfig is a test helper that generates new TLS config.
func NewTestRequest ¶ added in v0.85.0
NewTestRequest returns common DNS request for tests. This helper must not be used in IPv6-related tests.
func NewTestRequestWithHost ¶ added in v0.85.0
NewTestRequestWithHost returns DNS request with common values and given host. This helper must not be used in IPv6-related tests.
func NewTestResponse ¶ added in v0.85.0
NewTestResponse is a helper that returns new default response for given request. Response will contain single A record with IPv4 value. req must not be nil. This helper must not be used in IPv6-related tests.
func RequireResponse ¶ added in v0.85.0
RequireResponse is a test helper that ensures that the DNS reply matches the request and contains an A record with IPv4. It is intended to be used alongside NewTestRequest or NewTestRequestWithHost. This helper must not be used in IPv6-related tests.
Types ¶
This section is empty.