Improving Mac discovery

This commit is contained in:
Cuong Manh Le
2023-08-09 23:54:23 +07:00
committed by Cuong Manh Le
parent 3007cb86ec
commit 76d2e2c226
22 changed files with 1229 additions and 291 deletions
+29
View File
@@ -0,0 +1,29 @@
package clientinfo
import "sync"
type arpDiscover struct {
mac sync.Map // ip => mac
ip sync.Map // mac => ip
}
func (a *arpDiscover) refresh() error {
a.scan()
return nil
}
func (a *arpDiscover) LookupIP(mac string) string {
val, ok := a.ip.Load(mac)
if !ok {
return ""
}
return val.(string)
}
func (a *arpDiscover) LookupMac(ip string) string {
val, ok := a.mac.Load(ip)
if !ok {
return ""
}
return val.(string)
}