mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -04:00
plugin/host: don't append the names when reparsing hosts file (#3045)
The host plugin kept on adding entries instead of overwriting. Split the inline cache off from the /etc/hosts file cache and clear /etc/hosts file cache and re-parsing. A bunch of other cleanup as well. Use functions defined in the plugin package, don't re-parse strings if you don't have to and use To4() to check the family for IP addresses. Fix all test cases a carried entries are always fqdn-ed. Various smaller cleanup in unnessacry constants. Fixes: #3014 Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
@@ -26,7 +26,7 @@ func init() {
|
||||
func periodicHostsUpdate(h *Hosts) chan bool {
|
||||
parseChan := make(chan bool)
|
||||
|
||||
if h.options.reload == durationOf0s {
|
||||
if h.options.reload == 0 {
|
||||
return parseChan
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ func hostsParse(c *caddy.Controller) (Hosts, error) {
|
||||
h := Hosts{
|
||||
Hostsfile: &Hostsfile{
|
||||
path: "/etc/hosts",
|
||||
hmap: newHostsMap(),
|
||||
hmap: newMap(),
|
||||
options: options,
|
||||
},
|
||||
}
|
||||
@@ -152,7 +152,7 @@ func hostsParse(c *caddy.Controller) (Hosts, error) {
|
||||
if err != nil {
|
||||
return h, c.Errf("invalid duration for reload '%s'", remaining[0])
|
||||
}
|
||||
if reload < durationOf0s {
|
||||
if reload < 0 {
|
||||
return h, c.Errf("invalid negative duration for reload '%s'", remaining[0])
|
||||
}
|
||||
options.reload = reload
|
||||
|
||||
Reference in New Issue
Block a user