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

This commit is contained in:
evilsocket 2018-02-11 19:50:03 +01:00
commit 4d720bba7c

View file

@ -71,16 +71,17 @@ func (q *Queue) trackProtocols(pkt gopacket.Packet) {
// gather protocols stats // gather protocols stats
pktLayers := pkt.Layers() pktLayers := pkt.Layers()
for _, layer := range pktLayers { for _, layer := range pktLayers {
proto := layer.LayerType().String() proto := layer.LayerType()
if proto == "DecodeFailure" || proto == "Payload" || proto == "Ethernet" { if proto == gopacket.LayerTypeDecodeFailure || proto == gopacket.LayerTypePayload {
continue continue
} }
q.Lock() q.Lock()
if _, found := q.Protos[proto]; found == false { name := proto.String()
q.Protos[proto] = 1 if _, found := q.Protos[name]; found == false {
q.Protos[name] = 1
} else { } else {
q.Protos[proto] += 1 q.Protos[name] += 1
} }
q.Unlock() q.Unlock()
} }