mirror of
https://github.com/coredns/coredns.git
synced 2026-05-25 19:30:23 -04:00
plugin/file: trigger reload of zones based on mtime (#8085)
* Added fs.FileInfo.ModTime() based reload feature Signed-off-by: Endre Szabo <git@end.re> * Updated the plugin documentation. Signed-off-by: Endre Szabo <git@end.re> --------- Signed-off-by: Endre Szabo <git@end.re>
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/coredns/coredns/plugin"
|
||||
"github.com/coredns/coredns/plugin/pkg/fall"
|
||||
@@ -148,6 +149,15 @@ func Parse(f io.Reader, origin, fileName string, serial int64) (*Zone, error) {
|
||||
zp := dns.NewZoneParser(f, dns.Fqdn(origin), fileName)
|
||||
zp.SetIncludeAllowed(true)
|
||||
z := NewZone(origin, fileName)
|
||||
|
||||
if z.ReloadByMtime {
|
||||
fi, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to stat file %q with error %v", fileName, err)
|
||||
}
|
||||
z.file_mtime = fi.ModTime()
|
||||
}
|
||||
|
||||
seenSOA := false
|
||||
for rr, ok := zp.Next(); ok; rr, ok = zp.Next() {
|
||||
if !seenSOA {
|
||||
|
||||
Reference in New Issue
Block a user