Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plugin/secondary/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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())
}
Expand All @@ -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
Expand Down
20 changes: 14 additions & 6 deletions plugin/secondary/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentionally made a typo.

}`,
true,
"",
nil,
},
}

for i, test := range tests {
Expand Down