2017-08-20 09:55:02 +08:00
|
|
|
package alias
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/coredns/coredns/core/dnsserver"
|
2017-09-16 18:20:21 +08:00
|
|
|
"github.com/coredns/coredns/plugin"
|
2017-08-20 09:55:02 +08:00
|
|
|
|
2019-10-18 06:53:48 +08:00
|
|
|
"github.com/caddyserver/caddy"
|
2017-08-20 09:55:02 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
caddy.RegisterPlugin("alias", caddy.Plugin{
|
|
|
|
ServerType: "dns",
|
|
|
|
Action: setup,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func setup(c *caddy.Controller) error {
|
|
|
|
c.Next()
|
|
|
|
if c.NextArg() {
|
2017-09-16 18:20:21 +08:00
|
|
|
return plugin.Error("alias", c.ArgErr())
|
2017-08-20 09:55:02 +08:00
|
|
|
}
|
|
|
|
|
2017-09-16 18:20:21 +08:00
|
|
|
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
|
2017-08-20 09:55:02 +08:00
|
|
|
return Alias{Next: next}
|
|
|
|
})
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|