-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.go
31 lines (25 loc) · 955 Bytes
/
setup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package oneaddr
import (
"github.com/coredns/caddy"
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
clog "github.com/coredns/coredns/plugin/pkg/log"
)
var log = clog.NewWithPlugin("oneaddr")
// init registers this plugin.
func init() { plugin.Register("oneaddr", setup) }
func setup(c *caddy.Controller) error {
c.Next() // Ignore "oneaddr" and give us the next token.
if c.NextArg() {
// If there was another token, return an error, because we don't have any configuration.
// Any errors returned from this setup function should be wrapped with plugin.Error, so we
// can present a slightly nicer error message to the user.
return plugin.Error("oneaddr", c.ArgErr())
}
// Add the Plugin to CoreDNS, so Servers can use it in their plugin chain.
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
return OneAddr{Next: next}
})
// All OK, return a nil error.
return nil
}