diff --git a/plugin/secondary/setup.go b/plugin/secondary/setup.go index 22f0d3224..f8b190b53 100644 --- a/plugin/secondary/setup.go +++ b/plugin/secondary/setup.go @@ -72,6 +72,7 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) { names = append(names, origins[i]) } + hasTransfer := false for c.NextBlock() { var f []string @@ -82,6 +83,7 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) { if err != nil { return file.Zones{}, err } + hasTransfer = true default: return file.Zones{}, c.Errf("unknown property '%s'", c.Val()) } @@ -93,6 +95,9 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) { z[origin].Upstream = upstream.New() } } + if !hasTransfer { + return file.Zones{}, c.Err("secondary zones require a transfer from property") + } } } return file.Zones{Z: z, Names: names}, nil diff --git a/plugin/secondary/setup_test.go b/plugin/secondary/setup_test.go index 4985ec5b6..dbf1cb663 100644 --- a/plugin/secondary/setup_test.go +++ b/plugin/secondary/setup_test.go @@ -13,12 +13,6 @@ func TestSecondaryParse(t *testing.T) { transferFrom string zones []string }{ - { - `secondary`, - false, // TODO(miek): should actually be true, because without transfer lines this does not make sense - "", - nil, - }, { `secondary { transfer from 127.0.0.1 @@ -35,6 +29,20 @@ func TestSecondaryParse(t *testing.T) { "127.0.0.1:53", []string{"example.org."}, }, + { + `secondary`, + true, + "", + nil, + }, + { + `secondary example.org { + transferr from 127.0.0.1 + }`, + true, + "", + nil, + }, } for i, test := range tests {