mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 10:46:57 -07:00
new: implemented traffic column for wifi.recon module (ref #53)
This commit is contained in:
parent
9470926388
commit
c0354120d8
2 changed files with 87 additions and 1 deletions
44
modules/wifi_stats.go
Normal file
44
modules/wifi_stats.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package modules
|
||||
|
||||
import (
|
||||
"net"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type WiFiStationStats struct {
|
||||
Bytes uint64
|
||||
}
|
||||
|
||||
type WiFiStats struct {
|
||||
sync.Mutex
|
||||
stats map[string]*WiFiStationStats
|
||||
}
|
||||
|
||||
func NewWiFiStats() *WiFiStats {
|
||||
return &WiFiStats{
|
||||
stats: make(map[string]*WiFiStationStats),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *WiFiStats) Collect(station net.HardwareAddr, bytes uint64) {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
|
||||
bssid := station.String()
|
||||
if sstats, found := s.stats[bssid]; found == true {
|
||||
sstats.Bytes += bytes
|
||||
} else {
|
||||
s.stats[bssid] = &WiFiStationStats{Bytes: bytes}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *WiFiStats) For(station net.HardwareAddr) uint64 {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
|
||||
bssid := station.String()
|
||||
if sstats, found := s.stats[bssid]; found == true {
|
||||
return sstats.Bytes
|
||||
}
|
||||
return 0
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue