fix: protecting concurrent access to LAN hosts

This commit is contained in:
evilsocket 2018-02-20 11:33:30 +01:00
commit 241db0cc66
6 changed files with 43 additions and 23 deletions

View file

@ -71,11 +71,12 @@ func (d Discovery) Author() string {
func (d *Discovery) runDiff(cache network.ArpTable) {
// check for endpoints who disappeared
var rem network.ArpTable = make(network.ArpTable)
for mac, t := range d.Session.Lan.Hosts {
d.Session.Lan.EachHost(func(mac string, e *network.Endpoint) {
if _, found := cache[mac]; found == false {
rem[mac] = t.IpAddress
rem[mac] = e.IpAddress
}
}
})
for mac, ip := range rem {
d.Session.Lan.Remove(ip, mac)