aboutsummaryrefslogtreecommitdiff
path: root/middleware/file/file.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2016-10-17 18:37:56 +0100
committerGravatar GitHub <noreply@github.com> 2016-10-17 18:37:56 +0100
commitd536272201b117e18c909a921358fa19dee89f35 (patch)
tree35bf3d9a118401cb6e51d6bc20e1e7eb3b0b5f95 /middleware/file/file.go
parent2eafe3ee94bc4b1e94000bc74f8ee524132ae27c (diff)
downloadcoredns-d536272201b117e18c909a921358fa19dee89f35.tar.gz
coredns-d536272201b117e18c909a921358fa19dee89f35.tar.zst
coredns-d536272201b117e18c909a921358fa19dee89f35.zip
middleware/auto: add (#333)
Add auto-load middleware that automatically picks up zones. Every X seconds it will scan for new zones. Add tests and documentation. Make 'make test' use -race.
Diffstat (limited to 'middleware/file/file.go')
-rw-r--r--middleware/file/file.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/middleware/file/file.go b/middleware/file/file.go
index b1136c7db..90d15af79 100644
--- a/middleware/file/file.go
+++ b/middleware/file/file.go
@@ -22,8 +22,8 @@ type (
// Zones maps zone names to a *Zone.
Zones struct {
- Z map[string]*Zone
- Names []string
+ Z map[string]*Zone // A map mapping zone (origin) to the Zone's data
+ Names []string // All the keys from the map Z as a string slice.
}
)
@@ -35,6 +35,7 @@ func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
return dns.RcodeServerFailure, errors.New("can only deal with ClassINET")
}
qname := state.Name()
+ // TODO(miek): match the qname better in the map
zone := middleware.Zones(f.Zones.Names).Matches(qname)
if zone == "" {
if f.Next != nil {
@@ -49,6 +50,8 @@ func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
if z == nil {
return dns.RcodeServerFailure, nil
}
+
+ // This is only for when we are a secondary zones.
if r.Opcode == dns.OpcodeNotify {
if z.isNotify(state) {
m := new(dns.Msg)