new: the RSSI column in wifi.show is colored according to signal strength

This commit is contained in:
evilsocket 2019-02-11 14:20:04 +01:00
commit 5315784f8a
No known key found for this signature in database
GPG key ID: 1564D7F30393A456

View file

@ -22,11 +22,21 @@ func (w *WiFiModule) isApSelected() bool {
} }
func (w *WiFiModule) getRow(station *network.Station) ([]string, bool) { func (w *WiFiModule) getRow(station *network.Station) ([]string, bool) {
include := false // ref. https://www.metageek.com/training/resources/understanding-rssi-2.html
sinceStarted := time.Since(w.Session.StartedAt) rssi := fmt.Sprintf("%d dBm", station.RSSI)
sinceFirstSeen := time.Since(station.FirstSeen) if station.RSSI >= -67 {
rssi = tui.Green(rssi)
} else if station.RSSI >= -70 {
rssi = tui.Dim(tui.Green(rssi))
} else if station.RSSI >= -80 {
rssi = tui.Yellow(rssi)
} else {
rssi = tui.Dim(tui.Red(rssi))
}
bssid := station.HwAddress bssid := station.HwAddress
sinceStarted := time.Since(w.Session.StartedAt)
sinceFirstSeen := time.Since(station.FirstSeen)
if sinceStarted > (discovery.JustJoinedTimeInterval*2) && sinceFirstSeen <= discovery.JustJoinedTimeInterval { if sinceStarted > (discovery.JustJoinedTimeInterval*2) && sinceFirstSeen <= discovery.JustJoinedTimeInterval {
// if endpoint was first seen in the last 10 seconds // if endpoint was first seen in the last 10 seconds
bssid = tui.Bold(bssid) bssid = tui.Bold(bssid)
@ -65,6 +75,7 @@ func (w *WiFiModule) getRow(station *network.Station) ([]string, bool) {
sent := ops.Ternary(station.Sent > 0, humanize.Bytes(station.Sent), "").(string) sent := ops.Ternary(station.Sent > 0, humanize.Bytes(station.Sent), "").(string)
recvd := ops.Ternary(station.Received > 0, humanize.Bytes(station.Received), "").(string) recvd := ops.Ternary(station.Received > 0, humanize.Bytes(station.Received), "").(string)
include := false
if w.source == "" { if w.source == "" {
for _, frequencies := range w.frequencies { for _, frequencies := range w.frequencies {
if frequencies == station.Frequency { if frequencies == station.Frequency {
@ -76,9 +87,13 @@ func (w *WiFiModule) getRow(station *network.Station) ([]string, bool) {
include = true include = true
} }
if int(station.RSSI) < w.minRSSI {
include = false
}
if w.isApSelected() { if w.isApSelected() {
return []string{ return []string{
fmt.Sprintf("%d dBm", station.RSSI), rssi,
bssid, bssid,
strconv.Itoa(station.Channel()), strconv.Itoa(station.Channel()),
sent, sent,
@ -114,7 +129,7 @@ func (w *WiFiModule) getRow(station *network.Station) ([]string, bool) {
} }
return []string{ return []string{
fmt.Sprintf("%d dBm", station.RSSI), rssi,
bssid, bssid,
ssid, ssid,
encryption, encryption,