mirror of
https://github.com/bettercap/bettercap.git
synced 2025-03-12 04:36:03 -07:00
fix: fixed packets queue stats
This commit is contained in:
parent
d030ccb5ed
commit
656b633023
@ -14,8 +14,9 @@ import (
|
||||
)
|
||||
|
||||
type Activity struct {
|
||||
IP net.IP
|
||||
MAC net.HardwareAddr
|
||||
IP net.IP
|
||||
MAC net.HardwareAddr
|
||||
Source bool
|
||||
}
|
||||
|
||||
type Queue struct {
|
||||
@ -94,15 +95,17 @@ func (q *Queue) worker() {
|
||||
|
||||
if bytes.Compare(q.iface.IP, ip4.SrcIP) != 0 && q.iface.Net.Contains(ip4.SrcIP) {
|
||||
q.Activities <- Activity{
|
||||
IP: ip4.SrcIP,
|
||||
MAC: eth.SrcMAC,
|
||||
IP: ip4.SrcIP,
|
||||
MAC: eth.SrcMAC,
|
||||
Source: true,
|
||||
}
|
||||
}
|
||||
|
||||
if bytes.Compare(q.iface.IP, ip4.DstIP) != 0 && q.iface.Net.Contains(ip4.DstIP) {
|
||||
q.Activities <- Activity{
|
||||
IP: ip4.DstIP,
|
||||
MAC: eth.SrcMAC,
|
||||
IP: ip4.DstIP,
|
||||
MAC: eth.SrcMAC,
|
||||
Source: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/chzyer/readline"
|
||||
|
||||
@ -231,9 +232,15 @@ func (s *Session) Start() error {
|
||||
// keep reading network events in order to add / update endpoints
|
||||
go func() {
|
||||
for event := range s.Queue.Activities {
|
||||
addr := event.IP.String()
|
||||
mac := event.MAC.String()
|
||||
s.Targets.AddIfNotExist(addr, mac)
|
||||
if event.Source == true {
|
||||
addr := event.IP.String()
|
||||
mac := event.MAC.String()
|
||||
|
||||
existing := s.Targets.AddIfNotExist(addr, mac)
|
||||
if existing != nil {
|
||||
existing.LastSeen = time.Now()
|
||||
}
|
||||
}
|
||||
|
||||
if s.Active == false {
|
||||
return
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/evilsocket/bettercap-ng/core"
|
||||
"github.com/evilsocket/bettercap-ng/net"
|
||||
@ -64,7 +63,6 @@ func (tp *Targets) AddIfNotExist(ip, mac string) *net.Endpoint {
|
||||
}
|
||||
|
||||
if t, found := tp.Targets[mac]; found {
|
||||
t.LastSeen = time.Now()
|
||||
return t
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user