mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 05:23:19 -07:00
fix: using sync.Map to avoid race conditions on the packets.Queue
This commit is contained in:
parent
b676d68b4c
commit
64a5ce2b58
4 changed files with 34 additions and 71 deletions
|
@ -61,8 +61,11 @@ func (mod *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string {
|
|||
|
||||
var traffic *packets.Traffic
|
||||
var found bool
|
||||
if traffic, found = mod.Session.Queue.Traffic[e.IpAddress]; !found {
|
||||
var v interface{}
|
||||
if v, found = mod.Session.Queue.Traffic.Load(e.IpAddress); !found {
|
||||
traffic = &packets.Traffic{}
|
||||
} else {
|
||||
traffic = v.(*packets.Traffic)
|
||||
}
|
||||
|
||||
seen := e.LastSeen.Format("15:04:05")
|
||||
|
@ -203,9 +206,6 @@ func (mod *Discovery) colNames(hasMeta bool) []string {
|
|||
}
|
||||
|
||||
func (mod *Discovery) showStatusBar() {
|
||||
mod.Session.Queue.Stats.RLock()
|
||||
defer mod.Session.Queue.Stats.RUnlock()
|
||||
|
||||
parts := []string{
|
||||
fmt.Sprintf("%s %s", tui.Red("↑"), humanize.Bytes(mod.Session.Queue.Stats.Sent)),
|
||||
fmt.Sprintf("%s %s", tui.Green("↓"), humanize.Bytes(mod.Session.Queue.Stats.Received)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue