This commit is contained in:
evilsocket 2018-01-24 13:51:37 +01:00
parent 6e6eb688d7
commit 1cffa33264
7 changed files with 74 additions and 75 deletions

View file

@ -6,19 +6,19 @@ import (
)
func ArpUpdate(iface string) (ArpTable, error) {
arp_lock.Lock()
defer arp_lock.Unlock()
arpLock.Lock()
defer arpLock.Unlock()
// Signal we parsed the ARP table at least once.
arp_parsed = true
arpWasParsed = true
// Run "arp -an" (darwin) or "ip neigh" (linux) and parse the output
output, err := core.Exec(ArpCmd, ArpCmdOpts)
if err != nil {
return arp_table, err
return arpTable, err
}
new_table := make(ArpTable)
newTable := make(ArpTable)
for _, line := range strings.Split(output, "\n") {
m := ArpTableParser.FindStringSubmatch(line)
if len(m) == ArpTableTokens {
@ -27,12 +27,12 @@ func ArpUpdate(iface string) (ArpTable, error) {
ifname := m[ArpTableTokenIndex[2]]
if ifname == iface {
new_table[address] = mac
newTable[address] = mac
}
}
}
arp_table = new_table
arpTable = newTable
return arp_table, nil
return arpTable, nil
}