mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 21:43:18 -07:00
refact: refactored sniffer to allow several parsers
This commit is contained in:
parent
74867aaae4
commit
55b9b1f189
5 changed files with 235 additions and 180 deletions
51
modules/net_sniff_stats.go
Normal file
51
modules/net_sniff_stats.go
Normal file
|
@ -0,0 +1,51 @@
|
|||
package modules
|
||||
|
||||
import (
|
||||
"github.com/evilsocket/bettercap-ng/log"
|
||||
"time"
|
||||
)
|
||||
|
||||
type SnifferStats struct {
|
||||
NumLocal uint64
|
||||
NumMatched uint64
|
||||
NumDumped uint64
|
||||
NumWrote uint64
|
||||
Started time.Time
|
||||
FirstPacket time.Time
|
||||
LastPacket time.Time
|
||||
}
|
||||
|
||||
func NewSnifferStats() *SnifferStats {
|
||||
return &SnifferStats{
|
||||
NumLocal: 0,
|
||||
NumMatched: 0,
|
||||
NumDumped: 0,
|
||||
NumWrote: 0,
|
||||
Started: time.Now(),
|
||||
FirstPacket: time.Time{},
|
||||
LastPacket: time.Time{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SnifferStats) Print() error {
|
||||
first := "never"
|
||||
last := "never"
|
||||
|
||||
if s.FirstPacket.IsZero() == false {
|
||||
first = s.FirstPacket.String()
|
||||
}
|
||||
|
||||
if s.LastPacket.IsZero() == false {
|
||||
last = s.LastPacket.String()
|
||||
}
|
||||
|
||||
log.Info("Sniffer Started : %s", s.Started)
|
||||
log.Info("First Packet Seen : %s", first)
|
||||
log.Info("Last Packet Seen : %s", last)
|
||||
log.Info("Local Packets : %d", s.NumLocal)
|
||||
log.Info("Matched Packets : %d", s.NumMatched)
|
||||
log.Info("Dumped Packets : %d", s.NumDumped)
|
||||
log.Info("Wrote Packets : %d", s.NumWrote)
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue