Documentation
¶
Overview ¶
Package dnsserver implements CoreDNS as a Caddy server type.
By default, importing this package registers the "dns" server type with Caddy. Programs embedding CoreDNS can import only the plugins they need, call SetDirectives before starting a server, and pass an in-memory Corefile to caddy.Start. They should not import coremain or the generated all-plugin bundle: coremain provides command-line behavior such as flag registration, signal handling, and blocking until shutdown, and registers the server type. Before stopping an embedded instance, run its shutdown callbacks so that plugins can release resources.
A host can register a custom directive with plugin.Register before starting Caddy; it does not need to rebuild CoreDNS or modify plugin.cfg. Include the directive in the list passed to SetDirectives at the desired execution position, and use GetConfig and Config.AddPlugin in its setup function to add the handler. The setup function can register startup and shutdown callbacks on the Caddy controller. Directives determines execution order, not the order in the Corefile. Each directive must be registered only once per process.
SetDirectives copies the supplied list and rejects empty or duplicate names. Direct assignment to Directives remains supported for existing callers. Neither entry point imports plugins or registers them on the host's behalf.
Directives and Caddy's plugin registry are process-wide. Configure them before starting any servers and do not mutate them while servers are running. Automatic server-type registration is retained for existing embedding users; it does not start listeners or prevent the host from selecting directives.
To control when the DNS server type is registered, build the host with -tags=coredns_manual_registration. This excludes this package's registration init function. After selecting directives and registering host plugins, call Register before caddy.Start. Register is idempotent and also works in default builds. It returns an error if another caller already registered a DNS server type, leaving that registration unchanged.
The build tag does not disable initialization in Caddy or individual plugins, or make their registries instance-local. Selected plugins must not import coremain, directly or transitively, to avoid its command-line initialization and server-type registration. The CoreDNS command-line program explicitly registers the server type in both build modes.
Example (Embedding) ¶
package main
import (
"errors"
"fmt"
"github.com/coredns/caddy"
"github.com/coredns/coredns/core/dnsserver"
_ "github.com/coredns/coredns/plugin/bind"
_ "github.com/coredns/coredns/plugin/whoami"
"github.com/miekg/dns"
)
func main() {
oldDirectives := dnsserver.Directives
oldCaddyQuiet := caddy.Quiet
oldDNSQuiet := dnsserver.Quiet
defer func() {
dnsserver.Directives = oldDirectives
caddy.Quiet = oldCaddyQuiet
dnsserver.Quiet = oldDNSQuiet
}()
// Import only the plugins the host needs and set their execution order
// before starting the first server.
dnsserver.Directives = []string{"bind", "whoami"}
if err := dnsserver.Register(); err != nil {
panic(err)
}
caddy.Quiet = true
dnsserver.Quiet = true
instance, err := caddy.Start(caddy.CaddyfileInput{
Filepath: "Corefile",
Contents: []byte(".:0 {\nbind 127.0.0.1\nwhoami\n}\n"),
ServerTypeName: "dns",
})
if err != nil {
panic(err)
}
defer func() {
shutdownErr := errors.Join(instance.ShutdownCallbacks()...)
stopErr := instance.Stop()
instance.Wait()
if err := errors.Join(shutdownErr, stopErr); err != nil {
panic(err)
}
}()
server := instance.Servers()[0].LocalAddr().String()
query := new(dns.Msg)
query.SetQuestion("example.org.", dns.TypeA)
response, err := dns.Exchange(query, server)
if err != nil {
panic(err)
}
fmt.Println(response.Authoritative, response.Rcode == dns.RcodeSuccess)
}
Output: true true
Index ¶
- Constants
- Variables
- func AddPluginToAllServerBlocks(c *caddy.Controller, m plugin.Plugin)
- func AddPrefix(b []byte) (m []byte)
- func Register() error
- func SetDirectives(directives []string) error
- func SplitProtocolHostPort(address string) (protocol string, ip string, port string, err error)
- type Config
- type DoHWriter
- func (d *DoHWriter) Close() error
- func (d *DoHWriter) Hijack()
- func (d *DoHWriter) LocalAddr() net.Addr
- func (d *DoHWriter) Network() string
- func (d *DoHWriter) RemoteAddr() net.Addr
- func (d *DoHWriter) Request() *http.Request
- func (d *DoHWriter) TsigStatus() error
- func (d *DoHWriter) TsigTimersOnly(_ bool)
- func (d *DoHWriter) Write(b []byte) (int, error)
- func (d *DoHWriter) WriteMsg(m *dns.Msg) error
- type DoQWriter
- func (w *DoQWriter) Close() error
- func (w *DoQWriter) ConnectionState() *tls.ConnectionState
- func (w *DoQWriter) Hijack()
- func (w *DoQWriter) LocalAddr() net.Addr
- func (w *DoQWriter) Network() string
- func (w *DoQWriter) RemoteAddr() net.Addr
- func (w *DoQWriter) TsigStatus() error
- func (w *DoQWriter) TsigTimersOnly(_b bool)
- func (w *DoQWriter) Write(b []byte) (int, error)
- func (w *DoQWriter) WriteMsg(m *dns.Msg) error
- type FilterFunc
- type HTTPRequestKey
- type Key
- type LoopKey
- type MetadataCollector
- type Server
- func (s *Server) Address() string
- func (s *Server) Listen() (net.Listener, error)
- func (s *Server) ListenPacket() (net.PacketConn, error)
- func (s *Server) OnStartupComplete()
- func (s *Server) Serve(l net.Listener) error
- func (s *Server) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
- func (s *Server) ServePacket(p net.PacketConn) error
- func (s *Server) Stop() error
- func (s *Server) Tracer() ot.Tracer
- func (s *Server) WrapListener(ln net.Listener) net.Listener
- type ServerHTTPS
- func (s *ServerHTTPS) Listen() (net.Listener, error)
- func (s *ServerHTTPS) ListenPacket() (net.PacketConn, error)
- func (s *ServerHTTPS) OnStartupComplete()
- func (s *ServerHTTPS) Serve(l net.Listener) error
- func (s *ServerHTTPS) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *ServerHTTPS) ServePacket(_p net.PacketConn) error
- func (s *ServerHTTPS) Shutdown() error
- func (s *ServerHTTPS) Stop() error
- type ServerHTTPS3
- func (s *ServerHTTPS3) Listen() (net.Listener, error)
- func (s *ServerHTTPS3) ListenPacket() (net.PacketConn, error)
- func (s *ServerHTTPS3) OnStartupComplete()
- func (s *ServerHTTPS3) Serve(_l net.Listener) error
- func (s *ServerHTTPS3) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *ServerHTTPS3) ServePacket(pc net.PacketConn) error
- func (s *ServerHTTPS3) Shutdown() error
- func (s *ServerHTTPS3) Stop() error
- type ServerQUIC
- func (s *ServerQUIC) Listen() (net.Listener, error)
- func (s *ServerQUIC) ListenPacket() (net.PacketConn, error)
- func (s *ServerQUIC) OnStartupComplete()
- func (s *ServerQUIC) Serve(_l net.Listener) error
- func (s *ServerQUIC) ServePacket(p net.PacketConn) error
- func (s *ServerQUIC) ServeQUIC() error
- func (s *ServerQUIC) Stop() error
- type ServerTLS
- type ServergRPC
- func (s *ServergRPC) Listen() (net.Listener, error)
- func (s *ServergRPC) ListenPacket() (net.PacketConn, error)
- func (s *ServergRPC) OnStartupComplete()
- func (s *ServergRPC) Query(ctx context.Context, in *pb.DnsPacket) (*pb.DnsPacket, error)
- func (s *ServergRPC) Serve(l net.Listener) error
- func (s *ServergRPC) ServePacket(_p net.PacketConn) error
- func (s *ServergRPC) Shutdown() error
- func (s *ServergRPC) Stop() (err error)
- type TLSConfigIdentity
- type ViewKey
- type Viewer
Examples ¶
Constants ¶
const ( // DefaultGRPCMaxStreams is the default maximum number of concurrent streams per connection. DefaultGRPCMaxStreams = 256 // DefaultGRPCMaxConnections is the default maximum number of concurrent connections. DefaultGRPCMaxConnections = 200 )
const ( // DefaultHTTPSMaxConnections is the default maximum number of concurrent connections. DefaultHTTPSMaxConnections = 200 // DefaultHTTPSMaxStreams is the default maximum number of concurrent HTTP/2 streams // per connection, used when max_streams is not specified. DefaultHTTPSMaxStreams = 250 )
const ( // DefaultHTTPS3MaxStreams is the default maximum number of concurrent QUIC streams per connection. DefaultHTTPS3MaxStreams = 256 // DefaultHTTPS3MaxHeaderBytes limits HTTP/3 header memory before requests reach the DoH handler. DefaultHTTPS3MaxHeaderBytes = 16 << 10 // 16 KiB )
const ( // DoQCodeNoError is used when the connection or stream needs to be // closed, but there is no error to signal. DoQCodeNoError quic.ApplicationErrorCode = 0 // DoQCodeInternalError signals that the DoQ implementation encountered // an internal error and is incapable of pursuing the transaction or the // connection. DoQCodeInternalError quic.ApplicationErrorCode = 1 // DoQCodeProtocolError signals that the DoQ implementation encountered // a protocol error and is forcibly aborting the connection. DoQCodeProtocolError quic.ApplicationErrorCode = 2 // DefaultMaxQUICStreams is the default maximum number of concurrent QUIC streams // on a per-connection basis. RFC 9250 (DNS-over-QUIC) does not require a high // concurrent-stream limit; normal stub or recursive resolvers open only a handful // of streams in parallel. This default (256) is a safe upper bound. DefaultMaxQUICStreams = 256 // DefaultQUICStreamWorkers is the default number of workers for processing QUIC streams. DefaultQUICStreamWorkers = 1024 // DefaultQUICMaxConnections is the default maximum number of concurrent connections. DefaultQUICMaxConnections = 200 )
const DefaultPort = transport.Port
DefaultPort is the default port.
Variables ¶
var ( // Port is the port we listen on by default. Port = DefaultPort // GracefulTimeout is the maximum duration of a graceful shutdown. GracefulTimeout time.Duration )
These "soft defaults" are configurable by command line flags, etc.
var Directives = []string{
"root",
"metadata",
"geoip",
"cancel",
"proxyproto",
"quic",
"grpc_server",
"https",
"https3",
"timeouts",
"multisocket",
"reload",
"nsid",
"bufsize",
"bind",
"debug",
"trace",
"ready",
"health",
"pprof",
"shed",
"prometheus",
"errors",
"log",
"dnstap",
"local",
"dns64",
"siit",
"any",
"chaos",
"loadbalance",
"tsig",
"rewrite",
"autopath",
"acl",
"cache",
"header",
"dnssec",
"tls",
"minimal",
"template",
"transfer",
"dynupdate",
"hosts",
"route53",
"azure",
"clouddns",
"k8s_external",
"kubernetes",
"file",
"auto",
"secondary",
"etcd",
"loop",
"forward",
"grpc",
"erratic",
"whoami",
"on",
"sign",
"view",
"nomad",
}
Directives are registered in the order they should be executed.
Ordering is VERY important. Every plugin will feel the effects of all other plugin below (after) them during a request, but they must not care what plugin above them are doing.
var EnableChaos = map[string]struct{}{
"chaos": {},
"forward": {},
"proxy": {},
}
EnableChaos is a map with plugin names for which we should open CH class queries as we block these by default.
var Quiet bool
Quiet mode will not show any informative output on initialization.
Functions ¶
func AddPluginToAllServerBlocks ¶ added in v1.14.7
func AddPluginToAllServerBlocks(c *caddy.Controller, m plugin.Plugin)
AddPluginToAllServerBlocks adds m once to every server block in c's instance. It is intended for directives that must handle traffic on a listener other than the one where the directive is configured.
func Register ¶ added in v1.15.0
func Register() error
Register registers the DNS server type with Caddy. Repeated calls return the result of the first call without registering again. An existing server type registered by another caller is left unchanged and causes an error.
Default builds call Register automatically. When built with the coredns_manual_registration tag, an embedding host must call Register before starting Caddy. Register neither registers plugins nor starts listeners.
Concurrent calls to Register are safe, but the first call must not run concurrently with other Caddy configuration or startup operations.
Example ¶
package main
import (
"fmt"
"github.com/coredns/coredns/core/dnsserver"
_ "github.com/coredns/coredns/plugin/bind"
_ "github.com/coredns/coredns/plugin/whoami"
)
func main() {
// Required before caddy.Start in builds with coredns_manual_registration;
// harmless when the default import-time registration has already run.
if err := dnsserver.Register(); err != nil {
panic(err)
}
fmt.Println("registered")
}
Output: registered
func SetDirectives ¶ added in v1.15.0
SetDirectives replaces Directives with a copy of directives, in execution order. Names must be nonempty and unique. On error, Directives is unchanged. An empty or nil list disables all directives.
This selects directives but does not import or register plugins. A host may register its plugins after this call, before starting Caddy. Unregistered directives used in a Corefile are rejected by Caddy during startup.
The list is process-wide, not per instance. Call SetDirectives before starting any servers, not while servers are running. The caller must serialize it with all other access to Directives, including startup and reload. It is not a runtime reconfiguration API.
Example ¶
package main
import (
"fmt"
"github.com/coredns/coredns/core/dnsserver"
_ "github.com/coredns/coredns/plugin/bind"
_ "github.com/coredns/coredns/plugin/whoami"
)
func main() {
oldDirectives := dnsserver.Directives
defer func() { dnsserver.Directives = oldDirectives }()
if err := dnsserver.SetDirectives([]string{"bind", "whoami"}); err != nil {
panic(err)
}
fmt.Println(dnsserver.Directives)
}
Output: [bind whoami]
Types ¶
type Config ¶
type Config struct {
// The zone of the site.
Zone string
// one or several hostnames to bind the server to.
// defaults to a single empty string that denote the wildcard address
ListenHosts []string
// The port to listen on.
Port string
// The number of servers that will listen on one port.
// By default, one server will be running.
NumSockets int
// Root points to a base directory we find user defined "things".
// First consumer is the file plugin to looks for zone files in this place.
Root string
// Debug controls the panic/recover mechanism that is enabled by default.
Debug bool
// Stacktrace controls including stacktrace as part of log from recover mechanism, it is disabled by default.
Stacktrace bool
// The transport we implement, normally just "dns" over TCP/UDP, but could be
// DNS-over-TLS or DNS-over-gRPC.
Transport string
// If this function is not nil it will be used to inspect and validate
// HTTP requests. Although this isn't referenced in-tree, external plugins
// may depend on it.
HTTPRequestValidateFunc func(*http.Request) bool
// If this function is not nil it is called once per Server in ServePacket
// (so each UDP listening socket gets its own decorator under multisocket)
// and its result is installed as the underlying dns.Server's
// DecorateWriter. Plain dns:// UDP listeners only. When several server
// blocks sharing a listener set it, the last one in config order wins.
// Although this isn't referenced in-tree, external plugins may depend
// on it.
UDPDecorateWriterFunc func(*Server) dns.DecorateWriter
// FilterFuncs is used to further filter access
// to this handler. E.g. to limit access to a reverse zone
// on a non-octet boundary, i.e. /17
FilterFuncs []FilterFunc
// ViewName is the name of the Viewer PLugin defined in the Config
ViewName string
// TLSConfig when listening for encrypted connections (gRPC, DNS-over-TLS).
TLSConfig *tls.Config
// MaxQUICStreams defines the maximum number of concurrent QUIC streams for a QUIC server.
// This is nil if not specified, allowing for a default to be used.
MaxQUICStreams *int
// MaxQUICConnections is the maximum number of concurrent connections.
MaxQUICConnections *int
// MaxQUICWorkerPoolSize defines the size of the worker pool for processing QUIC streams.
// This is nil if not specified, allowing for a default to be used.
MaxQUICWorkerPoolSize *int
// ProxyProtoConnPolicy is the function that will be used to
// configure the PROXY protocol settings on listeners.
// If nil, PROXY protocol is disabled.
ProxyProtoConnPolicy proxyproto.ConnPolicyFunc
// ProxyProtoUDPSessionTrackingTTL enables per-UDP-session source address
// caching on the PacketConn listener when set to a positive duration.
// The first datagram of a Cloudflare Spectrum PPv2 session (which contains
// only the PROXY Protocol header and no DNS payload) is used to populate a
// short-lived cache keyed by the Spectrum-side remote address. Subsequent
// datagrams from the same remote address that carry no PROXY Protocol header
// are associated with the cached real client address for up to this duration
// (refreshed on each matching packet). A zero or negative value disables
// session tracking. Has no effect unless ProxyProtoConnPolicy is also set.
ProxyProtoUDPSessionTrackingTTL time.Duration
// ProxyProtoUDPSessionTrackingMaxSessions is the maximum number of concurrent
// UDP sessions held in the LRU cache. Zero means use the default (udpSessionMaxEntries).
// Has no effect unless ProxyProtoUDPSessionTrackingTTL is positive.
ProxyProtoUDPSessionTrackingMaxSessions int
// ProxyProtoTLVMetadata, when true, captures the PPv2 TLV vector and exposes
// it to downstream plugins as the "proxyproto/tlv" metadata label (raw hex).
// Opt-in: off by default so existing listeners skip the extra TLV processing.
// Has no effect unless ProxyProtoConnPolicy is also set.
ProxyProtoTLVMetadata bool
// MaxGRPCStreams defines the maximum number of concurrent streams per gRPC connection.
// This is nil if not specified, allowing for a default to be used.
MaxGRPCStreams *int
// MaxGRPCConnections defines the maximum number of concurrent gRPC connections.
// This is nil if not specified, allowing for a default to be used.
MaxGRPCConnections *int
// MaxHTTPSConnections defines the maximum number of concurrent HTTPS connections.
// This is nil if not specified, allowing for a default to be used.
MaxHTTPSConnections *int
// MaxHTTPSStreams defines the maximum number of concurrent HTTP/2 streams per HTTPS connection.
// This is nil if not specified, allowing for a default to be used.
MaxHTTPSStreams *int
// MaxHTTPS3Streams defines the maximum number of concurrent QUIC streams for HTTPS3.
// This is nil if not specified, allowing for a default to be used.
MaxHTTPS3Streams *int
// MaxHTTPS3Connections defines the maximum number of concurrent HTTPS3 connections.
// This is nil if not specified, allowing for a default to be used.
MaxHTTPS3Connections *int
// Timeouts for connection-oriented servers. Exact applicability depends on transport.
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
// MaxTCPQueries defines the maximum number of queries served on a single TCP/TLS
// connection before it is closed. -1 means unlimited. This is nil if not specified,
// allowing for a default to be used.
MaxTCPQueries *int
// TSIG secrets, [name]key.
TsigSecret map[string]string
// Plugin stack.
Plugin []plugin.Plugin
// contains filtered or unexported fields
}
Config configuration for a single server.
func GetConfig ¶
func GetConfig(c *caddy.Controller) *Config
GetConfig gets the Config that corresponds to c. If none exist nil is returned.
func (*Config) AllowOpcode ¶ added in v1.15.0
AllowOpcode permits a non-default DNS opcode to reach this config's plugin chain on UDP, TCP, and DNS-over-TLS listeners. Plugins should call it during setup. The listener still requires exactly one question, and configs that do not opt in continue to reject the opcode.
func (*Config) Handler ¶
Handler returns the plugin handler that has been added to the config under its name. This is useful to inspect if a certain plugin is active in this server. Note that this is order dependent and the order is defined in directives.go, i.e. if your plugin comes before the plugin you are checking; it will not be there (yet).
func (*Config) Handlers ¶ added in v1.0.2
Handlers returns a slice of plugins that have been registered. This can be used to inspect and interact with registered plugins but cannot be used to remove or add plugins. Note that this is order dependent and the order is defined in directives.go, i.e. if your plugin comes before the plugin you are checking; it will not be there (yet).
func (*Config) SetTLSConfigIdentity ¶ added in v1.15.0
func (c *Config) SetTLSConfigIdentity(identity *TLSConfigIdentity)
SetTLSConfigIdentity associates an opaque listener-wide policy identity with this config.
type DoHWriter ¶ added in v1.1.3
type DoHWriter struct {
// Msg is a response to be written to the client.
Msg *dns.Msg
// contains filtered or unexported fields
}
DoHWriter is a dns.ResponseWriter that adds more specific LocalAddr and RemoteAddr methods.
func (*DoHWriter) Hijack ¶ added in v1.11.0
func (d *DoHWriter) Hijack()
Hijack no-op implementation.
func (*DoHWriter) RemoteAddr ¶ added in v1.1.3
RemoteAddr returns the remote address.
func (*DoHWriter) TsigStatus ¶ added in v1.11.0
TsigStatus returns the TSIG verification status for this request.
func (*DoHWriter) TsigTimersOnly ¶ added in v1.11.0
TsigTimersOnly no-op implementation.
type DoQWriter ¶ added in v1.11.0
func (*DoQWriter) Close ¶ added in v1.11.0
Close sends the STREAM FIN signal. The server MUST send the response(s) on the same stream and MUST indicate, after the last response, through the STREAM FIN mechanism that no further data will be sent on that stream. See https://www.rfc-editor.org/info/rfc9250/#section-4.2-7
func (*DoQWriter) ConnectionState ¶ added in v1.14.4
func (w *DoQWriter) ConnectionState() *tls.ConnectionState
ConnectionState implements the dns.ConnectionStater interface, exposing the TLS state of the underlying QUIC connection (e.g. for plugins that need to read the SNI ServerName). Mirrors the DoT behavior already provided by the miekg/dns response writer.
func (*DoQWriter) RemoteAddr ¶ added in v1.11.0
func (*DoQWriter) TsigStatus ¶ added in v1.11.0
func (*DoQWriter) TsigTimersOnly ¶ added in v1.11.0
type FilterFunc ¶ added in v1.10.0
FilterFunc is a function that filters requests from the Config
type HTTPRequestKey ¶ added in v1.9.4
type HTTPRequestKey struct{}
HTTPRequestKey is the context key for the HTTP request when processing DNS-over-HTTPS. Plugins can access the original HTTP request to retrieve headers, client IP, and metadata.
type Key ¶ added in v1.0.6
type Key struct{}
Key is the context key for the current server added to the context.
type LoopKey ¶ added in v1.8.1
type LoopKey struct{}
LoopKey is the context key to detect server wide loops.
type MetadataCollector ¶ added in v1.10.0
MetadataCollector is a plugin that can retrieve metadata functions from all metadata providing plugins
type Server ¶
type Server struct {
Addr string // Address we listen on
IdleTimeout time.Duration // Idle timeout for connection-oriented transports
ReadTimeout time.Duration // Read timeout for connection-oriented transports
WriteTimeout time.Duration // Write timeout for connection-oriented transports that support it
MaxTCPQueries int // Maximum number of queries served on a single TCP/TLS connection. -1 means unlimited.
TsigSecret map[string]string // TSIG secrets of all served zones; must not be modified as it's concurrently accessed by DNS server.
// contains filtered or unexported fields
}
Server represents an instance of a server, which serves DNS requests at a particular address (host and port). A server is capable of serving numerous zones on the same address and the listener may be stopped for graceful termination (POSIX only).
func NewServer ¶
NewServer returns a new CoreDNS server and compiles all plugins in to it. By default CH class queries are blocked unless queries from enableChaos are loaded.
func (*Server) ListenPacket ¶
func (s *Server) ListenPacket() (net.PacketConn, error)
ListenPacket implements caddy.UDPServer interface.
func (*Server) OnStartupComplete ¶
func (s *Server) OnStartupComplete()
OnStartupComplete lists the sites served by this server and any relevant information, assuming Quiet is false.
func (*Server) Serve ¶
Serve starts the server with an existing listener. It blocks until the server stops. This implements caddy.TCPServer interface.
func (*Server) ServeDNS ¶
ServeDNS is the entry point for every request to the address that is bound to. It acts as a multiplexer for the requests zonename as defined in the request so that the correct zone (configuration and plugin stack) will handle the request.
func (*Server) ServePacket ¶
func (s *Server) ServePacket(p net.PacketConn) error
ServePacket starts the server with an existing packetconn. It blocks until the server stops. This implements caddy.UDPServer interface.
func (*Server) Stop ¶
Stop attempts to gracefully stop the server. It waits until the server is stopped and its connections are closed, up to a max timeout of a few seconds. If unsuccessful, an error is returned.
This implements Caddy.Stopper interface.
type ServerHTTPS ¶ added in v1.1.3
type ServerHTTPS struct {
*Server
// contains filtered or unexported fields
}
ServerHTTPS represents an instance of a DNS-over-HTTPS server.
func NewServerHTTPS ¶ added in v1.1.3
func NewServerHTTPS(addr string, group []*Config) (*ServerHTTPS, error)
NewServerHTTPS returns a new CoreDNS HTTPS server and compiles all plugins in to it.
func (*ServerHTTPS) Listen ¶ added in v1.1.3
func (s *ServerHTTPS) Listen() (net.Listener, error)
Listen implements caddy.TCPServer interface.
func (*ServerHTTPS) ListenPacket ¶ added in v1.1.3
func (s *ServerHTTPS) ListenPacket() (net.PacketConn, error)
ListenPacket implements caddy.UDPServer interface.
func (*ServerHTTPS) OnStartupComplete ¶ added in v1.1.3
func (s *ServerHTTPS) OnStartupComplete()
OnStartupComplete lists the sites served by this server and any relevant information, assuming Quiet is false.
func (*ServerHTTPS) Serve ¶ added in v1.1.3
func (s *ServerHTTPS) Serve(l net.Listener) error
Serve implements caddy.TCPServer interface.
func (*ServerHTTPS) ServeHTTP ¶ added in v1.1.3
func (s *ServerHTTPS) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP is the handler that gets the HTTP request and converts to the dns format, calls the plugin chain, converts it back and write it to the client.
func (*ServerHTTPS) ServePacket ¶ added in v1.1.3
func (s *ServerHTTPS) ServePacket(_p net.PacketConn) error
ServePacket implements caddy.UDPServer interface.
func (*ServerHTTPS) Shutdown ¶ added in v1.1.3
func (s *ServerHTTPS) Shutdown() error
Shutdown stops the server (non gracefully).
func (*ServerHTTPS) Stop ¶ added in v1.1.3
func (s *ServerHTTPS) Stop() error
Stop stops the server. It blocks until the server is totally stopped.
type ServerHTTPS3 ¶ added in v1.13.2
type ServerHTTPS3 struct {
*Server
// contains filtered or unexported fields
}
ServerHTTPS3 represents a DNS-over-HTTP/3 server.
func NewServerHTTPS3 ¶ added in v1.13.2
func NewServerHTTPS3(addr string, group []*Config) (*ServerHTTPS3, error)
NewServerHTTPS3 builds the HTTP/3 (DoH3) server.
func (*ServerHTTPS3) Listen ¶ added in v1.13.2
func (s *ServerHTTPS3) Listen() (net.Listener, error)
Listen function not used in HTTP/3, but defined for compatibility
func (*ServerHTTPS3) ListenPacket ¶ added in v1.13.2
func (s *ServerHTTPS3) ListenPacket() (net.PacketConn, error)
ListenPacket opens the UDP socket for QUIC.
func (*ServerHTTPS3) OnStartupComplete ¶ added in v1.13.2
func (s *ServerHTTPS3) OnStartupComplete()
OnStartupComplete lists the sites served by this server and any relevant information, assuming Quiet is false.
func (*ServerHTTPS3) ServeHTTP ¶ added in v1.13.2
func (s *ServerHTTPS3) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP is the handler for the DoH3 requests
func (*ServerHTTPS3) ServePacket ¶ added in v1.13.2
func (s *ServerHTTPS3) ServePacket(pc net.PacketConn) error
ServePacket starts serving QUIC+HTTP/3 on an existing UDP socket.
func (*ServerHTTPS3) Shutdown ¶ added in v1.13.2
func (s *ServerHTTPS3) Shutdown() error
Shutdown stops the server (non gracefully).
func (*ServerHTTPS3) Stop ¶ added in v1.13.2
func (s *ServerHTTPS3) Stop() error
Stop graceful shutdown. It blocks until the server is totally stopped.
type ServerQUIC ¶ added in v1.11.0
type ServerQUIC struct {
*Server
// contains filtered or unexported fields
}
ServerQUIC represents an instance of a DNS-over-QUIC server.
func NewServerQUIC ¶ added in v1.11.0
func NewServerQUIC(addr string, group []*Config) (*ServerQUIC, error)
NewServerQUIC returns a new CoreDNS QUIC server and compiles all plugin in to it.
func (*ServerQUIC) Listen ¶ added in v1.11.0
func (s *ServerQUIC) Listen() (net.Listener, error)
Listen implements caddy.TCPServer interface.
func (*ServerQUIC) ListenPacket ¶ added in v1.11.0
func (s *ServerQUIC) ListenPacket() (net.PacketConn, error)
ListenPacket implements caddy.UDPServer interface.
func (*ServerQUIC) OnStartupComplete ¶ added in v1.11.0
func (s *ServerQUIC) OnStartupComplete()
OnStartupComplete lists the sites served by this server and any relevant information, assuming Quiet is false.
func (*ServerQUIC) Serve ¶ added in v1.11.0
func (s *ServerQUIC) Serve(_l net.Listener) error
Serve implements caddy.TCPServer interface.
func (*ServerQUIC) ServePacket ¶ added in v1.11.0
func (s *ServerQUIC) ServePacket(p net.PacketConn) error
ServePacket implements caddy.UDPServer interface.
func (*ServerQUIC) ServeQUIC ¶ added in v1.11.0
func (s *ServerQUIC) ServeQUIC() error
ServeQUIC listens for incoming QUIC packets.
func (*ServerQUIC) Stop ¶ added in v1.11.0
func (s *ServerQUIC) Stop() error
Stop stops the server non-gracefully. It blocks until the server is totally stopped.
type ServerTLS ¶
type ServerTLS struct {
*Server
// contains filtered or unexported fields
}
ServerTLS represents an instance of a TLS-over-DNS-server.
func NewServerTLS ¶
NewServerTLS returns a new CoreDNS TLS server and compiles all plugin in to it.
func (*ServerTLS) ListenPacket ¶
func (s *ServerTLS) ListenPacket() (net.PacketConn, error)
ListenPacket implements caddy.UDPServer interface.
func (*ServerTLS) OnStartupComplete ¶
func (s *ServerTLS) OnStartupComplete()
OnStartupComplete lists the sites served by this server and any relevant information, assuming Quiet is false.
func (*ServerTLS) ServePacket ¶
func (s *ServerTLS) ServePacket(_p net.PacketConn) error
ServePacket implements caddy.UDPServer interface.
type ServergRPC ¶
type ServergRPC struct {
*Server
*pb.UnimplementedDnsServiceServer
// contains filtered or unexported fields
}
ServergRPC represents an instance of a DNS-over-gRPC server.
func NewServergRPC ¶
func NewServergRPC(addr string, group []*Config) (*ServergRPC, error)
NewServergRPC returns a new CoreDNS GRPC server and compiles all plugin in to it.
func (*ServergRPC) Listen ¶
func (s *ServergRPC) Listen() (net.Listener, error)
Listen implements caddy.TCPServer interface.
func (*ServergRPC) ListenPacket ¶
func (s *ServergRPC) ListenPacket() (net.PacketConn, error)
ListenPacket implements caddy.UDPServer interface.
func (*ServergRPC) OnStartupComplete ¶
func (s *ServergRPC) OnStartupComplete()
OnStartupComplete lists the sites served by this server and any relevant information, assuming Quiet is false.
func (*ServergRPC) Query ¶
Query is the main entry-point into the gRPC server. From here we call ServeDNS like any normal server. We use a custom responseWriter to pick up the bytes we need to write back to the client as a protobuf.
func (*ServergRPC) Serve ¶
func (s *ServergRPC) Serve(l net.Listener) error
Serve implements caddy.TCPServer interface.
func (*ServergRPC) ServePacket ¶
func (s *ServergRPC) ServePacket(_p net.PacketConn) error
ServePacket implements caddy.UDPServer interface.
func (*ServergRPC) Shutdown ¶
func (s *ServergRPC) Shutdown() error
Shutdown stops the server (non gracefully).
func (*ServergRPC) Stop ¶
func (s *ServergRPC) Stop() (err error)
Stop stops the server. It blocks until the server is totally stopped.
type TLSConfigIdentity ¶ added in v1.15.0
type TLSConfigIdentity struct {
// contains filtered or unexported fields
}
TLSConfigIdentity is an opaque identity for equivalent dynamic TLS policies. Plugins should share one identity only when they can prove that independently constructed TLS configs are interchangeable on the same listener.
func NewTLSConfigIdentity ¶ added in v1.15.0
func NewTLSConfigIdentity() *TLSConfigIdentity
NewTLSConfigIdentity returns a new opaque TLS policy identity.
type ViewKey ¶ added in v1.10.0
type ViewKey struct{}
ViewKey is the context key for the current view, if defined
type Viewer ¶ added in v1.10.0
type Viewer interface {
// Filter returns true if the server should use the server block in which the implementing plugin resides, and the
// name of the view for metrics logging.
Filter(ctx context.Context, req *request.Request) bool
// ViewName returns the name of the view
ViewName() string
}
Viewer - If Viewer is implemented by a plugin in a server block, its Filter() is added to the server block's filter functions when starting the server. When a running server serves a DNS request, it will route the request to the first Config (server block) that passes all its filter functions.