mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
29 lines
417 B
Go
29 lines
417 B
Go
package clientinfo
|
|
|
|
import (
|
|
"bufio"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
const procNetArpFile = "/proc/net/arp"
|
|
|
|
func (a *arpDiscover) scan() {
|
|
f, err := os.Open(procNetArpFile)
|
|
if err != nil {
|
|
return
|
|
}
|
|
defer f.Close()
|
|
|
|
s := bufio.NewScanner(f)
|
|
s.Scan() // skip header
|
|
for s.Scan() {
|
|
line := s.Text()
|
|
fields := strings.Fields(line)
|
|
ip := fields[0]
|
|
mac := fields[3]
|
|
a.mac.Store(ip, mac)
|
|
a.ip.Store(mac, ip)
|
|
}
|
|
}
|