internal/clientinfo: add NDP discovery

This commit is contained in:
Cuong Manh Le
2024-01-04 00:23:41 +07:00
committed by Cuong Manh Le
parent 4d996e317b
commit cb445825f4
5 changed files with 266 additions and 8 deletions
+24
View File
@@ -0,0 +1,24 @@
package clientinfo
import (
"github.com/vishvananda/netlink"
"github.com/Control-D-Inc/ctrld"
)
// scan populates NDP table using information from system mappings.
func (nd *ndpDiscover) scan() {
neighs, err := netlink.NeighList(0, netlink.FAMILY_V6)
if err != nil {
ctrld.ProxyLogger.Load().Warn().Err(err).Msg("could not get neigh list")
return
}
for _, n := range neighs {
ip := n.IP.String()
mac := n.HardwareAddr.String()
nd.mac.Store(ip, mac)
nd.ip.Store(mac, ip)
}
}