Documentation ¶
Overview ¶
Package middleware provides some types and functions common among middleware.
Index ¶
- Constants
- func A(b ServiceBackend, zone string, state request.Request, previousRecords []dns.RR, ...) (records []dns.RR, debug []msg.Service, err error)
- func AAAA(b ServiceBackend, zone string, state request.Request, previousRecords []dns.RR, ...) (records []dns.RR, debug []msg.Service, err error)
- func BackendError(b ServiceBackend, zone string, rcode int, state request.Request, ...) (int, error)
- func CNAME(b ServiceBackend, zone string, state request.Request, opt Options) (records []dns.RR, debug []msg.Service, err error)
- func Error(name string, err error) error
- func ErrorToTxt(err error) dns.RR
- func MX(b ServiceBackend, zone string, state request.Request, opt Options) (records, extra []dns.RR, debug []msg.Service, err error)
- func NS(b ServiceBackend, zone string, state request.Request, opt Options) (records, extra []dns.RR, debug []msg.Service, err error)
- func NextOrFailure(name string, next Handler, ctx context.Context, w dns.ResponseWriter, ...) (int, error)
- func PTR(b ServiceBackend, zone string, state request.Request, opt Options) (records []dns.RR, debug []msg.Service, err error)
- func SOA(b ServiceBackend, zone string, state request.Request, opt Options) ([]dns.RR, []msg.Service, error)
- func SRV(b ServiceBackend, zone string, state request.Request, opt Options) (records, extra []dns.RR, debug []msg.Service, err error)
- func ServicesToTxt(debug []msg.Service) []dns.RR
- func TXT(b ServiceBackend, zone string, state request.Request, opt Options) (records []dns.RR, debug []msg.Service, err error)
- type Addr
- type Handler
- type HandlerFunc
- type Host
- type Middleware
- type Name
- type Options
- type ServiceBackend
- type Zones
Constants ¶
const ( TransportDNS = "dns" TransportTLS = "tls" TransportGRPC = "grpc" )
Duplicated from core/dnsserver/address.go !
const Namespace = "coredns"
Namespace is the namespace used for the metrics.
Variables ¶
This section is empty.
Functions ¶
func A ¶
func A(b ServiceBackend, zone string, state request.Request, previousRecords []dns.RR, opt Options) (records []dns.RR, debug []msg.Service, err error)
A returns A records from Backend or an error.
func AAAA ¶
func AAAA(b ServiceBackend, zone string, state request.Request, previousRecords []dns.RR, opt Options) (records []dns.RR, debug []msg.Service, err error)
AAAA returns AAAA records from Backend or an error.
func BackendError ¶
func BackendError(b ServiceBackend, zone string, rcode int, state request.Request, debug []msg.Service, err error, opt Options) (int, error)
BackendError writes an error response to the client.
func CNAME ¶
func CNAME(b ServiceBackend, zone string, state request.Request, opt Options) (records []dns.RR, debug []msg.Service, err error)
CNAME returns CNAME records from the backend or an error.
func MX ¶
func MX(b ServiceBackend, zone string, state request.Request, opt Options) (records, extra []dns.RR, debug []msg.Service, err error)
MX returns MX records from the Backend. If the Target is not a name but an IP address, a name is created on the fly.
func NS ¶
func NS(b ServiceBackend, zone string, state request.Request, opt Options) (records, extra []dns.RR, debug []msg.Service, err error)
NS returns NS records from the backend
func NextOrFailure ¶
func NextOrFailure(name string, next Handler, ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)
NextOrFailure calls next.ServeDNS when next is not nill, otherwise it will return, a ServerFailure and a nil error.
func PTR ¶
func PTR(b ServiceBackend, zone string, state request.Request, opt Options) (records []dns.RR, debug []msg.Service, err error)
PTR returns the PTR records from the backend, only services that have a domain name as host are included.
func SOA ¶
func SOA(b ServiceBackend, zone string, state request.Request, opt Options) ([]dns.RR, []msg.Service, error)
SOA returns a SOA record from the backend.
func SRV ¶
func SRV(b ServiceBackend, zone string, state request.Request, opt Options) (records, extra []dns.RR, debug []msg.Service, err error)
SRV returns SRV records from the Backend. If the Target is not a name but an IP address, a name is created on the fly.
func ServicesToTxt ¶
ServicesToTxt puts debug in TXT RRs.
Types ¶
type Addr ¶
type Addr string // Addr resprents an address in the Corefile.
Addr represents an address in the Corefile.
type Handler ¶
type Handler interface { ServeDNS(context.Context, dns.ResponseWriter, *dns.Msg) (int, error) Name() string }
Handler is like dns.Handler except ServeDNS may return an rcode and/or error.
If ServeDNS writes to the response body, it should return a status code. If the status code is not one of the following:
* SERVFAIL (dns.RcodeServerFailure)
* REFUSED (dns.RecodeRefused)
* FORMERR (dns.RcodeFormatError)
* NOTIMP (dns.RcodeNotImplemented)
CoreDNS assumes *no* reply has yet been written. All other response codes signal other handlers above it that the response message is already written, and that they should not write to it also.
If ServeDNS encounters an error, it should return the error value so it can be logged by designated error-handling middleware.
If writing a response after calling another ServeDNS method, the returned rcode SHOULD be used when writing the response.
If handling errors after calling another ServeDNS method, the returned error value SHOULD be logged or handled accordingly.
Otherwise, return values should be propagated down the middleware chain by returning them unchanged.
type HandlerFunc ¶
HandlerFunc is a convenience type like dns.HandlerFunc, except ServeDNS returns an rcode and an error. See Handler documentation for more information.
type Host ¶
type Host string // Host represents a host from the Corefile, may contain port.
Host represents a host from the Corefile, may contain port.
type Middleware ¶
Middleware is the middle layer which represents the traditional idea of middleware: it chains one Handler to the next by being passed the next Handler in the chain.
type Name ¶
type Name string
Name represents a domain name.
type Options ¶
type Options struct {
Debug string // This is a debug query. A query prefixed with debug.o-o
}
Options are extra options that can be specified for a lookup.
type ServiceBackend ¶
type ServiceBackend interface { // Services communicates with the backend to retrieve the service definition. Exact indicates // on exact much are that we are allowed to recurs. Services(state request.Request, exact bool, opt Options) ([]msg.Service, []msg.Service, error) // Reverse communicates with the backend to retrieve service definition based on a IP address // instead of a name. I.e. a reverse DNS lookup. Reverse(state request.Request, exact bool, opt Options) ([]msg.Service, []msg.Service, error) // Lookup is used to find records else where. Lookup(state request.Request, name string, typ uint16) (*dns.Msg, error) // IsNameError return true if err indicated a record not found condition IsNameError(err error) bool // Debug returns a string used when returning debug services. Debug() string // Returns _all_ services that matches a certain name. // Note: it does not implement a specific service. Records(name string, exact bool) ([]msg.Service, error) }
ServiceBackend defines a (dynamic) backend that returns a slice of service definitions.
Directories ¶
Path | Synopsis |
---|---|
Package auto implements an on-the-fly loading file backend.
|
Package auto implements an on-the-fly loading file backend. |
Package bind allows binding to a specific interface instead of bind to all of them.
|
Package bind allows binding to a specific interface instead of bind to all of them. |
Package cache implements a cache.
|
Package cache implements a cache. |
freq
Package freq keeps track of last X seen events.
|
Package freq keeps track of last X seen events. |
Package chaos implements a middleware that answer to 'CH version.bind TXT' type queries.
|
Package chaos implements a middleware that answer to 'CH version.bind TXT' type queries. |
Package dnssec implements a middleware that signs responses on-the-fly using NSEC black lies.
|
Package dnssec implements a middleware that signs responses on-the-fly using NSEC black lies. |
msg
Package msg helps to build a dnstap Message.
|
Package msg helps to build a dnstap Message. |
taprw
Package taprw takes a query and intercepts the response.
|
Package taprw takes a query and intercepts the response. |
Package erratic implements a middleware that returns erratic answers (delayed, dropped).
|
Package erratic implements a middleware that returns erratic answers (delayed, dropped). |
Package errors implements an HTTP error handling middleware.
|
Package errors implements an HTTP error handling middleware. |
Package etcd provides the etcd backend middleware.
|
Package etcd provides the etcd backend middleware. |
msg
Package msg defines the Service structure which is used for service discovery.
|
Package msg defines the Service structure which is used for service discovery. |
Package file implements a file backend.
|
Package file implements a file backend. |
tree
Package tree implements Left-Leaning Red Black trees as described by Robert Sedgewick.
|
Package tree implements Left-Leaning Red Black trees as described by Robert Sedgewick. |
Package health implements an HTTP handler that responds to health checks.
|
Package health implements an HTTP handler that responds to health checks. |
Package kubernetes provides the kubernetes backend.
|
Package kubernetes provides the kubernetes backend. |
Package loadbalance is middleware for rewriting responses to do "load balancing" Package loadbalance shuffles A and AAAA records.
|
Package loadbalance is middleware for rewriting responses to do "load balancing" Package loadbalance shuffles A and AAAA records. |
Package log implements basic but useful request (access) logging middleware.
|
Package log implements basic but useful request (access) logging middleware. |
Package metrics implement a handler and middleware that provides Prometheus metrics.
|
Package metrics implement a handler and middleware that provides Prometheus metrics. |
test
Package test will scrape a target and you can inspect the variables.
|
Package test will scrape a target and you can inspect the variables. |
pkg
|
|
cache
Package cache implements a cache.
|
Package cache implements a cache. |
dnsrecorder
Package dnsrecorder allows you to record a DNS response when it is send to the client.
|
Package dnsrecorder allows you to record a DNS response when it is send to the client. |
dnsutil
Package dnsutil contains DNS related helper functions.
|
Package dnsutil contains DNS related helper functions. |
edns
Package edns provides function useful for adding/inspecting OPT records to/in messages.
|
Package edns provides function useful for adding/inspecting OPT records to/in messages. |
singleflight
Package singleflight provides a duplicate function call suppression mechanism.
|
Package singleflight provides a duplicate function call suppression mechanism. |
Package pprof implement a debug endpoint for getting profiles using the go pprof tooling.
|
Package pprof implement a debug endpoint for getting profiles using the go pprof tooling. |
Package proxy is middleware that proxies requests.
|
Package proxy is middleware that proxies requests. |
Package rewrite is middleware for rewriting requests internally to something different.
|
Package rewrite is middleware for rewriting requests internally to something different. |
Package secondary implements a secondary middleware.
|
Package secondary implements a secondary middleware. |
Package test contains helper functions for writing middleware tests.
|
Package test contains helper functions for writing middleware tests. |
Package trace implements OpenTracing-based tracing
|
Package trace implements OpenTracing-based tracing |
Package whoami implements a middleware that returns details about the resolving querying it.
|
Package whoami implements a middleware that returns details about the resolving querying it. |