mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 13:33:21 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
d62090267e
commit
7f68d0d82c
4 changed files with 19 additions and 19 deletions
33
modules/ble/ble_show_sort.go
Normal file
33
modules/ble/ble_show_sort.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
// +build !windows
|
||||
// +build !darwin
|
||||
|
||||
package ble
|
||||
|
||||
import (
|
||||
"github.com/bettercap/bettercap/network"
|
||||
)
|
||||
|
||||
type ByBLERSSISorter []*network.BLEDevice
|
||||
|
||||
func (a ByBLERSSISorter) Len() int { return len(a) }
|
||||
func (a ByBLERSSISorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByBLERSSISorter) Less(i, j int) bool {
|
||||
if a[i].RSSI == a[j].RSSI {
|
||||
return a[i].Device.ID() < a[j].Device.ID()
|
||||
}
|
||||
return a[i].RSSI > a[j].RSSI
|
||||
}
|
||||
|
||||
type ByBLEMacSorter []*network.BLEDevice
|
||||
|
||||
func (a ByBLEMacSorter) Len() int { return len(a) }
|
||||
func (a ByBLEMacSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByBLEMacSorter) Less(i, j int) bool {
|
||||
return a[i].Device.ID() < a[j].Device.ID()
|
||||
}
|
||||
|
||||
type ByBLESeenSorter []*network.BLEDevice
|
||||
|
||||
func (a ByBLESeenSorter) Len() int { return len(a) }
|
||||
func (a ByBLESeenSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByBLESeenSorter) Less(i, j int) bool { return a[i].LastSeen.Before(a[j].LastSeen) }
|
Loading…
Add table
Add a link
Reference in a new issue