do proper testing
This commit is contained in:
@@ -6,12 +6,16 @@ import (
|
||||
"github.com/coredns/coredns/core/dnsserver"
|
||||
"github.com/coredns/coredns/plugin"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// syntheticConfig holds the configuration options for the synthetic plugin.
|
||||
type syntheticConfig struct {
|
||||
net []*net.IPNet
|
||||
forward string
|
||||
ttl uint32
|
||||
prefix string
|
||||
}
|
||||
|
||||
// init registers this plugin.
|
||||
@@ -45,12 +49,40 @@ func setup(c *caddy.Controller) error {
|
||||
config.forward = arg
|
||||
}
|
||||
|
||||
// Configuration for the TTL value
|
||||
case "ttl":
|
||||
args := c.RemainingArgs()
|
||||
for _, arg := range args {
|
||||
ttl64, err := strconv.ParseUint(arg, 10, 32)
|
||||
if err != nil {
|
||||
return fmt.Errorf("synthetic: invalid ttl value: %v", arg)
|
||||
}
|
||||
config.ttl = uint32(ttl64)
|
||||
}
|
||||
|
||||
// configuration for the prefix value (defaults to `ip`)
|
||||
case "prefix":
|
||||
args := c.RemainingArgs()
|
||||
for _, arg := range args {
|
||||
config.prefix = arg
|
||||
}
|
||||
|
||||
default:
|
||||
return c.Errf("unknown property '%s'", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if config.forward == "" {
|
||||
return c.Err("synthetic: forward zone must be specified")
|
||||
}
|
||||
if config.prefix == "" {
|
||||
config.prefix = "ip"
|
||||
}
|
||||
if !strings.HasSuffix(config.prefix, "-") {
|
||||
config.prefix = config.prefix + "-"
|
||||
}
|
||||
|
||||
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
|
||||
return synthetic{Next: next, Config: config}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user