mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-22 21:15:35 +03:00
util: imp autohosts
This commit is contained in:
parent
7e1b4ca6fe
commit
52575d0247
1 changed files with 8 additions and 6 deletions
|
@ -120,14 +120,13 @@ func (a *AutoHosts) Process(host string, qtype uint16) []net.IP {
|
|||
|
||||
var ipsCopy []net.IP
|
||||
a.lock.RLock()
|
||||
defer a.lock.RUnlock()
|
||||
|
||||
if ips, ok := a.table[host]; ok {
|
||||
ipsCopy = make([]net.IP, len(ips))
|
||||
copy(ipsCopy, ips)
|
||||
}
|
||||
|
||||
a.lock.RUnlock()
|
||||
|
||||
log.Debug("AutoHosts: answer: %s -> %v", host, ipsCopy)
|
||||
return ipsCopy
|
||||
}
|
||||
|
@ -339,10 +338,13 @@ func (a *AutoHosts) updateHosts() {
|
|||
}
|
||||
}
|
||||
|
||||
a.lock.Lock()
|
||||
a.table = table
|
||||
a.tableReverse = tableRev
|
||||
a.lock.Unlock()
|
||||
func() {
|
||||
a.lock.Lock()
|
||||
defer a.lock.Unlock()
|
||||
|
||||
a.table = table
|
||||
a.tableReverse = tableRev
|
||||
}()
|
||||
|
||||
a.notify()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue