aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2016-04-04 15:45:17 +0100
committerGravatar Miek Gieben <miek@miek.nl> 2016-04-04 15:45:17 +0100
commit6445a3f2f019bd951ffc02b5ec86d73157f512c2 (patch)
tree412eb10f7ea2bd27a3592bd3ea6c4a3ce5b177e4 /server
parent45ac2dd0c007901ad7557c1f703bf3da87b26b45 (diff)
downloadcoredns-6445a3f2f019bd951ffc02b5ec86d73157f512c2.tar.gz
coredns-6445a3f2f019bd951ffc02b5ec86d73157f512c2.tar.zst
coredns-6445a3f2f019bd951ffc02b5ec86d73157f512c2.zip
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.
Diffstat (limited to 'server')
-rw-r--r--server/server.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/server/server.go b/server/server.go
index 1c588b69f..c186c82d2 100644
--- a/server/server.go
+++ b/server/server.go
@@ -17,6 +17,7 @@ import (
"golang.org/x/net/context"
+ "github.com/miekg/coredns/middleware/chaos"
"github.com/miekg/dns"
)
@@ -97,7 +98,6 @@ func New(addr string, configs []Config, gracefulTimeout time.Duration) (*Server,
// Set up each zone
for _, conf := range configs {
- // TODO(miek): something better here?
if _, exists := s.zones[conf.Host]; exists {
return nil, fmt.Errorf("cannot serve %s - host already defined for address %s", conf.Address(), s.Addr)
}
@@ -111,6 +111,19 @@ func New(addr string, configs []Config, gracefulTimeout time.Duration) (*Server,
}
s.zones[conf.Host] = z
+
+ // A bit of a hack. Loop through the middlewares of this zone and check if
+ // they have enabled the chaos middleware. If so add the special chaos zones.
+ Middleware:
+ for _, mid := range z.config.Middleware {
+ fn := mid(nil)
+ if _, ok := fn.(chaos.Chaos); ok {
+ for _, ch := range []string{"authors.bind.", "version.bind.", "version.server.", "hostname.bind.", "id.server."} {
+ s.zones[ch] = z
+ }
+ break Middleware
+ }
+ }
}
return s, nil