mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-05-27 12:52:27 +02:00
internal/clientinfo: add NDP discovery
This commit is contained in:
committed by
Cuong Manh Le
parent
4d996e317b
commit
cb445825f4
@@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user