misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
evilsocket 2018-02-17 06:04:16 +01:00
commit eb5a72a44c
9 changed files with 234 additions and 220 deletions

View file

@ -71,19 +71,19 @@ 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.Targets.Targets {
for mac, t := range d.Session.Lan.Hosts {
if _, found := cache[mac]; found == false {
rem[mac] = t.IpAddress
}
}
for mac, ip := range rem {
d.Session.Targets.Remove(ip, mac)
d.Session.Lan.Remove(ip, mac)
}
// now check for new friends ^_^
for ip, mac := range cache {
d.Session.Targets.AddIfNew(ip, mac)
d.Session.Lan.AddIfNew(ip, mac)
}
}