Documentation
¶
Index ¶
- type DoTServer
- type Handler
- type MainHandler
- func (h *MainHandler) EnableCookies()
- func (h *MainHandler) EnableCookiesWithSecret(secret []byte)
- func (h *MainHandler) Handle(query []byte, clientAddr net.Addr) ([]byte, error)
- func (h *MainHandler) SetBlocklist(bl interface{ ... })
- func (h *MainHandler) SetECS(enabled bool, maxPrefix int)
- func (h *MainHandler) SetNoCacheClients(cidrs []string)
- func (h *MainHandler) SetPrivateFilter(enabled bool)
- type TCPOption
- type TCPServer
- type UDPServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DoTServer ¶
type DoTServer struct {
// contains filtered or unexported fields
}
DoTServer handles DNS queries over TLS (RFC 7858).
func NewDoTServer ¶
func NewDoTServer(addr string, handler Handler, certFile, keyFile string, timeout time.Duration, maxConns int, logger *slog.Logger) (*DoTServer, error)
NewDoTServer creates a new DNS-over-TLS server. It loads the TLS certificate/key pair and wraps a TCP listener with TLS.
func NewDoTServerWithListener ¶
func NewDoTServerWithListener(ln net.Listener, handler Handler, timeout time.Duration, maxConns int, logger *slog.Logger) *DoTServer
NewDoTServerWithListener creates a DoT server using an existing TLS listener. This is primarily useful for testing.
type MainHandler ¶
type MainHandler struct {
// OnQuery is an optional callback invoked after each query is resolved.
// Parameters: client IP, qname, qtype, rcode (may be "BLOCKED"), whether served from cache, duration in ms.
OnQuery func(client, qname, qtype, rcode string, cached bool, durationMs float64)
// contains filtered or unexported fields
}
MainHandler ties together parsing, resolution, and response assembly.
func NewMainHandler ¶
func NewMainHandler( res *resolver.Resolver, c *cache.Cache, rl *security.RateLimiter, rrl *security.RRL, acl *security.ACL, m *metrics.Metrics, logger *slog.Logger, ) *MainHandler
NewMainHandler creates a new MainHandler.
func (*MainHandler) EnableCookies ¶
func (h *MainHandler) EnableCookies()
EnableCookies enables DNS cookie support (RFC 7873). A random 16-byte server secret is generated at startup.
func (*MainHandler) EnableCookiesWithSecret ¶
func (h *MainHandler) EnableCookiesWithSecret(secret []byte)
EnableCookiesWithSecret enables DNS cookies with a specific secret (for testing).
func (*MainHandler) SetBlocklist ¶
func (h *MainHandler) SetBlocklist(bl interface { IsBlocked(string) bool BlockingMode() string CustomIP() string })
SetBlocklist configures an optional blocklist for the handler.
func (*MainHandler) SetECS ¶
func (h *MainHandler) SetECS(enabled bool, maxPrefix int)
SetECS enables or disables ECS forwarding.
func (*MainHandler) SetNoCacheClients ¶
func (h *MainHandler) SetNoCacheClients(cidrs []string)
SetNoCacheClients configures the list of client IPs/CIDRs that should bypass the cache.
func (*MainHandler) SetPrivateFilter ¶
func (h *MainHandler) SetPrivateFilter(enabled bool)
SetPrivateFilter enables or disables private address filtering.
type TCPOption ¶
type TCPOption func(*TCPServer)
TCPOption configures optional TCPServer parameters.
func WithIdleTimeout ¶
WithIdleTimeout sets the idle timeout between pipelined queries.
func WithPipelineMax ¶
WithPipelineMax sets the maximum number of queries per TCP connection.
type TCPServer ¶
type TCPServer struct {
// contains filtered or unexported fields
}
TCPServer handles DNS queries over TCP.