2016-08-19 17:14:17 -07:00
|
|
|
package bind
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"net"
|
|
|
|
|
|
2017-02-21 22:51:47 -08:00
|
|
|
"github.com/coredns/coredns/core/dnsserver"
|
|
|
|
|
"github.com/coredns/coredns/middleware"
|
2016-08-19 17:14:17 -07:00
|
|
|
|
|
|
|
|
"github.com/mholt/caddy"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func setupBind(c *caddy.Controller) error {
|
|
|
|
|
config := dnsserver.GetConfig(c)
|
|
|
|
|
for c.Next() {
|
|
|
|
|
if !c.Args(&config.ListenHost) {
|
2016-09-10 09:16:25 +01:00
|
|
|
return middleware.Error("bind", c.ArgErr())
|
2016-08-19 17:14:17 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if net.ParseIP(config.ListenHost) == nil {
|
2016-09-10 09:16:25 +01:00
|
|
|
return middleware.Error("bind", fmt.Errorf("not a valid IP address: %s", config.ListenHost))
|
2016-08-19 17:14:17 -07:00
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|