From 0c1b4738cdfdddee4c57a7f09b150f7e2befb115 Mon Sep 17 00:00:00 2001 From: kenshinx Date: Tue, 20 Oct 2015 14:01:41 +0800 Subject: [PATCH] Clear file-backend hosts cache. --- hosts.go | 6 ++++++ 1 file changed, 6 insertions(+) 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