* plugin/hosts: create inline map in setup
The inline map wasn't create in the setup.go fuction leading to a crash,
which is masked by a recover (but leads to a SERVFAIL, and not logging
the request).
Various other simplifications.
host plugin could use some test that actually cover these edgecases.
Signed-off-by: Miek Gieben <miek@miek.nl>
* PR review changes
Signed-off-by: Miek Gieben <miek@miek.nl>
The host plugin kept on adding entries instead of overwriting. Split the
inline cache off from the /etc/hosts file cache and clear /etc/hosts
file cache and re-parsing.
A bunch of other cleanup as well. Use functions defined in the plugin
package, don't re-parse strings if you don't have to and use To4() to
check the family for IP addresses. Fix all test cases a carried entries
are always fqdn-ed. Various smaller cleanup in unnessacry constants.
Fixes: #3014
Signed-off-by: Miek Gieben <miek@miek.nl>
* plugin/hosts provide more configuration flexibility
This patch adds few features to the host plugin
* no-reverse (both as first argument on the plugin line and inline)
disable the automatic generation of reserve entries for hosts
* ttl <duration> (inline only atm)
allows to change the default ttl (default 5 minutes)
* reload <duration> (inline only atm)
allows to change the reloading interval (default 5s)
* plugin/hosts remove superfluous parameters to parse
Every plugin needs to deal with EDNS0 and should call Scrub to make a
message fit the client's buffer. Move this functionality into the server
and wrapping the ResponseWriter into a ScrubWriter that handles these
bits for us. Result:
Less code and faster, because multiple chained plugins could all be
calling scrub and SizeAndDo - now there is just one place.
Most tests in file/* and dnssec/* needed adjusting because in those unit
tests you don't see OPT RRs anymore. The DNSSEC signer was also looking
at the returned OPT RR to see if it needed to sign - as those are now
added by the server (and thus later), this needed to change slightly.
Scrub itself still exist (for backward compat reasons), but has been
made a noop. Scrub has been renamed to scrub as it should not be used by
external plugins.
Fixes: #2010
Signed-off-by: Miek Gieben <miek@miek.nl>
* Remove Compress by default
Set Compress = true in Scrub only when the message doesn not fit the
advertized buffer. Doing compression is expensive, so try to avoid it.
Master vs this branch
pkg: github.com/coredns/coredns/plugin/cache
BenchmarkCacheResponse-2 50000 24774 ns/op
pkg: github.com/coredns/coredns/plugin/cache
BenchmarkCacheResponse-2 100000 21960 ns/op
* and make it compile
* global: move to context
Move from golang.org/x/net/context to std lib's context.
Change done with:
for i in $(grep -l '/context' **/*.go); do sed -e 's|golang.org/x/net/context|context|' -i $i; echo $i; done
for i in **/*.go; do goimports -w $i; done
* drop from dns.pb.go as well
* Add pkg/fall for Fallthrough
Move this into it's own package to facilitate tests. Important bug
was fixed: make the names fully qualified.
Add fall package to hosts, reverse, etcd, and fix kubernetes and any
tests. The k8s tests are still as-is, might need a future cleanup.
* Rename middleware to plugin
first pass; mostly used 'sed', few spots where I manually changed
text.
This still builds a coredns binary.
* fmt error
* Rename AddMiddleware to AddPlugin
* Readd AddMiddleware to remain backwards compat