mirror of
https://github.com/bettercap/bettercap
synced 2025-07-16 10:03:39 -07:00
fix: fixed the way endpoints metas are rendered on the net.show table
This commit is contained in:
parent
798df7e32f
commit
a58d59d4cb
1 changed files with 24 additions and 12 deletions
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/bettercap/bettercap/core"
|
||||||
|
@ -31,7 +30,7 @@ func (p ProtoPairList) Len() int { return len(p) }
|
||||||
func (p ProtoPairList) Less(i, j int) bool { return p[i].Hits < p[j].Hits }
|
func (p ProtoPairList) Less(i, j int) bool { return p[i].Hits < p[j].Hits }
|
||||||
func (p ProtoPairList) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
func (p ProtoPairList) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||||
|
|
||||||
func (d *Discovery) getRow(e *network.Endpoint, withMeta bool) []string {
|
func (d *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string {
|
||||||
sinceStarted := time.Since(d.Session.StartedAt)
|
sinceStarted := time.Since(d.Session.StartedAt)
|
||||||
sinceFirstSeen := time.Since(e.FirstSeen)
|
sinceFirstSeen := time.Since(e.FirstSeen)
|
||||||
|
|
||||||
|
@ -86,17 +85,28 @@ func (d *Discovery) getRow(e *network.Endpoint, withMeta bool) []string {
|
||||||
seen,
|
seen,
|
||||||
}
|
}
|
||||||
|
|
||||||
if withMeta {
|
if !withMeta {
|
||||||
metas := []string{}
|
return [][]string{row}
|
||||||
e.Meta.Each(func(name string, value interface{}) {
|
} else if e.Meta.Empty() {
|
||||||
metas = append(metas, fmt.Sprintf("%s=%s", core.Bold(name), core.Yellow(value.(string))))
|
return [][]string{append(row, core.Dim("-"))}
|
||||||
})
|
|
||||||
|
|
||||||
sort.Strings(metas)
|
|
||||||
row = append(row, strings.Join(metas, ", "))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return row
|
metas := []string{}
|
||||||
|
e.Meta.Each(func(name string, value interface{}) {
|
||||||
|
metas = append(metas, fmt.Sprintf("%s:%s", core.Green(name), core.Yellow(value.(string))))
|
||||||
|
})
|
||||||
|
sort.Strings(metas)
|
||||||
|
|
||||||
|
rows := [][]string{}
|
||||||
|
for i, m := range metas {
|
||||||
|
if i == 0 {
|
||||||
|
rows = append(rows, append(row, m))
|
||||||
|
} else {
|
||||||
|
rows = append(rows, []string{"", "", "", "", "", "", "", m})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rows
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Discovery) Show(by string) error {
|
func (d *Discovery) Show(by string) error {
|
||||||
|
@ -136,7 +146,9 @@ func (d *Discovery) Show(by string) error {
|
||||||
|
|
||||||
rows := make([][]string, 0)
|
rows := make([][]string, 0)
|
||||||
for i, t := range targets {
|
for i, t := range targets {
|
||||||
rows = append(rows, d.getRow(t, hasMeta))
|
for _, r := range d.getRow(t, hasMeta) {
|
||||||
|
rows = append(rows, r)
|
||||||
|
}
|
||||||
if i == pad {
|
if i == pad {
|
||||||
rows = append(rows, padCols)
|
rows = append(rows, padCols)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue