aboutsummaryrefslogtreecommitdiff
path: root/plugin/hosts/setup.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2019-07-31 19:37:09 +0000
committerGravatar GitHub <noreply@github.com> 2019-07-31 19:37:09 +0000
commit07f016191d5d42e56f64408751fdb48057c5b930 (patch)
tree9c5364ed4a6f03bb45e052cac255f4e5279a3b7e /plugin/hosts/setup.go
parent45e17c325c16760374455157795d375709ee72ab (diff)
downloadcoredns-07f016191d5d42e56f64408751fdb48057c5b930.tar.gz
coredns-07f016191d5d42e56f64408751fdb48057c5b930.tar.zst
coredns-07f016191d5d42e56f64408751fdb48057c5b930.zip
plugin/hosts: create inline map in setup (#3071)
* plugin/hosts: create inline map in setup The inline map wasn't create in the setup.go fuction leading to a crash, which is masked by a recover (but leads to a SERVFAIL, and not logging the request). Various other simplifications. host plugin could use some test that actually cover these edgecases. Signed-off-by: Miek Gieben <miek@miek.nl> * PR review changes Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/hosts/setup.go')
-rw-r--r--plugin/hosts/setup.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/plugin/hosts/setup.go b/plugin/hosts/setup.go
index 73fd3cec4..981ea141f 100644
--- a/plugin/hosts/setup.go
+++ b/plugin/hosts/setup.go
@@ -73,13 +73,12 @@ func setup(c *caddy.Controller) error {
func hostsParse(c *caddy.Controller) (Hosts, error) {
config := dnsserver.GetConfig(c)
- options := newOptions()
-
h := Hosts{
Hostsfile: &Hostsfile{
path: "/etc/hosts",
hmap: newMap(),
- options: options,
+ inline: newMap(),
+ options: newOptions(),
},
}
@@ -129,7 +128,7 @@ func hostsParse(c *caddy.Controller) (Hosts, error) {
case "fallthrough":
h.Fall.SetZonesFromArgs(c.RemainingArgs())
case "no_reverse":
- options.autoReverse = false
+ h.options.autoReverse = false
case "ttl":
remaining := c.RemainingArgs()
if len(remaining) < 1 {
@@ -142,7 +141,7 @@ func hostsParse(c *caddy.Controller) (Hosts, error) {
if ttl <= 0 || ttl > 65535 {
return h, c.Errf("ttl provided is invalid")
}
- options.ttl = uint32(ttl)
+ h.options.ttl = uint32(ttl)
case "reload":
remaining := c.RemainingArgs()
if len(remaining) != 1 {
@@ -155,7 +154,7 @@ func hostsParse(c *caddy.Controller) (Hosts, error) {
if reload < 0 {
return h, c.Errf("invalid negative duration for reload '%s'", remaining[0])
}
- options.reload = reload
+ h.options.reload = reload
default:
if len(h.Fall.Zones) == 0 {
line := strings.Join(append([]string{c.Val()}, c.RemainingArgs()...), " ")