new: new net.show.meta boolean flag to enable or disable endpoints metainfo rendering

This commit is contained in:
evilsocket 2018-09-09 20:24:49 +03:00
commit 9f64372273
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
2 changed files with 15 additions and 4 deletions

View file

@ -29,6 +29,10 @@ func NewDiscovery(s *session.Session) *Discovery {
return d.Stop()
}))
d.AddParam(session.NewBoolParameter("net.show.meta",
"true",
"If true, the net.show command will show all metadata collected about each endpoint."))
d.AddHandler(session.NewModuleHandler("net.show", "",
"Show cache hosts list (default sorting by ip).",
func(args []string) error {

View file

@ -110,6 +110,11 @@ func (d *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string {
}
func (d *Discovery) Show(by string, addr string) error {
err, showMeta := d.BoolParam("net.show.meta")
if err != nil {
return err
}
targets := d.Session.Lan.List()
if by == "seen" {
sort.Sort(BySeenSorter(targets))
@ -141,10 +146,12 @@ func (d *Discovery) Show(by string, addr string) error {
}
hasMeta := false
for _, t := range targets {
if !t.Meta.Empty() {
hasMeta = true
break
if showMeta {
for _, t := range targets {
if !t.Meta.Empty() {
hasMeta = true
break
}
}
}