mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
Refactor if/else and switch for the modules package
This commit is contained in:
parent
ed6d40f163
commit
191e8eacff
34 changed files with 326 additions and 199 deletions
|
@ -84,30 +84,29 @@ func (w *WiFiModule) getRow(station *network.Station) ([]string, bool) {
|
|||
recvd,
|
||||
seen,
|
||||
}, include
|
||||
} else {
|
||||
// this is ugly, but necessary in order to have this
|
||||
// method handle both access point and clients
|
||||
// transparently
|
||||
clients := ""
|
||||
if ap, found := w.Session.WiFi.Get(station.HwAddress); found {
|
||||
if ap.NumClients() > 0 {
|
||||
clients = strconv.Itoa(ap.NumClients())
|
||||
}
|
||||
}
|
||||
// this is ugly, but necessary in order to have this
|
||||
// method handle both access point and clients
|
||||
// transparently
|
||||
clients := ""
|
||||
if ap, found := w.Session.WiFi.Get(station.HwAddress); found {
|
||||
if ap.NumClients() > 0 {
|
||||
clients = strconv.Itoa(ap.NumClients())
|
||||
}
|
||||
|
||||
return []string{
|
||||
fmt.Sprintf("%d dBm", station.RSSI),
|
||||
bssid,
|
||||
ssid,
|
||||
/* station.Vendor, */
|
||||
encryption,
|
||||
strconv.Itoa(station.Channel()),
|
||||
clients,
|
||||
sent,
|
||||
recvd,
|
||||
seen,
|
||||
}, include
|
||||
}
|
||||
|
||||
return []string{
|
||||
fmt.Sprintf("%d dBm", station.RSSI),
|
||||
bssid,
|
||||
ssid,
|
||||
/* station.Vendor, */
|
||||
encryption,
|
||||
strconv.Itoa(station.Channel()),
|
||||
clients,
|
||||
sent,
|
||||
recvd,
|
||||
seen,
|
||||
}, include
|
||||
}
|
||||
|
||||
func (w *WiFiModule) Show(by string) error {
|
||||
|
@ -123,14 +122,14 @@ func (w *WiFiModule) Show(by string) error {
|
|||
} else {
|
||||
stations = w.Session.WiFi.Stations()
|
||||
}
|
||||
|
||||
if by == "seen" {
|
||||
switch by {
|
||||
case "seen":
|
||||
sort.Sort(ByWiFiSeenSorter(stations))
|
||||
} else if by == "essid" {
|
||||
case "essid":
|
||||
sort.Sort(ByEssidSorter(stations))
|
||||
} else if by == "channel" {
|
||||
case "channel":
|
||||
sort.Sort(ByChannelSorter(stations))
|
||||
} else {
|
||||
default:
|
||||
sort.Sort(ByRSSISorter(stations))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue