mirror of
https://github.com/bettercap/bettercap
synced 2025-08-21 05:53:20 -07:00
new: better net.show output
This commit is contained in:
parent
3e15e13027
commit
7965cece7f
4 changed files with 105 additions and 45 deletions
|
@ -23,6 +23,14 @@ func NewTargets(s *Session, iface, gateway *net.Endpoint) *Targets {
|
|||
}
|
||||
}
|
||||
|
||||
func (tp *Targets) Lock() {
|
||||
tp.lock.Lock()
|
||||
}
|
||||
|
||||
func (tp *Targets) Unlock() {
|
||||
tp.lock.Unlock()
|
||||
}
|
||||
|
||||
func (tp *Targets) Remove(ip, mac string) {
|
||||
tp.lock.Lock()
|
||||
defer tp.lock.Unlock()
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/evilsocket/bettercap-ng/core"
|
||||
"github.com/evilsocket/bettercap-ng/net"
|
||||
)
|
||||
|
||||
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 (tp *Targets) Dump() {
|
||||
tp.lock.Lock()
|
||||
defer tp.lock.Unlock()
|
||||
|
||||
fmt.Println()
|
||||
fmt.Printf(" " + core.GREEN + "interface" + core.RESET + "\n\n")
|
||||
fmt.Printf(" " + tp.Interface.String() + "\n")
|
||||
fmt.Println()
|
||||
fmt.Printf(" " + core.GREEN + "gateway" + core.RESET + "\n\n")
|
||||
fmt.Printf(" " + tp.Gateway.String() + "\n")
|
||||
|
||||
if len(tp.Targets) > 0 {
|
||||
fmt.Println()
|
||||
fmt.Printf(" " + core.GREEN + "hosts" + core.RESET + "\n\n")
|
||||
targets := make([]*net.Endpoint, 0, len(tp.Targets))
|
||||
for _, t := range tp.Targets {
|
||||
targets = append(targets, t)
|
||||
}
|
||||
|
||||
sort.Sort(tSorter(targets))
|
||||
|
||||
for _, t := range targets {
|
||||
fmt.Println(" " + t.String())
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue