Fix Corefile parsing

Fix some file/secondary issues when parsing a Corefile, also allow

for multiple origins to be specified. Also don't fail on startup when

a zonetransfer fails.



Fixes: #54
This commit is contained in:
Miek Gieben
2016-04-03 15:52:23 +01:00
parent e41e8683bd
commit 3b25bfd7ae
5 changed files with 32 additions and 38 deletions

View File

@@ -35,23 +35,26 @@ func secondaryParse(c *Controller) (file.Zones, error) {
for c.Next() {
if c.Val() == "secondary" {
// secondary [origin]
origin := c.ServerBlockHosts[c.ServerBlockHostIndex]
if c.NextArg() {
origin = c.Val()
origins := []string{c.ServerBlockHosts[c.ServerBlockHostIndex]}
args := c.RemainingArgs()
if len(args) > 0 {
origins = args
}
for i, _ := range origins {
origins[i] = middleware.Host(origins[i]).Normalize()
z[origins[i]] = file.NewZone(origins[i])
names = append(names, origins[i])
}
// TODO(miek): we should allow more. Issue #54.
origin = middleware.Host(origin).Normalize()
z[origin] = file.NewZone(origin)
names = append(names, origin)
for c.NextBlock() {
t, f, e := parseTransfer(c)
if e != nil {
return file.Zones{}, e
}
z[origin].TransferTo = append(z[origin].TransferTo, t)
z[origin].TransferFrom = append(z[origin].TransferFrom, f)
for _, origin := range origins {
z[origin].TransferTo = append(z[origin].TransferTo, t)
z[origin].TransferFrom = append(z[origin].TransferFrom, f)
}
}
}
}