internal/clientinfo: add NDP discovery

This commit is contained in:
Cuong Manh Le authored and Cuong Manh Le committed 2024-01-22 23:05:44 +07:00
1 parent 4d996e317b
commit cb445825f4
5 files changed
+266 -8

No files matched your search

+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)
}
}