aboutsummaryrefslogtreecommitdiff
path: root/plugin/auto/setup.go
diff options
context:
space:
mode:
authorGravatar gomakesix <94422637+gomakesix@users.noreply.github.com> 2021-11-20 00:19:25 +0800
committerGravatar GitHub <noreply@github.com> 2021-11-19 16:19:25 +0000
commit71bb575b7187852a100f54453c519b8a2c821cb1 (patch)
tree8ee068fa03a1e2d94a07da0a28e428abc7c1dfb9 /plugin/auto/setup.go
parente799a0f5c7ae90b6db3b9f63e2d82765b30200e6 (diff)
downloadcoredns-71bb575b7187852a100f54453c519b8a2c821cb1.tar.gz
coredns-71bb575b7187852a100f54453c519b8a2c821cb1.tar.zst
coredns-71bb575b7187852a100f54453c519b8a2c821cb1.zip
plugin/auto: Fix panic caused by config invalid reload value (#4986)
Automatically submitted.
Diffstat (limited to 'plugin/auto/setup.go')
-rw-r--r--plugin/auto/setup.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/plugin/auto/setup.go b/plugin/auto/setup.go
index 1162274a0..38e8d26fe 100644
--- a/plugin/auto/setup.go
+++ b/plugin/auto/setup.go
@@ -1,6 +1,7 @@
package auto
import (
+ "errors"
"os"
"path/filepath"
"regexp"
@@ -44,7 +45,9 @@ func setup(c *caddy.Controller) error {
if err != nil {
return err
}
-
+ if a.loader.ReloadInterval == 0 {
+ return nil
+ }
go func() {
ticker := time.NewTicker(a.loader.ReloadInterval)
for {
@@ -131,7 +134,14 @@ func autoParse(c *caddy.Controller) (Auto, error) {
}
case "reload":
- d, err := time.ParseDuration(c.RemainingArgs()[0])
+ t := c.RemainingArgs()
+ if len(t) < 1 {
+ return a, errors.New("reload duration value is expected")
+ }
+ d, err := time.ParseDuration(t[0])
+ if d < 0 {
+ err = errors.New("invalid duration")
+ }
if err != nil {
return a, plugin.Error("file", err)
}