Documentation ¶
Overview ¶
Package dnsserver implements all the interfaces from Caddy, so that CoreDNS can be a servertype plugin.
Index ¶
- Constants
- Variables
- func DefaultErrorFunc(w dns.ResponseWriter, r *dns.Msg, rc int)
- func SplitProtocolHostPort(address string) (protocol string, ip string, port string, err error)
- func Transport(s string) string
- type Config
- type Key
- 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() (err error)
- func (s *Server) Tracer() ot.Tracer
- 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)
Constants ¶
const ( TransportDNS = "dns" TransportTLS = "tls" TransportGRPC = "grpc" )
Supported transports.
const ( // DefaultPort is the default port. DefaultPort = "53" // TLSPort is the default port for DNS-over-TLS. TLSPort = "853" // GRPCPort is the default port for DNS-over-gRPC. GRPCPort = "443" )
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{
"tls",
"nsid",
"root",
"bind",
"debug",
"trace",
"health",
"pprof",
"prometheus",
"errors",
"log",
"dnstap",
"chaos",
"loadbalance",
"cache",
"rewrite",
"dnssec",
"autopath",
"reverse",
"template",
"hosts",
"route53",
"federation",
"kubernetes",
"file",
"auto",
"secondary",
"etcd",
"forward",
"proxy",
"erratic",
"whoami",
"on",
"startup",
"shutdown",
}
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 Quiet bool
Quiet mode will not show any informative output on initialization.
Functions ¶
func DefaultErrorFunc ¶
func DefaultErrorFunc(w dns.ResponseWriter, r *dns.Msg, rc int)
DefaultErrorFunc responds to an DNS request with an error.
func SplitProtocolHostPort ¶ added in v1.0.6
SplitProtocolHostPort - split a full formed address like "dns://[::1}:53" into parts
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 // Root points to a base directory we 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 // 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 further filter access // to this handler. The primary use is to limit access to a reverse zone // on a non-octet boundary, i.e. /17 FilterFunc func(string) bool // TLSConfig when listening for encrypted connections (gRPC, DNS-over-TLS). TLSConfig *tls.Config // 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) 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) HostAddresses ¶ added in v1.0.6
HostAddresses builds a representation of the addresses of this Config after server is started ONLY, can be used as a Key for identifing that config :53 or 127.0.0.1:53 or 127.0.0.1:53/::1:53
type Server ¶
type Server struct { Addr string // Address we listen on // 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 s 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.
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 // 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.