Moved packet-creation outside for all cases

f_influx-checks
Ruakij 3 years ago
parent c2210dfb59
commit bba5da2599

@ -65,14 +65,16 @@ class PacketStreamFactory extends Transform{
packet.bssid = data.match(/(^| )BSSID:(.{17})($| )/i)?.[2] ?? null; packet.bssid = data.match(/(^| )BSSID:(.{17})($| )/i)?.[2] ?? null;
// Cover special cases with more data // Cover special cases with more data
let newPacket;
switch(packet.packetType){ switch(packet.packetType){
case PacketType.Beacon: case PacketType.Beacon:
case PacketType.ProbeRequest: case PacketType.ProbeRequest:
case PacketType.ProbeResponse: case PacketType.ProbeResponse:
packet = Object.assign(new PacketWithSSID(), packet); // Create new, more specific, packet and copy old data over newPacket = new PacketWithSSID();
packet.ssid = data.match(new RegExp(`(^| )${packetTypeStr} `+'\\'+`((.{0,32})`+'\\'+`)($| )`, 'i'))?.[2] ?? null; newPacket.ssid = data.match(new RegExp(`(^| )${packetTypeStr} `+'\\'+`((.{0,32})`+'\\'+`)($| )`, 'i'))?.[2] ?? null;
break; break;
} }
if(newPacket) packet = Object.assign(new newPacket, packet); // Use new, more specific, packet and copy old data over
} }
_handlePayload(packet, data){ _handlePayload(packet, data){

Loading…
Cancel
Save