MCPcopy
hub / github.com/nextdns/nextdns / Get

Function Get

ndp/ndp_unix.go:12–43  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10)
11
12func Get() (Table, error) {
13 data, err := exec.Command("ndp", "-an").Output()
14 if err != nil {
15 return nil, err
16 }
17
18 var t Table
19 header := true
20 for line := range strings.SplitSeq(string(data), "\n") {
21 if header {
22 header = false
23 continue
24 }
25 fields := strings.Fields(line)
26 if len(fields) < 2 {
27 continue
28 }
29
30 if mac := parseMAC(fields[1]); mac != nil {
31 ip := fields[0]
32 if idx := strings.IndexByte(ip, '%'); idx != -1 {
33 ip = ip[:idx]
34 }
35 t = append(t, Entry{
36 IP: net.ParseIP(ip),
37 MAC: mac,
38 })
39 }
40 }
41
42 return t, nil
43}

Callers 1

getMethod · 0.70

Calls 2

CommandMethod · 0.80
parseMACFunction · 0.70

Tested by

no test coverage detected