Debian Codegraph @

modules/net_sniff/net_sniff_event.go

raw symbols SCIP
1 package net_sniff
2
3 import (
4 "fmt"
5 "time"
6
7 "github.com/bettercap/bettercap/session"
8 )
9
10 type SniffData map[string]interface{}
11
12 type SnifferEvent struct {
13 PacketTime time.Time `json:"time"`
14 Protocol string `json:"protocol"`
15 Source string `json:"from"`
16 Destination string `json:"to"`
17 Message string `json:"message"`
18 Data interface{} `json:"data"`
19 }
20
21 func NewSnifferEvent(t time.Time, proto string, src string, dst string, data interface{}, format string, args ...interface{}) SnifferEvent {
22 return SnifferEvent{
23 PacketTime: t,
24 Protocol: proto,
25 Source: src,
26 Destination: dst,
27 Message: fmt.Sprintf(format, args...),
28 Data: data,
29 }
30 }
31
32 func (e SnifferEvent) Push() {
33 session.I.Events.Add("net.sniff."+e.Protocol, e)
34 session.I.Refresh()
35 }