fix: pruning wifi clients not seen in the last 5 minutes

This commit is contained in:
evilsocket 2018-07-31 17:20:47 +02:00
parent 81fb3fe1a6
commit db30cfdd6a
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
2 changed files with 24 additions and 4 deletions

View file

@ -29,11 +29,21 @@ func (w *WiFiModule) stationPruner() {
log.Debug("WiFi stations pruner started.")
for w.Running() {
for _, s := range w.Session.WiFi.List() {
sinceLastSeen := time.Since(s.LastSeen)
// loop every AP
for _, ap := range w.Session.WiFi.List() {
sinceLastSeen := time.Since(ap.LastSeen)
if sinceLastSeen > maxStationTTL {
log.Debug("Station %s not seen in %s, removing.", s.BSSID(), sinceLastSeen)
w.Session.WiFi.Remove(s.BSSID())
log.Debug("Station %s not seen in %s, removing.", ap.BSSID(), sinceLastSeen)
w.Session.WiFi.Remove(ap.BSSID())
continue
}
// loop every AP client
for _, c := range ap.Clients() {
sinceLastSeen := time.Since(c.LastSeen)
if sinceLastSeen > maxStationTTL {
log.Debug("Client %s of station %s not seen in %s, removing.", c.String(), ap.BSSID(), sinceLastSeen)
ap.RemoveClient(c.BSSID())
}
}
}
time.Sleep(1 * time.Second)