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

This commit is contained in:
evilsocket 2018-02-11 05:03:06 +01:00
parent 624fed69bb
commit 2c7a8d8fa7

View file

@ -91,9 +91,6 @@ func (q *Queue) trackProtocols(pkt gopacket.Packet) {
} }
func (q *Queue) trackActivity(eth *layers.Ethernet, ip4 *layers.IPv4, address net.IP, pktSize uint64) { func (q *Queue) trackActivity(eth *layers.Ethernet, ip4 *layers.IPv4, address net.IP, pktSize uint64) {
q.Lock()
defer q.Unlock()
// detrmine direction // detrmine direction
isSent := bytes.Compare(address, ip4.SrcIP) == 0 isSent := bytes.Compare(address, ip4.SrcIP) == 0
// push to activity channel // push to activity channel
@ -103,6 +100,9 @@ func (q *Queue) trackActivity(eth *layers.Ethernet, ip4 *layers.IPv4, address ne
Source: isSent, Source: isSent,
} }
q.Lock()
defer q.Unlock()
// initialize or update stats // initialize or update stats
addr := address.String() addr := address.String()
if _, found := q.Traffic[addr]; found == false { if _, found := q.Traffic[addr]; found == false {