2016-09-17 17:09:05 +01:00
|
|
|
package whoami
|
|
|
|
|
|
|
|
|
|
import (
|
2017-02-21 22:51:47 -08:00
|
|
|
"github.com/coredns/coredns/core/dnsserver"
|
2017-09-14 09:36:06 +01:00
|
|
|
"github.com/coredns/coredns/plugin"
|
2016-09-17 17:09:05 +01:00
|
|
|
|
2019-07-03 09:04:47 +08:00
|
|
|
"github.com/caddyserver/caddy"
|
2016-09-17 17:09:05 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
caddy.RegisterPlugin("whoami", caddy.Plugin{
|
|
|
|
|
ServerType: "dns",
|
2018-02-28 19:56:14 -08:00
|
|
|
Action: setup,
|
2016-09-17 17:09:05 +01:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-28 19:56:14 -08:00
|
|
|
func setup(c *caddy.Controller) error {
|
2016-09-17 17:09:05 +01:00
|
|
|
c.Next() // 'whoami'
|
|
|
|
|
if c.NextArg() {
|
2017-09-14 09:36:06 +01:00
|
|
|
return plugin.Error("whoami", c.ArgErr())
|
2016-09-17 17:09:05 +01:00
|
|
|
}
|
|
|
|
|
|
2017-09-14 09:36:06 +01:00
|
|
|
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
|
2016-12-20 18:58:05 +00:00
|
|
|
return Whoami{}
|
2016-09-17 17:09:05 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|