mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 10:46:57 -07:00
Refactoring modules
This commit is contained in:
parent
c0d3c314fc
commit
ed652622e2
89 changed files with 186 additions and 138 deletions
35
modules/net_sniff/net_sniff_event.go
Normal file
35
modules/net_sniff/net_sniff_event.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package net_sniff
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/bettercap/bettercap/session"
|
||||
)
|
||||
|
||||
type SniffData map[string]interface{}
|
||||
|
||||
type SnifferEvent struct {
|
||||
PacketTime time.Time `json:"time"`
|
||||
Protocol string `json:"protocol"`
|
||||
Source string `json:"from"`
|
||||
Destination string `json:"to"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
func NewSnifferEvent(t time.Time, proto string, src string, dst string, data interface{}, format string, args ...interface{}) SnifferEvent {
|
||||
return SnifferEvent{
|
||||
PacketTime: t,
|
||||
Protocol: proto,
|
||||
Source: src,
|
||||
Destination: dst,
|
||||
Message: fmt.Sprintf(format, args...),
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
|
||||
func (e SnifferEvent) Push() {
|
||||
session.I.Events.Add("net.sniff."+e.Protocol, e)
|
||||
session.I.Refresh()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue