mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
plugin/auto: Fix panic caused by config invalid reload value (#4986)
Automatically submitted.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user