coredns: github.com/coredns/coredns/plugin Index | Files | Directories

package plugin

import "github.com/coredns/coredns/plugin"

Package plugin provides some types and functions common among plugin.

Index

Package Files

backend.go backend_lookup.go done.go normalize.go plugin.go register.go

Constants

const Namespace = "coredns"

Namespace is the namespace used for the metrics.

Variables

var ErrOnce = errors.New("this plugin can only be used once per Server Block")

ErrOnce is returned when a plugin doesn't support multiple setups per server.

var TimeBuckets = prometheus.ExponentialBuckets(0.00025, 2, 16) // from 0.25ms to 8 seconds

TimeBuckets is based on Prometheus client_golang prometheus.DefBuckets

func A Uses

func A(ctx context.Context, b ServiceBackend, zone string, state request.Request, previousRecords []dns.RR, opt Options) (records []dns.RR, err error)

A returns A records from Backend or an error.

func AAAA Uses

func AAAA(ctx context.Context, b ServiceBackend, zone string, state request.Request, previousRecords []dns.RR, opt Options) (records []dns.RR, err error)

AAAA returns AAAA records from Backend or an error.

func BackendError Uses

func BackendError(ctx context.Context, b ServiceBackend, zone string, rcode int, state request.Request, err error, opt Options) (int, error)

BackendError writes an error response to the client.

func CNAME Uses

func CNAME(ctx context.Context, b ServiceBackend, zone string, state request.Request, opt Options) (records []dns.RR, err error)

CNAME returns CNAME records from the backend or an error.

func ClientWrite Uses

func ClientWrite(rcode int) bool

ClientWrite returns true if the response has been written to the client. Each plugin to adhere to this protocol.

func Done Uses

func Done(ctx context.Context) bool

Done is a non-blocking function that returns true if the context has been canceled.

func Error Uses

func Error(name string, err error) error

Error returns err with 'plugin/name: ' prefixed to it.

func MX Uses

func MX(ctx context.Context, b ServiceBackend, zone string, state request.Request, opt Options) (records, extra []dns.RR, 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 Uses

func NS(ctx context.Context, b ServiceBackend, zone string, state request.Request, opt Options) (records, extra []dns.RR, err error)

NS returns NS records from the backend

func NextOrFailure Uses

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 nil, otherwise it will return, a ServerFailure and a nil error.

func PTR Uses

func PTR(ctx context.Context, b ServiceBackend, zone string, state request.Request, opt Options) (records []dns.RR, err error)

PTR returns the PTR records from the backend, only services that have a domain name as host are included.

func Register Uses

func Register(name string, action caddy.SetupFunc)

Register registers your plugin with CoreDNS and allows it to be called when the server is running.

func SOA Uses

func SOA(ctx context.Context, b ServiceBackend, zone string, state request.Request, opt Options) ([]dns.RR, error)

SOA returns a SOA record from the backend.

func SRV Uses

func SRV(ctx context.Context, b ServiceBackend, zone string, state request.Request, opt Options) (records, extra []dns.RR, 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 SplitHostPort Uses

func SplitHostPort(s string) (host, port string, ipnet *net.IPNet, err error)

SplitHostPort splits s up in a host and port portion, taking reverse address notation into account. String the string s should *not* be prefixed with any protocols, i.e. dns://. The returned ipnet is the *net.IPNet that is used when the zone is a reverse and a netmask is given.

func TXT Uses

func TXT(ctx context.Context, b ServiceBackend, zone string, state request.Request, opt Options) (records []dns.RR, err error)

TXT returns TXT records from Backend or an error.

type Handler Uses

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. CoreDNS assumes *no* reply has yet been written if the status code is one of the following:

* SERVFAIL (dns.RcodeServerFailure)

* REFUSED (dns.RecodeRefused)

* FORMERR (dns.RcodeFormatError)

* NOTIMP (dns.RcodeNotImplemented)

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 plugin.

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 plugin chain by returning them unchanged.

type HandlerFunc Uses

type HandlerFunc func(context.Context, dns.ResponseWriter, *dns.Msg) (int, error)

HandlerFunc is a convenience type like dns.HandlerFunc, except ServeDNS returns an rcode and an error. See Handler documentation for more information.

func (HandlerFunc) Name Uses

func (f HandlerFunc) Name() string

Name implements the Handler interface.

func (HandlerFunc) ServeDNS Uses

func (f HandlerFunc) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the Handler interface.

type Host Uses

type Host string

Host represents a host from the Corefile, may contain port.

func (Host) MustNormalize Uses

func (h Host) MustNormalize() (string, error)

MustNormalize will return the host portion of host, stripping of any port or transport. The host will also be fully qualified and lowercased. An error is returned on error

func (Host) Normalize Uses

func (h Host) Normalize() string

Normalize will return the host portion of host, stripping of any port or transport. The host will also be fully qualified and lowercased. An empty string is returned on failure

type Name Uses

type Name string

Name represents a domain name.

func (Name) Matches Uses

func (n Name) Matches(child string) bool

Matches checks to see if other is a subdomain (or the same domain) of n. This method assures that names can be easily and consistently matched.

func (Name) Normalize Uses

func (n Name) Normalize() string

Normalize lowercases and makes n fully qualified.

type Options Uses

type Options struct{}

Options are extra options that can be specified for a lookup.

type Plugin Uses

type Plugin func(Handler) Handler

Plugin is a middle layer which represents the traditional idea of plugin: it chains one Handler to the next by being passed the next Handler in the chain.

type ServiceBackend Uses

type ServiceBackend interface {
    // Services communicates with the backend to retrieve the service definitions. Exact indicates
    // on exact match should be returned.
    Services(ctx context.Context, state request.Request, exact bool, opt Options) ([]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(ctx context.Context, state request.Request, exact bool, opt Options) ([]msg.Service, error)

    // Lookup is used to find records else where.
    Lookup(ctx context.Context, state request.Request, name string, typ uint16) (*dns.Msg, error)

    // Returns _all_ services that matches a certain name.
    // Note: it does not implement a specific service.
    Records(ctx context.Context, state request.Request, exact bool) ([]msg.Service, error)

    // IsNameError return true if err indicated a record not found condition
    IsNameError(err error) bool

    Transferer
}

ServiceBackend defines a (dynamic) backend that returns a slice of service definitions.

type Transferer Uses

type Transferer interface {
    // Serial returns a SOA serial number to construct a SOA record.
    Serial(state request.Request) uint32

    // MinTTL returns the minimum TTL to be used in the SOA record.
    MinTTL(state request.Request) uint32

    // Transfer handles a zone transfer it writes to the client just
    // like any other handler.
    Transfer(ctx context.Context, state request.Request) (int, error)
}

Transferer defines an interface for backends that provide AXFR of all records.

type Zones Uses

type Zones []string

Zones represents a lists of zone names.

func (Zones) Matches Uses

func (z Zones) Matches(qname string) string

Matches checks if qname is a subdomain of any of the zones in z. The match will return the most specific zones that matches. The empty string signals a not found condition.

func (Zones) Normalize Uses

func (z Zones) Normalize()

Normalize fully qualifies all zones in z. The zones in Z must be domain names, without a port or protocol prefix.

Directories

PathSynopsis
acl
any
autoPackage auto implements an on-the-fly loading file backend.
autopathPackage autopath implements autopathing.
azure
bindPackage bind allows binding to a specific interface instead of bind to all of them.
bufsizePackage bufsize implements a plugin that modifies EDNS0 buffer size.
cachePackage cache implements a cache.
cache/freqPackage freq keeps track of last X seen events.
cancelPackage cancel implements a plugin adds a canceling context to each request.
chaosPackage chaos implements a plugin that answer to 'CH version.bind TXT' type queries.
clouddnsPackage clouddns implements a plugin that returns resource records from GCP Cloud DNS.
debug
deprecatedPackage deprecated is used when we deprecated plugin.
dnssecPackage dnssec implements a plugin that signs responses on-the-fly using NSEC black lies.
dnstap
dnstap/dnstapio
dnstap/msg
dnstap/taprwPackage taprw takes a query and intercepts the response.
dnstap/test
erraticPackage erratic implements a plugin that returns erratic answers (delayed, dropped).
errorsPackage errors implements an error handling plugin.
etcdPackage etcd provides the etcd version 3 backend plugin.
etcd/msgPackage msg defines the Service structure which is used for service discovery.
filePackage file implements a file backend.
file/rrutilPackage rrutil provides function to find certain RRs in slices.
file/treePackage tree implements Left-Leaning Red Black trees as described by Robert Sedgewick.
forwardPackage forward implements a forwarding proxy.
grpc
healthPackage health implements an HTTP handler that responds to health checks.
hosts
k8s_externalPackage external implements external names for kubernetes clusters.
kubernetesPackage kubernetes provides the kubernetes backend.
kubernetes/objectPackage object holds functions that convert the objects from the k8s API in to a more memory efficient structures.
loadbalancePackage loadbalance is a plugin for rewriting responses to do "load balancing"
logPackage log implements basic but useful request (access) logging plugin.
loop
metadataPackage metadata provides an API that allows plugins to add metadata to the context.
metricsPackage metrics implement a handler and plugin that provides Prometheus metrics.
metrics/vars
nsidPackage nsid implements NSID protocol
pkg/cachePackage cache implements a cache.
pkg/dnstestPackage dnstest allows for easy testing of DNS client against a test server.
pkg/dnsutilPackage dnsutil contains DNS related helper functions.
pkg/doh
pkg/ednsPackage edns provides function useful for adding/inspecting OPT records to/in messages.
pkg/fallPackage fall handles the fallthrough logic used in plugins that support it.
pkg/fuzzPackage fuzz contains functions that enable fuzzing of plugins.
pkg/logPackage log implements a small wrapper around the std lib log package.
pkg/nonwriterPackage nonwriter implements a dns.ResponseWriter that never writes, but captures the dns.Msg being written.
pkg/parsePackage parse contains functions that can be used in the setup code for plugins.
pkg/rcode
pkg/replacer
pkg/response
pkg/singleflightPackage singleflight provides a duplicate function call suppression mechanism.
pkg/tls
pkg/trace
pkg/transport
pkg/uniqPackage uniq keeps track of "thing" that are either "todo" or "done".
pkg/upPackage up is used to run a function for some duration.
pkg/upstreamPackage upstream abstracts a upstream lookups so that plugins can handle them in an unified way.
pprofPackage pprof implements a debug endpoint for getting profiles using the go pprof tooling.
readyPackage ready is used to signal readiness of the CoreDNS process.
reloadPackage reload periodically checks if the Corefile has changed, and reloads if so.
rewritePackage rewrite is a plugin for rewriting requests internally to something different.
root
route53Package route53 implements a plugin that returns resource records from AWS route53.
secondaryPackage secondary implements a secondary plugin.
signPackage sign implements a zone signer as a plugin.
template
testPackage test contains helper functions for writing plugin tests.
tls
tracePackage trace implements OpenTracing-based tracing
transfer
whoamiPackage whoami implements a plugin that returns details about the resolving querying it.

Package plugin imports 15 packages (graph) and is imported by 361 packages. Updated 2019-11-11. Refresh now. Tools for package owners.