fix: ignoring broadcast macs on osx

This commit is contained in:
evilsocket 2018-02-20 04:04:29 +01:00
parent 0e86cf4394
commit 8ee4cad421

View file

@ -140,7 +140,7 @@ func (lan *LAN) Remove(ip, mac string) {
}
}
func (lan *LAN) shouldIgnore(ip string) bool {
func (lan *LAN) shouldIgnore(ip, mac string) bool {
// skip our own address
if ip == lan.Interface.IpAddress {
return true
@ -153,6 +153,10 @@ func (lan *LAN) shouldIgnore(ip string) bool {
if strings.HasSuffix(ip, ".255") {
return true
}
// skip broadcast macs
if strings.ToLower(mac) == "ff:ff:ff:ff:ff:ff" {
return true
}
// skip everything which is not in our subnet (multicast noise)
addr := net.ParseIP(ip)
return lan.Interface.Net.Contains(addr) == false
@ -188,7 +192,7 @@ func (lan *LAN) AddIfNew(ip, mac string) *Endpoint {
lan.Lock()
defer lan.Unlock()
if lan.shouldIgnore(ip) {
if lan.shouldIgnore(ip, mac) {
return nil
}