diff options
author | 2016-04-03 09:02:34 +0100 | |
---|---|---|
committer | 2016-04-03 09:02:34 +0100 | |
commit | f58f1e4285ab9725a317ac7b38f5905fb497c7b0 (patch) | |
tree | b44eead7ca9f687bea1813cfe7247123d8929026 /core/setup/file.go | |
parent | 7fb959470e95517967c4f0bcf85f1adf9a77a42f (diff) | |
download | coredns-f58f1e4285ab9725a317ac7b38f5905fb497c7b0.tar.gz coredns-f58f1e4285ab9725a317ac7b38f5905fb497c7b0.tar.zst coredns-f58f1e4285ab9725a317ac7b38f5905fb497c7b0.zip |
Add secondary support
Allow specifying a primary server and retrieve the zone's content.
Add tests and an Expired bool to zone struct, to stop server zones
that are expired. The zone is retrieved on Startup, no updates of
changed content are done. We also don't respond to notifies yet.
Diffstat (limited to 'core/setup/file.go')
-rw-r--r-- | core/setup/file.go | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/core/setup/file.go b/core/setup/file.go index aca9f8f9f..dc0d61e18 100644 --- a/core/setup/file.go +++ b/core/setup/file.go @@ -36,9 +36,9 @@ func fileParse(c *Controller) (file.Zones, error) { if c.NextArg() { origin = c.Val() } - // normalize this origin - origin = middleware.Host(origin).Standard() + origin = middleware.Host(origin).Normalize() + // TODO(miek): we should allow more. Issue #54. reader, err := os.Open(fileName) if err != nil { return file.Zones{}, err @@ -48,27 +48,40 @@ func fileParse(c *Controller) (file.Zones, error) { z[origin] = zone } names = append(names, origin) - if c.NextBlock() { - what := c.Val() - if !c.NextArg() { - return file.Zones{}, c.ArgErr() - } - value := c.Val() - var err error - switch what { - case "transfer": - if value == "out" { - z[origin].Transfer.Out = true - } - if value == "in" { - z[origin].Transfer.In = true - } - } - if err != nil { - return file.Zones{}, err + + for c.NextBlock() { + t, _, e := parseTransfer(c) + if e != nil { + return file.Zones{}, e } + // discard from, here, maybe check and show log when we do? + z[origin].TransferTo = append(z[origin].TransferTo, t) } } } return file.Zones{Z: z, Names: names}, nil } + +// transfer to [address] +func parseTransfer(c *Controller) (to, from string, err error) { + what := c.Val() + if !c.NextArg() { + return "", "", c.ArgErr() + } + value := c.Val() + switch what { + case "transfer": + if !c.NextArg() { + return "", "", c.ArgErr() + } + if value == "to" { + to = c.Val() + to = middleware.Addr(to).Normalize() + } + if value == "from" { + from = c.Val() + from = middleware.Addr(from).Normalize() + } + } + return +} |