Cleanup docs and the chaos middleware

Make the CH middleware actually work. Needs a bit of a hack to route

the fake version.bind and friends zone to the correct handler. Fiddle

with the order in directive.go so that CH queries get logged as well.



Secondly add class rewriting to the rewrite middleware handler and also

log the class by default.
This commit is contained in:
Miek Gieben
2016-04-04 15:45:17 +01:00
parent 45ac2dd0c0
commit 6445a3f2f0
10 changed files with 60 additions and 20 deletions

View File

@@ -1,6 +1,7 @@
# chaos
`chaos`
The `chaos` middleware allows CoreDNS to response to TXT queries in CH class.
Useful for retrieving version or author information from the server.
## Syntax
@@ -11,16 +12,12 @@ chaos [version] [authors...]
* `version` the version to return, defaults to CoreDNS.
* `authors` what authors to return. No default.
Note this middleware can only be specified for a zone once. This is because it hijacks
the zones `version.bind`, `version.server`, `authors.bind`, `hostname.bind` and
`id.server`, which means it can only be routed to one middleware.
## Examples
~~~
etcd {
path /skydns
endpoint endpoint...
stubzones
}
chaos CoreDNS-001 "Miek Gieben" miek@miek.nl
~~~
* `path` /skydns
* `endpoint` endpoints...
* `stubzones`

View File

@@ -22,7 +22,10 @@ func (c Chaos) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
if state.QClass() != dns.ClassCHAOS || state.QType() != dns.TypeTXT {
return c.Next.ServeDNS(ctx, w, r)
}
m := new(dns.Msg)
m.SetReply(r)
hdr := dns.RR_Header{Name: state.QName(), Rrtype: dns.TypeTXT, Class: dns.ClassCHAOS, Ttl: 0}
switch state.Name() {
default: