misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
evilsocket 2018-02-17 02:52:43 +01:00
parent 620f5291a6
commit b80bd4e1e2
2 changed files with 31 additions and 30 deletions

View file

@ -0,0 +1,31 @@
package modules
type ByChannelSorter []*WiFiStation
func (a ByChannelSorter) Len() int { return len(a) }
func (a ByChannelSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByChannelSorter) Less(i, j int) bool {
if a[i].Channel == a[j].Channel {
return a[i].HwAddress < a[j].HwAddress
}
return a[i].Channel < a[j].Channel
}
type ByEssidSorter []*WiFiStation
func (a ByEssidSorter) Len() int { return len(a) }
func (a ByEssidSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByEssidSorter) Less(i, j int) bool {
if a[i].ESSID() == a[j].ESSID() {
return a[i].HwAddress < a[j].HwAddress
}
return a[i].ESSID() < a[j].ESSID()
}
type BywifiSeenSorter []*WiFiStation
func (a BywifiSeenSorter) Len() int { return len(a) }
func (a BywifiSeenSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a BywifiSeenSorter) Less(i, j int) bool {
return a[i].LastSeen.After(a[j].LastSeen)
}