mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 21:43:18 -07:00
Replace if/else by switch
This commit is contained in:
parent
b119f815d9
commit
25a2f48a02
3 changed files with 22 additions and 17 deletions
|
@ -119,14 +119,14 @@ func (d *Discovery) Show(by string, expr string) (err error) {
|
|||
} else {
|
||||
targets = d.Session.Lan.List()
|
||||
}
|
||||
|
||||
if by == "seen" {
|
||||
switch by {
|
||||
case "seen":
|
||||
sort.Sort(BySeenSorter(targets))
|
||||
} else if by == "sent" {
|
||||
case "sent":
|
||||
sort.Sort(BySentSorter(targets))
|
||||
} else if by == "rcvd" {
|
||||
case "rcvd":
|
||||
sort.Sort(ByRcvdSorter(targets))
|
||||
} else {
|
||||
default:
|
||||
sort.Sort(ByAddressSorter(targets))
|
||||
}
|
||||
|
||||
|
|
|
@ -123,14 +123,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