do proper testing

This commit is contained in:
Donavan Fritz
2024-02-20 22:26:54 -08:00
parent 6c6d9580d9
commit 2e9360fd45
6 changed files with 449 additions and 24 deletions
+32
View File
@@ -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}
})