diff --git a/modules/wifi_show.go b/modules/wifi_show.go index 7f3f7207..a4c0be8f 100644 --- a/modules/wifi_show.go +++ b/modules/wifi_show.go @@ -279,16 +279,32 @@ func (w *WiFiModule) Show() (err error) { tui.Table(os.Stdout, w.colNames(nrows), rows) } + numHandshakes := w.Session.WiFi.NumHandshakes() + w.Session.Queue.Stats.RLock() - fmt.Printf("\n%s (ch. %d) / %s %s / %s %s / %d pkts / %d errs\n\n", - w.Session.Interface.Name(), - network.GetInterfaceChannel(w.Session.Interface.Name()), - tui.Red("↑"), - humanize.Bytes(w.Session.Queue.Stats.Sent), - tui.Green("↓"), - humanize.Bytes(w.Session.Queue.Stats.Received), - w.Session.Queue.Stats.PktReceived, - w.Session.Queue.Stats.Errors) + + if numHandshakes > 0 { + fmt.Printf("\n%s (ch. %d) / %s %s / %s %s / %d pkts / %d errs / %d handshakes\n\n", + w.Session.Interface.Name(), + network.GetInterfaceChannel(w.Session.Interface.Name()), + tui.Red("↑"), + humanize.Bytes(w.Session.Queue.Stats.Sent), + tui.Green("↓"), + humanize.Bytes(w.Session.Queue.Stats.Received), + w.Session.Queue.Stats.PktReceived, + w.Session.Queue.Stats.Errors, + numHandshakes) + } else { + fmt.Printf("\n%s (ch. %d) / %s %s / %s %s / %d pkts / %d errs\n\n", + w.Session.Interface.Name(), + network.GetInterfaceChannel(w.Session.Interface.Name()), + tui.Red("↑"), + humanize.Bytes(w.Session.Queue.Stats.Sent), + tui.Green("↓"), + humanize.Bytes(w.Session.Queue.Stats.Received), + w.Session.Queue.Stats.PktReceived, + w.Session.Queue.Stats.Errors) + } w.Session.Queue.Stats.RUnlock() w.Session.Refresh() diff --git a/network/wifi.go b/network/wifi.go index 79b95921..0d265856 100644 --- a/network/wifi.go +++ b/network/wifi.go @@ -182,6 +182,22 @@ func (w *WiFi) Clear() error { return nil } +func (w *WiFi) NumHandshakes() int { + w.Lock() + defer w.Unlock() + + sum := 0 + for _, ap := range w.aps { + for _, station := range ap.Clients() { + if station.Handshake.Complete() { + sum++ + } + } + } + + return sum +} + func (w *WiFi) SaveHandshakesTo(fileName string, linkType layers.LinkType) error { w.Lock() defer w.Unlock() diff --git a/network/wifi_ap.go b/network/wifi_ap.go index ff2f67ec..9ff5ec4a 100644 --- a/network/wifi_ap.go +++ b/network/wifi_ap.go @@ -97,15 +97,21 @@ func (ap *AccessPoint) Clients() (list []*Station) { return } -func (ap *AccessPoint) HasHandshakes() bool { +func (ap *AccessPoint) NumHandshakes() int { ap.Lock() defer ap.Unlock() + sum := 0 + for _, c := range ap.clients { if c.Handshake.Complete() { - return true + sum++ } } - return false + return sum +} + +func (ap *AccessPoint) HasHandshakes() bool { + return ap.NumHandshakes() > 0 }