fix: allow wifi modules to use network aliases for clients never seen on lan

This commit is contained in:
evilsocket 2019-03-17 14:01:30 +01:00
commit 255102c250
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
5 changed files with 15 additions and 10 deletions

View file

@ -4,6 +4,8 @@ import (
"encoding/json"
"sync"
"time"
"github.com/evilsocket/islazy/data"
)
type AccessPoint struct {
@ -65,7 +67,7 @@ func (ap *AccessPoint) RemoveClient(mac string) {
}
}
func (ap *AccessPoint) AddClientIfNew(bssid string, frequency int, rssi int8) (*Station, bool) {
func (ap *AccessPoint) AddClientIfNew(bssid string, frequency int, rssi int8, aliases *data.UnsortedKV) (*Station, bool) {
ap.Lock()
defer ap.Unlock()
@ -77,10 +79,17 @@ func (ap *AccessPoint) AddClientIfNew(bssid string, frequency int, rssi int8) (*
s.RSSI = rssi
s.LastSeen = time.Now()
if aliases != nil {
s.Alias = aliases.GetOr(bssid, "")
}
return s, false
}
s := NewStation("", bssid, frequency, rssi)
if aliases != nil {
s.Alias = aliases.GetOr(bssid, "")
}
ap.clients[bssid] = s
return s, true