Implemented PacketType Authentication
This commit is contained in:
parent
bba5da2599
commit
0d472e8cb3
@ -9,6 +9,7 @@ const PacketType = {
|
|||||||
Acknowledgment: 'Acknowledgment',
|
Acknowledgment: 'Acknowledgment',
|
||||||
BlockAcknowledgment: 'BlockAcknowledgment',
|
BlockAcknowledgment: 'BlockAcknowledgment',
|
||||||
NoData: 'NoData',
|
NoData: 'NoData',
|
||||||
|
Authentication: 'Authentication',
|
||||||
Unknown: 'Unknown'
|
Unknown: 'Unknown'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,6 +42,14 @@ class BeaconPacket extends PacketWithSSID{}
|
|||||||
class ProbeRequestPacket extends PacketWithSSID{}
|
class ProbeRequestPacket extends PacketWithSSID{}
|
||||||
class ProbeResponsePacket extends PacketWithSSID{}
|
class ProbeResponsePacket extends PacketWithSSID{}
|
||||||
|
|
||||||
|
const AuthenticationType = {
|
||||||
|
OpenSystem_1: 'OpenSystem_1',
|
||||||
|
OpenSystem_2: 'OpenSystem_2',
|
||||||
|
Unknown: 'Unknown',
|
||||||
|
}
|
||||||
|
class AuthenticationPacket extends Packet{
|
||||||
|
authenticationType;
|
||||||
|
}
|
||||||
|
|
||||||
// Specify exports
|
// Specify exports
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@ -49,5 +58,7 @@ module.exports = {
|
|||||||
PacketWithSSID,
|
PacketWithSSID,
|
||||||
BeaconPacket,
|
BeaconPacket,
|
||||||
ProbeRequestPacket,
|
ProbeRequestPacket,
|
||||||
ProbeResponsePacket
|
ProbeResponsePacket,
|
||||||
|
AuthenticationType,
|
||||||
|
AuthenticationPacket,
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const logger = require.main.require("./helper/logger.js")("PacketStreamFactory");
|
const logger = require.main.require("./helper/logger.js")("PacketStreamFactory");
|
||||||
const { Transform } = require('stream');
|
const { Transform } = require('stream');
|
||||||
const { DateTime } = require("luxon");
|
const { DateTime } = require("luxon");
|
||||||
const { PacketType, Packet, PacketWithSSID, BeaconPacket, ProbeRequestPacket, ProbeResponsePacket } = require.main.require('./dto/Packet.js');
|
const { PacketType, Packet, PacketWithSSID, BeaconPacket, ProbeRequestPacket, ProbeResponsePacket, AuthenticationPacket, AuthenticationType } = require.main.require('./dto/Packet.js');
|
||||||
|
|
||||||
const PACKET_TYPE_MAP = {
|
const PACKET_TYPE_MAP = {
|
||||||
"Beacon": PacketType.Beacon,
|
"Beacon": PacketType.Beacon,
|
||||||
@ -12,10 +12,16 @@ const PACKET_TYPE_MAP = {
|
|||||||
"Request-To-Send": PacketType.RequestToSend,
|
"Request-To-Send": PacketType.RequestToSend,
|
||||||
"Clear-To-Send": PacketType.ClearToSend,
|
"Clear-To-Send": PacketType.ClearToSend,
|
||||||
"Acknowledgment": PacketType.Acknowledgment,
|
"Acknowledgment": PacketType.Acknowledgment,
|
||||||
"BA": PacketType.BlockAcknowledgment
|
"BA": PacketType.BlockAcknowledgment,
|
||||||
|
"Authentication": PacketType.Authentication,
|
||||||
};
|
};
|
||||||
const PACKET_TYPES_REGEX = Object.keys(PACKET_TYPE_MAP).join('|');
|
const PACKET_TYPES_REGEX = Object.keys(PACKET_TYPE_MAP).join('|');
|
||||||
|
|
||||||
|
const AUTHENTICATION_TYPE_MAP = {
|
||||||
|
"(Open System)-1": AuthenticationType.OpenSystem_1,
|
||||||
|
"(Open System)-2": AuthenticationType.OpenSystem_2,
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read data from text-blocks and convert them to Packet
|
* Read data from text-blocks and convert them to Packet
|
||||||
*/
|
*/
|
||||||
@ -73,6 +79,11 @@ class PacketStreamFactory extends Transform{
|
|||||||
newPacket = new PacketWithSSID();
|
newPacket = new PacketWithSSID();
|
||||||
newPacket.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;
|
||||||
|
|
||||||
|
case PacketType.Authentication:
|
||||||
|
newPacket = new AuthenticationPacket();
|
||||||
|
newPacket.authenticationType = AUTHENTICATION_TYPE_MAP[data.match(/(?<=(^|\s)Authentication\s).{3,}(?=\:(\s|$))/i)[0]] ?? AuthenticationType.Unknown;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if(newPacket) packet = Object.assign(new newPacket, packet); // Use new, more specific, packet and copy old data over
|
if(newPacket) packet = Object.assign(new newPacket, packet); // Use new, more specific, packet and copy old data over
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user