Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var StringToHandler = map[string]func() Handler{ "acl": func() Handler { return new(acl.Acl) }, "any": func() Handler { return new(any.Any) }, "as112": func() Handler { return new(as112.As112) }, "chaos": func() Handler { return new(chaos.Chaos) }, "cookie": func() Handler { return new(cookie.Cookie) }, "dbfile": func() Handler { return new(dbfile.Dbfile) }, "dbhost": func() Handler { return new(dbhost.Dbhost) }, "dbsqlite": func() Handler { return new(dbsqlite.Dbsqlite) }, "drunk": func() Handler { return new(drunk.Drunk) }, "ecs": func() Handler { return new(ecs.Ecs) }, "geoip": func() Handler { return new(geoip.Geoip) }, "id": func() Handler { return new(id.Id) }, "kill": func() Handler { return new(kill.Kill) }, "log": func() Handler { return new(log.Log) }, "metrics": func() Handler { return new(metrics.Metrics) }, "msgcache": func() Handler { return new(msgcache.Msgcache) }, "nsid": func() Handler { return new(nsid.Nsid) }, "refuse": func() Handler { return new(refuse.Refuse) }, "sign": func() Handler { return new(sign.Sign) }, "template": func() Handler { return new(template.Template) }, "tsig": func() Handler { return new(tsig.Tsig) }, "unpack": func() Handler { return new(unpack.Unpack) }, "url": func() Handler { return new(url.Url) }, "whoami": func() Handler { return new(whoami.Whoami) }, "yes": func() Handler { return new(yes.Yes) }, }
StringToHandler is a map of strings to a handler creation function.
Functions ¶
func Compile ¶
func Compile(hs []Handler) dns.HandlerFunc
Compile takes the Handlers hs and creates a wrapped handle func.
Types ¶
type Handler ¶
type Handler interface {
// HandlerFunc run the handler's code.
HandlerFunc(next dns.HandlerFunc) dns.HandlerFunc
// Err returns a error with some extra data that identifies the handler in erroring. This method can be
// created with go generate, once some scaffolding is in place.
Err(error) error
}
A Handler is a dns.HandlerFunc that has a handler func (the next when to call in the middleware stack) as input and returns a handle func which is the handler itself.
There are several types of handlers that you can implement, handlers that:
- observe, things like logging and metrics.
- modify the dns.Msg and then call the next handler, they can enrich the context or modify the message.
- call the next handler, wait for it to return and modify the dns.Msg, think of setting TSIG or a DNS cookie.
If a Handler implements HandleFunc that returns a nil, instead of a proper dns.HandlerFunc, it is considered a noop handler and not added to the handlers chain. For the Handler to be useful it should implement Setupper, because without it would be a comletely useless handler.
type Setupper ¶
type Setupper interface {
Setup(co *dnsserver.Controller) error
}
Setupper holds a single method that is called when this Handler has configuration that needs to be parsed from the config file. The co's Global holds the server's global config.