2017-08-20 09:55:02 +08:00
|
|
|
package alias
|
|
|
|
|
|
|
|
import (
|
2021-01-24 09:20:40 +08:00
|
|
|
"github.com/coredns/caddy"
|
2017-08-20 09:55:02 +08:00
|
|
|
"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
|
|
|
)
|
|
|
|
|
2021-01-24 09:20:40 +08:00
|
|
|
func init() { plugin.Register("alias", setup) }
|
2017-08-20 09:55:02 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|