new: net.show.filter, net.show.limit, net.show.sort and net.show.sort_by parameters to control net.show

This commit is contained in:
evilsocket 2019-01-23 20:03:01 +01:00
commit 28f8586abb
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
4 changed files with 178 additions and 29 deletions

View file

@ -17,11 +17,27 @@ func (a ByAddressSorter) Less(i, j int) bool {
return a[i].IpAddressUint32 < a[j].IpAddressUint32
}
type ByIpSorter []*network.Endpoint
func (a ByIpSorter) Len() int { return len(a) }
func (a ByIpSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByIpSorter) Less(i, j int) bool {
return a[i].IpAddressUint32 < a[j].IpAddressUint32
}
type ByMacSorter []*network.Endpoint
func (a ByMacSorter) Len() int { return len(a) }
func (a ByMacSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByMacSorter) Less(i, j int) bool {
return a[i].HwAddress < a[j].HwAddress
}
type BySeenSorter []*network.Endpoint
func (a BySeenSorter) Len() int { return len(a) }
func (a BySeenSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a BySeenSorter) Less(i, j int) bool { return a[i].LastSeen.After(a[j].LastSeen) }
func (a BySeenSorter) Less(i, j int) bool { return a[i].LastSeen.Before(a[j].LastSeen) }
type BySentSorter []*network.Endpoint
@ -43,7 +59,7 @@ func (a BySentSorter) Less(i, j int) bool {
bTraffic = &packets.Traffic{}
}
return bTraffic.Sent < aTraffic.Sent
return bTraffic.Sent > aTraffic.Sent
}
type ByRcvdSorter []*network.Endpoint
@ -66,5 +82,5 @@ func (a ByRcvdSorter) Less(i, j int) bool {
bTraffic = &packets.Traffic{}
}
return bTraffic.Received < aTraffic.Received
return bTraffic.Received > aTraffic.Received
}