mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
fix: yet another fix for macOS bogus wifi error correction
This commit is contained in:
parent
8365904ed5
commit
3dd39e4dc4
1 changed files with 17 additions and 0 deletions
|
@ -2,6 +2,7 @@ package network
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
@ -86,6 +87,18 @@ func (w *WiFi) Remove(mac string) {
|
|||
}
|
||||
}
|
||||
|
||||
// when iface is in monitor mode, error
|
||||
// correction on macOS is crap and we
|
||||
// get non printable characters .... (ref #61)
|
||||
func isBogusMacESSID(essid string) bool {
|
||||
for _, c := range essid {
|
||||
if strconv.IsPrint(c) == false {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (w *WiFi) AddIfNew(ssid, mac string, frequency int, rssi int8) *AccessPoint {
|
||||
w.Lock()
|
||||
defer w.Unlock()
|
||||
|
@ -94,6 +107,10 @@ func (w *WiFi) AddIfNew(ssid, mac string, frequency int, rssi int8) *AccessPoint
|
|||
if ap, found := w.aps[mac]; found {
|
||||
ap.LastSeen = time.Now()
|
||||
ap.RSSI = rssi
|
||||
// always get the cleanest one
|
||||
if isBogusMacESSID(ssid) == false {
|
||||
ap.Hostname = ssid
|
||||
}
|
||||
return ap
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue