new: net.show now accepts an IP address parameter which, if present, will be the only endpoint listed in the table

This commit is contained in:
evilsocket 2018-09-09 16:36:25 +03:00
commit 7ef447e726
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
2 changed files with 22 additions and 5 deletions

View file

@ -109,7 +109,7 @@ func (d *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string {
return rows
}
func (d *Discovery) Show(by string) error {
func (d *Discovery) Show(by string, addr string) error {
targets := d.Session.Lan.List()
if by == "seen" {
sort.Sort(BySeenSorter(targets))
@ -129,6 +129,17 @@ func (d *Discovery) Show(by string) error {
targets = append([]*network.Endpoint{d.Session.Interface, d.Session.Gateway}, targets...)
}
if addr != "" {
tmp := make([]*network.Endpoint, 0)
pad = 0
for _, t := range targets {
if t.IP.String() == addr {
tmp = append(tmp, t)
}
}
targets = tmp
}
hasMeta := false
for _, t := range targets {
if !t.Meta.Empty() {