mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
Plugin/BIND - extend the syntax to allow multiple addresses (#1512)
* Extend bind to allow multiple addresses. UTs added. Changes the log for server starting, adding address when available * update readme for bind * fixes after review * minor fix on readme * accept multiple BIND directives in blocserver, consolidate the addresses * fixes after review - format logging server address, variable names
This commit is contained in:
committed by
Miek Gieben
parent
a0834b1dd5
commit
76455c6a0d
@@ -12,13 +12,21 @@ import (
|
||||
|
||||
func setupBind(c *caddy.Controller) error {
|
||||
config := dnsserver.GetConfig(c)
|
||||
|
||||
// addresses will be consolidated over all BIND directives available in that BlocServer
|
||||
all := []string{}
|
||||
for c.Next() {
|
||||
if !c.Args(&config.ListenHost) {
|
||||
return plugin.Error("bind", c.ArgErr())
|
||||
addrs := c.RemainingArgs()
|
||||
if len(addrs) == 0 {
|
||||
return plugin.Error("bind", fmt.Errorf("at least one address is expected"))
|
||||
}
|
||||
for _, addr := range addrs {
|
||||
if net.ParseIP(addr) == nil {
|
||||
return plugin.Error("bind", fmt.Errorf("not a valid IP address: %s", addr))
|
||||
}
|
||||
}
|
||||
all = append(all, addrs...)
|
||||
}
|
||||
if net.ParseIP(config.ListenHost) == nil {
|
||||
return plugin.Error("bind", fmt.Errorf("not a valid IP address: %s", config.ListenHost))
|
||||
}
|
||||
config.ListenHosts = all
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user