mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 10:46:57 -07:00
fix: better way of printing events
This commit is contained in:
parent
8e8e529744
commit
bcdfcca047
4 changed files with 47 additions and 22 deletions
43
modules/events_view.go
Normal file
43
modules/events_view.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package modules
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/evilsocket/bettercap-ng/core"
|
||||
"github.com/evilsocket/bettercap-ng/session"
|
||||
)
|
||||
|
||||
const eventTimeFormat = "2006-01-02 15:04:05"
|
||||
|
||||
func (s EventsStream) viewLogEvent(e session.Event) {
|
||||
fmt.Printf("[%s] [%s] (%s) %s\n",
|
||||
e.Time.Format(eventTimeFormat),
|
||||
core.Green(e.Tag),
|
||||
e.Label(),
|
||||
e.Data.(session.LogMessage).Message)
|
||||
}
|
||||
|
||||
func (s EventsStream) viewSnifferEvent(e session.Event) {
|
||||
se := e.Data.(SnifferEvent)
|
||||
fmt.Printf("[%s] [%s] %s > %s | %v\n",
|
||||
e.Time.Format(eventTimeFormat),
|
||||
core.Green(e.Tag),
|
||||
se.Source,
|
||||
se.Destination,
|
||||
se.Data)
|
||||
}
|
||||
|
||||
func (s *EventsStream) view(e session.Event) {
|
||||
if s.filter == "" || strings.Contains(e.Tag, s.filter) {
|
||||
if e.Tag == "sys.log" {
|
||||
s.viewLogEvent(e)
|
||||
} else if strings.HasPrefix(e.Tag, "net.sniff.") {
|
||||
s.viewSnifferEvent(e)
|
||||
} else {
|
||||
fmt.Printf("[%s] [%s] %v\n", e.Time.Format(eventTimeFormat), core.Green(e.Tag), e)
|
||||
}
|
||||
|
||||
s.Session.Refresh()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue