mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -04:00
middleware/file: correctly parse the stanza (#658)
* middleware/file: correctly parse the stanza Parsing the file stanza would give precedence to 'transfer' and ignore other bits if it wasn't specified. This change fixes the parsing. The actually external CNAME retrieval is working fine (once the upstream is correctly parsed). This wasn't caught in tests, because we lack a parsing test for this. Fixes #657 * Add tests
This commit is contained in:
@@ -48,6 +48,7 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) {
|
||||
names := []string{}
|
||||
origins := []string{}
|
||||
for c.Next() {
|
||||
|
||||
if c.Val() == "secondary" {
|
||||
// secondary [origin]
|
||||
origins = make([]string, len(c.ServerBlockKeys))
|
||||
@@ -63,10 +64,18 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) {
|
||||
}
|
||||
|
||||
for c.NextBlock() {
|
||||
t, f, e := file.TransferParse(c, true)
|
||||
if e != nil {
|
||||
return file.Zones{}, e
|
||||
|
||||
t, f := []string{}, []string{}
|
||||
var e error
|
||||
|
||||
switch c.Val() {
|
||||
case "transfer":
|
||||
t, _, e = file.TransferParse(c, true)
|
||||
if e != nil {
|
||||
return file.Zones{}, e
|
||||
}
|
||||
}
|
||||
|
||||
for _, origin := range origins {
|
||||
if t != nil {
|
||||
z[origin].TransferTo = append(z[origin].TransferTo, t...)
|
||||
|
||||
Reference in New Issue
Block a user