mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
fix: fixed a race condition
This commit is contained in:
parent
e5f598b274
commit
ec28d73ba7
4 changed files with 32 additions and 38 deletions
|
@ -19,9 +19,9 @@ func (p *Prober) sendProbeUDP(from net.IP, from_hw net.HardwareAddr, ip net.IP)
|
|||
wrote, _ := con.Write([]byte{0x00})
|
||||
|
||||
if wrote > 0 {
|
||||
p.Session.Queue.Stats.Lock()
|
||||
p.Session.Queue.Stats.Sent += uint64(wrote)
|
||||
p.Session.Queue.Stats.Unlock()
|
||||
p.Session.Queue.TrackSent(uint64(wrote))
|
||||
} else {
|
||||
p.Session.Queue.TrackError()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -273,17 +273,6 @@ func (w *WiFiModule) updateStats(dot11 *layers.Dot11, packet gopacket.Packet) {
|
|||
}
|
||||
}
|
||||
|
||||
func (w *WiFiModule) trackPacket(pkt gopacket.Packet) {
|
||||
pktSize := uint64(len(pkt.Data()))
|
||||
|
||||
w.Session.Queue.Stats.Lock()
|
||||
|
||||
w.Session.Queue.Stats.PktReceived++
|
||||
w.Session.Queue.Stats.Received += pktSize
|
||||
|
||||
w.Session.Queue.Stats.Unlock()
|
||||
}
|
||||
|
||||
func (w *WiFiModule) Start() error {
|
||||
if err := w.Configure(); err != nil {
|
||||
return err
|
||||
|
@ -306,13 +295,11 @@ func (w *WiFiModule) Start() error {
|
|||
for packet := range w.pktSourceChan {
|
||||
if w.Running() == false {
|
||||
break
|
||||
}
|
||||
|
||||
if packet == nil {
|
||||
} else if packet == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
w.trackPacket(packet)
|
||||
w.Session.Queue.TrackPacket(uint64(len(packet.Data())))
|
||||
|
||||
// perform initial dot11 parsing and layers validation
|
||||
if ok, radiotap, dot11 := packets.Dot11Parse(packet); ok == true {
|
||||
|
|
|
@ -13,14 +13,9 @@ import (
|
|||
func (w *WiFiModule) injectPacket(data []byte) {
|
||||
if err := w.handle.WritePacketData(data); err != nil {
|
||||
log.Error("Could not inject WiFi packet: %s", err)
|
||||
|
||||
w.Session.Queue.Stats.Lock()
|
||||
w.Session.Queue.Stats.Errors++
|
||||
w.Session.Queue.Stats.Unlock()
|
||||
w.Session.Queue.TrackError()
|
||||
} else {
|
||||
w.Session.Queue.Stats.Lock()
|
||||
w.Session.Queue.Stats.Sent += uint64(len(data))
|
||||
w.Session.Queue.Stats.Unlock()
|
||||
w.Session.Queue.TrackSent(uint64(len(data)))
|
||||
}
|
||||
// let the network card breath a little
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue