mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 13:09:49 -07:00
new: the RSSI column in wifi.show is colored according to signal strength
This commit is contained in:
parent
261789d592
commit
5315784f8a
1 changed files with 20 additions and 5 deletions
|
@ -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,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue