diff --git a/hosts.go b/hosts.go index dd98d7c..a3e7d01 100644 --- a/hosts.go +++ b/hosts.go @@ -145,6 +145,8 @@ func (f *FileHosts) Refresh() { } defer buf.Close() + f.clear() + scanner := bufio.NewScanner(buf) for scanner.Scan() { @@ -175,6 +177,10 @@ func (f *FileHosts) Refresh() { logger.Debug("update hosts records from %s", f.file) } +func (f *FileHosts) clear() { + f.hosts = make(map[string]string) +} + func (f *FileHosts) isDomain(domain string) bool { if f.isIP(domain) { return false