misc: each module now has its own tagged logging

This commit is contained in:
evilsocket 2019-02-12 15:16:02 +01:00
commit 9cd4e380fb
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
47 changed files with 343 additions and 349 deletions

View file

@ -4,7 +4,6 @@ import (
"fmt"
"time"
"github.com/bettercap/bettercap/log"
"github.com/bettercap/bettercap/session"
"github.com/google/gopacket"
@ -171,7 +170,7 @@ func (s *Sniffer) Start() error {
s.pktSourceChan = src.Packets()
for packet := range s.pktSourceChan {
if !s.Running() {
log.Debug("end pkt loop (pkt=%v filter='%s')", packet, s.Ctx.Filter)
s.Debug("end pkt loop (pkt=%v filter='%s')", packet, s.Ctx.Filter)
break
}
@ -211,14 +210,14 @@ func (s *Sniffer) Start() error {
func (s *Sniffer) Stop() error {
return s.SetRunning(false, func() {
log.Debug("stopping sniffer")
s.Debug("stopping sniffer")
if s.pktSourceChan != nil {
log.Debug("sending nil")
s.Debug("sending nil")
s.pktSourceChan <- nil
log.Debug("nil sent")
s.Debug("nil sent")
}
log.Debug("closing ctx")
s.Debug("closing ctx")
s.Ctx.Close()
log.Debug("ctx closed")
s.Debug("ctx closed")
})
}

View file

@ -6,10 +6,7 @@ import (
"github.com/google/gopacket"
"github.com/bettercap/bettercap/log"
"github.com/evilsocket/islazy/str"
"github.com/evilsocket/islazy/tui"
)
var mutators = []func(byte) byte{
@ -60,13 +57,13 @@ func (s *Sniffer) doFuzzing(pkt gopacket.Packet) {
}
if bytesChanged > 0 {
logFn := log.Info
logFn := s.Info
if s.fuzzSilent {
logFn = log.Debug
logFn = s.Debug
}
logFn("[%s] changed %d bytes in %d layers.", tui.Green("net.fuzz"), bytesChanged, layersChanged)
logFn("changed %d bytes in %d layers.", bytesChanged, layersChanged)
if err := s.Session.Queue.Send(pkt.Data()); err != nil {
log.Error("error sending fuzzed packet: %s", err)
s.Error("error sending fuzzed packet: %s", err)
}
}
}
@ -110,7 +107,7 @@ func (s *Sniffer) StartFuzzing() error {
s.fuzzActive = true
log.Info("[%s] active on layer types %s (rate:%f ratio:%f)", tui.Green("net.fuzz"), strings.Join(s.fuzzLayers, ","), s.fuzzRate, s.fuzzRatio)
s.Info("active on layer types %s (rate:%f ratio:%f)", strings.Join(s.fuzzLayers, ","), s.fuzzRate, s.fuzzRatio)
return nil
}