mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 18:57:17 -07:00
Refactoring modules
This commit is contained in:
parent
c0d3c314fc
commit
ed652622e2
89 changed files with 186 additions and 138 deletions
50
modules/net_sniff/net_sniff_stats.go
Normal file
50
modules/net_sniff/net_sniff_stats.go
Normal file
|
@ -0,0 +1,50 @@
|
|||
package net_sniff
|
||||
|
||||
import (
|
||||
"github.com/bettercap/bettercap/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() {
|
||||
first = s.FirstPacket.String()
|
||||
}
|
||||
if !s.LastPacket.IsZero() {
|
||||
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