new: endpoints seen since less than 10 seconds are marked as bold and not seen after 1 minute are marked as dim

This commit is contained in:
evilsocket 2018-01-27 18:42:34 +01:00
commit c332250afa

View file

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"os" "os"
"sort" "sort"
"time"
"github.com/evilsocket/bettercap-ng/core" "github.com/evilsocket/bettercap-ng/core"
"github.com/evilsocket/bettercap-ng/net" "github.com/evilsocket/bettercap-ng/net"
@ -13,6 +14,11 @@ import (
"github.com/olekukonko/tablewriter" "github.com/olekukonko/tablewriter"
) )
var (
aliveTimeInterval = time.Duration(10) * time.Second
presentTimeInterval = time.Duration(1) * time.Minute
)
type ProtoPair struct { type ProtoPair struct {
Protocol string Protocol string
Hits uint64 Hits uint64
@ -89,6 +95,16 @@ func (d *Discovery) Show(by string) error {
traffic = &packets.Traffic{} traffic = &packets.Traffic{}
} }
seen := t.LastSeen.Format("15:04:05")
sinceLastSeen := time.Since(t.LastSeen)
if sinceLastSeen <= aliveTimeInterval {
seen = core.Bold(seen)
} else if sinceLastSeen <= presentTimeInterval {
} else {
seen = core.Dim(seen)
}
data[i] = []string{ data[i] = []string{
t.IpAddress, t.IpAddress,
t.HwAddress, t.HwAddress,
@ -96,7 +112,7 @@ func (d *Discovery) Show(by string) error {
t.Vendor, t.Vendor,
humanize.Bytes(traffic.Sent), humanize.Bytes(traffic.Sent),
humanize.Bytes(traffic.Received), humanize.Bytes(traffic.Received),
t.LastSeen.Format("15:04:05"), seen,
} }
} }