util: imp autohosts
This commit is contained in:
parent
7e1b4ca6fe
commit
52575d0247
|
@ -120,14 +120,13 @@ func (a *AutoHosts) Process(host string, qtype uint16) []net.IP {
|
||||||
|
|
||||||
var ipsCopy []net.IP
|
var ipsCopy []net.IP
|
||||||
a.lock.RLock()
|
a.lock.RLock()
|
||||||
|
defer a.lock.RUnlock()
|
||||||
|
|
||||||
if ips, ok := a.table[host]; ok {
|
if ips, ok := a.table[host]; ok {
|
||||||
ipsCopy = make([]net.IP, len(ips))
|
ipsCopy = make([]net.IP, len(ips))
|
||||||
copy(ipsCopy, ips)
|
copy(ipsCopy, ips)
|
||||||
}
|
}
|
||||||
|
|
||||||
a.lock.RUnlock()
|
|
||||||
|
|
||||||
log.Debug("AutoHosts: answer: %s -> %v", host, ipsCopy)
|
log.Debug("AutoHosts: answer: %s -> %v", host, ipsCopy)
|
||||||
return ipsCopy
|
return ipsCopy
|
||||||
}
|
}
|
||||||
|
@ -339,10 +338,13 @@ func (a *AutoHosts) updateHosts() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a.lock.Lock()
|
func() {
|
||||||
a.table = table
|
a.lock.Lock()
|
||||||
a.tableReverse = tableRev
|
defer a.lock.Unlock()
|
||||||
a.lock.Unlock()
|
|
||||||
|
a.table = table
|
||||||
|
a.tableReverse = tableRev
|
||||||
|
}()
|
||||||
|
|
||||||
a.notify()
|
a.notify()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue