diff options
author | VaiTon | 2023-06-05 14:54:19 +0000 |
---|---|---|
committer | VaiTon | 2023-06-05 14:54:19 +0000 |
commit | 05e7c4a4e672cec898f7856c8f133cb3380a16d3 (patch) | |
tree | 47e6f472abd9d77d78161a2af25716e05e409881 | |
parent | 2e6af3b2623da3d002816a6de325133d626858c9 (diff) |
Divide if branches
-rw-r--r-- | pcap_importer.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/pcap_importer.go b/pcap_importer.go index 0df4bcb..388ec2d 100644 --- a/pcap_importer.go +++ b/pcap_importer.go @@ -222,8 +222,15 @@ func (pi *PcapImporter) parsePcap(session ImportingSession, fileName string, flu session.ProcessedPackets++ - if packet.NetworkLayer() == nil || packet.TransportLayer() == nil || - packet.TransportLayer().LayerType() != layers.LayerTypeTCP { // invalid packet + if packet.NetworkLayer() == nil { + log.Warn("Invalid packet: no network layer") + session.InvalidPackets++ + continue + } else if packet.TransportLayer() == nil { + log.Warn("Invalid packet: no transport layer") + session.InvalidPackets++ + continue + } else if packet.TransportLayer().LayerType() != layers.LayerTypeTCP { log.Warn("Invalid packet: no network or transport layer") session.InvalidPackets++ continue |