mirror of
https://github.com/bettercap/bettercap
synced 2025-07-13 08:33:48 -07:00
refact: starting refactoring new.show sorting in separate file
This commit is contained in:
parent
97c97a668a
commit
1367663aa1
2 changed files with 12 additions and 7 deletions
|
@ -153,12 +153,6 @@ func (d *Discovery) Start() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
type tSorter []*net.Endpoint
|
||||
|
||||
func (a tSorter) Len() int { return len(a) }
|
||||
func (a tSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a tSorter) Less(i, j int) bool { return a[i].IpAddressUint32 < a[j].IpAddressUint32 }
|
||||
|
||||
func rankByProtoHits(protos map[string]uint64) (ProtoPairList, uint64) {
|
||||
pl := make(ProtoPairList, len(protos))
|
||||
max := uint64(0)
|
||||
|
@ -216,7 +210,7 @@ func (d *Discovery) Show() error {
|
|||
targets = append(targets, t)
|
||||
}
|
||||
|
||||
sort.Sort(tSorter(targets))
|
||||
sort.Sort(ByAddressSorter(targets))
|
||||
|
||||
data = make([][]string, nTargets)
|
||||
for i, t := range targets {
|
||||
|
|
11
modules/net_recon_sort.go
Normal file
11
modules/net_recon_sort.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
package modules
|
||||
|
||||
import (
|
||||
"github.com/evilsocket/bettercap-ng/net"
|
||||
)
|
||||
|
||||
type ByAddressSorter []*net.Endpoint
|
||||
|
||||
func (a ByAddressSorter) Len() int { return len(a) }
|
||||
func (a ByAddressSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByAddressSorter) Less(i, j int) bool { return a[i].IpAddressUint32 < a[j].IpAddressUint32 }
|
Loading…
Add table
Add a link
Reference in a new issue