From bba5da25998c7cbe5f72ba0a19f181c2bdf7fa4d Mon Sep 17 00:00:00 2001 From: Ruakij Date: Wed, 24 Nov 2021 22:25:10 +0100 Subject: [PATCH] Moved packet-creation outside for all cases --- src/streamHandler/PacketStreamFactory.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/streamHandler/PacketStreamFactory.js b/src/streamHandler/PacketStreamFactory.js index 01795da..0e8f76d 100644 --- a/src/streamHandler/PacketStreamFactory.js +++ b/src/streamHandler/PacketStreamFactory.js @@ -65,14 +65,16 @@ class PacketStreamFactory extends Transform{ packet.bssid = data.match(/(^| )BSSID:(.{17})($| )/i)?.[2] ?? null; // Cover special cases with more data + let newPacket; switch(packet.packetType){ case PacketType.Beacon: case PacketType.ProbeRequest: case PacketType.ProbeResponse: - packet = Object.assign(new PacketWithSSID(), packet); // Create new, more specific, packet and copy old data over - packet.ssid = data.match(new RegExp(`(^| )${packetTypeStr} `+'\\'+`((.{0,32})`+'\\'+`)($| )`, 'i'))?.[2] ?? null; + newPacket = new PacketWithSSID(); + newPacket.ssid = data.match(new RegExp(`(^| )${packetTypeStr} `+'\\'+`((.{0,32})`+'\\'+`)($| )`, 'i'))?.[2] ?? null; break; } + if(newPacket) packet = Object.assign(new newPacket, packet); // Use new, more specific, packet and copy old data over } _handlePayload(packet, data){