diff options
Diffstat (limited to 'plugin/pkg/parse/parse.go')
-rw-r--r-- | plugin/pkg/parse/parse.go | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/plugin/pkg/parse/parse.go b/plugin/pkg/parse/parse.go index 356d6c21c..300a57a8b 100644 --- a/plugin/pkg/parse/parse.go +++ b/plugin/pkg/parse/parse.go @@ -8,41 +8,31 @@ import ( "github.com/coredns/coredns/plugin/pkg/transport" ) -// Transfer parses transfer statements: 'transfer [to|from] [address...]'. -func Transfer(c *caddy.Controller, secondary bool) (tos, froms []string, err error) { +// TransferIn parses transfer statements: 'transfer from [address...]'. +func TransferIn(c *caddy.Controller) (froms []string, err error) { if !c.NextArg() { - return nil, nil, c.ArgErr() + return nil, c.ArgErr() } value := c.Val() switch value { - case "to": - tos = c.RemainingArgs() - for i := range tos { - if tos[i] != "*" { - normalized, err := HostPort(tos[i], transport.Port) - if err != nil { - return nil, nil, err - } - tos[i] = normalized - } - } - + default: + return nil, c.Errf("unknown property %s", value) case "from": - if !secondary { - return nil, nil, fmt.Errorf("can't use `transfer from` when not being a secondary") - } froms = c.RemainingArgs() + if len(froms) == 0 { + return nil, c.ArgErr() + } for i := range froms { if froms[i] != "*" { normalized, err := HostPort(froms[i], transport.Port) if err != nil { - return nil, nil, err + return nil, err } froms[i] = normalized } else { - return nil, nil, fmt.Errorf("can't use '*' in transfer from") + return nil, fmt.Errorf("can't use '*' in transfer from") } } } - return + return froms, nil } |