coredns-override/setup.go
2022-03-31 22:00:17 +02:00

41 lines
689 B
Go

package override
import (
"net"
"github.com/coredns/caddy"
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
)
func init() {
plugin.Register("override", setup)
}
func setup(c *caddy.Controller) error {
c.Next()
rules, err := parseRules(c)
if err != nil {
return plugin.Error("override", err)
}
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
return Override{Next: next, Rules: rules}
})
return nil
}
func parseRules(c *caddy.Controller) ([]Rule, error) {
var rules []Rule
rules = append(rules, Rule{
Search: net.ParseIP("45.9.63.244"),
Override: net.ParseIP("10.0.0.1"),
})
return rules, nil
}