Debian Codegraph @

modules/net_sniff/net_sniff_stats.go

raw symbols SCIP
1 package net_sniff
2
3 import (
4 "github.com/bettercap/bettercap/log"
5 "time"
6 )
7
8 type SnifferStats struct {
9 NumLocal uint64
10 NumMatched uint64
11 NumDumped uint64
12 NumWrote uint64
13 Started time.Time
14 FirstPacket time.Time
15 LastPacket time.Time
16 }
17
18 func NewSnifferStats() *SnifferStats {
19 return &SnifferStats{
20 NumLocal: 0,
21 NumMatched: 0,
22 NumDumped: 0,
23 NumWrote: 0,
24 Started: time.Now(),
25 FirstPacket: time.Time{},
26 LastPacket: time.Time{},
27 }
28 }
29
30 func (s *SnifferStats) Print() error {
31 first := "never"
32 last := "never"
33
34 if !s.FirstPacket.IsZero() {
35 first = s.FirstPacket.String()
36 }
37 if !s.LastPacket.IsZero() {
38 last = s.LastPacket.String()
39 }
40
41 log.Info("Sniffer Started : %s", s.Started)
42 log.Info("First Packet Seen : %s", first)
43 log.Info("Last Packet Seen : %s", last)
44 log.Info("Local Packets : %d", s.NumLocal)
45 log.Info("Matched Packets : %d", s.NumMatched)
46 log.Info("Dumped Packets : %d", s.NumDumped)
47 log.Info("Wrote Packets : %d", s.NumWrote)
48
49 return nil
50 }