misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
evilsocket 2018-02-11 19:43:36 +01:00
commit ea477ef2b4
4 changed files with 38 additions and 45 deletions

View file

@ -3,6 +3,7 @@ package modules
import (
"fmt"
"net"
"sync/atomic"
"github.com/evilsocket/bettercap-ng/log"
)
@ -19,9 +20,7 @@ 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.Lock()
p.Session.Queue.Sent += uint64(wrote)
p.Session.Queue.Unlock()
atomic.AddUint64(&p.Session.Queue.Stats.Sent, uint64(wrote))
}
}
}

View file

@ -144,11 +144,11 @@ func (d *Discovery) Show(by string) error {
fmt.Printf("\n%s %s / %s %s / %d pkts / %d errs\n\n",
core.Red("↑"),
humanize.Bytes(atomic.LoadUint64(&d.Session.Queue.Sent)),
humanize.Bytes(atomic.LoadUint64(&d.Session.Queue.Stats.Sent)),
core.Green("↓"),
humanize.Bytes(atomic.LoadUint64(&d.Session.Queue.Received)),
atomic.LoadUint64(&d.Session.Queue.PktReceived),
atomic.LoadUint64(&d.Session.Queue.Errors))
humanize.Bytes(atomic.LoadUint64(&d.Session.Queue.Stats.Received)),
atomic.LoadUint64(&d.Session.Queue.Stats.PktReceived),
atomic.LoadUint64(&d.Session.Queue.Stats.Errors))
s := EventsStream{}
events := d.Session.Events.Sorted()