Compare commits
11 Commits
v1.1.0
...
release-2.
| Author | SHA1 | Date | |
|---|---|---|---|
| 94846a48e1 | |||
| f00db16269 | |||
| 1bffd22735 | |||
| 41b2caecb3 | |||
| 8eef17fd4c | |||
| 39350932a4 | |||
| 1e37f35e38 | |||
| d0be44c1af | |||
| 57cf6fb0a7 | |||
| 298a96bf16 | |||
| b98dff947d |
@@ -7,8 +7,11 @@ WORKDIR /usr/src/app
|
|||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
RUN apk update
|
# remove development dependencies
|
||||||
RUN apk add tcpdump
|
RUN npm prune --production
|
||||||
|
|
||||||
|
# Install required apk-packages & delete cache
|
||||||
|
RUN apk update && apk add tcpdump && rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
# Bundle app source
|
# Bundle app source
|
||||||
COPY ./src/ .
|
COPY ./src/ .
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
const PacketType = {
|
const PacketType = {
|
||||||
Beacon: 'Beacon',
|
Beacon: "Beacon",
|
||||||
ProbeRequest: 'ProbeRequest',
|
ProbeRequest: "ProbeRequest",
|
||||||
ProbeResponse: 'ProbeResponse',
|
ProbeResponse: "ProbeResponse",
|
||||||
Data: 'Data',
|
Data: "Data",
|
||||||
RequestToSend: 'RequestToSend',
|
RequestToSend: "RequestToSend",
|
||||||
ClearToSend: 'ClearToSend',
|
ClearToSend: "ClearToSend",
|
||||||
Acknowledgment: 'Acknowledgment',
|
Acknowledgment: "Acknowledgment",
|
||||||
BlockAcknowledgment: 'BlockAcknowledgment',
|
BlockAcknowledgment: "BlockAcknowledgment",
|
||||||
NoData: 'NoData',
|
NoData: "NoData",
|
||||||
Authentication: 'Authentication',
|
Authentication: "Authentication",
|
||||||
AssociationRequest: 'AssociationRequest',
|
AssociationRequest: "AssociationRequest",
|
||||||
AssociationResponse: 'AssociationResponse',
|
AssociationResponse: "AssociationResponse",
|
||||||
Disassociation: 'Disassociation',
|
Disassociation: "Disassociation",
|
||||||
Handshake: 'Handshake',
|
Handshake: "Handshake",
|
||||||
Unknown: 'Unknown'
|
Unknown: "Unknown"
|
||||||
}
|
};
|
||||||
|
|
||||||
const FlagType = {
|
const FlagType = {
|
||||||
MoreFragments: "MoreFragments",
|
MoreFragments: "MoreFragments",
|
||||||
@@ -23,7 +23,7 @@ const FlagType = {
|
|||||||
MoreData: "MoreData",
|
MoreData: "MoreData",
|
||||||
Protected: "Protected",
|
Protected: "Protected",
|
||||||
Order: "Order"
|
Order: "Order"
|
||||||
}
|
};
|
||||||
|
|
||||||
class Packet{
|
class Packet{
|
||||||
timestampMicros;
|
timestampMicros;
|
||||||
@@ -58,10 +58,10 @@ class ProbeRequestPacket extends PacketWithSSID{}
|
|||||||
class ProbeResponsePacket extends PacketWithSSID{}
|
class ProbeResponsePacket extends PacketWithSSID{}
|
||||||
|
|
||||||
const AuthenticationType = {
|
const AuthenticationType = {
|
||||||
OpenSystem_1: 'OpenSystem_1',
|
OpenSystem_1: "OpenSystem_1",
|
||||||
OpenSystem_2: 'OpenSystem_2',
|
OpenSystem_2: "OpenSystem_2",
|
||||||
Unknown: 'Unknown',
|
Unknown: "Unknown",
|
||||||
}
|
};
|
||||||
class AuthenticationPacket extends Packet{
|
class AuthenticationPacket extends Packet{
|
||||||
authenticationType;
|
authenticationType;
|
||||||
}
|
}
|
||||||
@@ -77,11 +77,11 @@ class DisassociationPacket extends Packet{
|
|||||||
|
|
||||||
|
|
||||||
const HandshakeStage = {
|
const HandshakeStage = {
|
||||||
1: '1',
|
1: "1",
|
||||||
2: '2',
|
2: "2",
|
||||||
3: '3',
|
3: "3",
|
||||||
4: '4'
|
4: "4"
|
||||||
}
|
};
|
||||||
class HandshakePacket extends Packet{
|
class HandshakePacket extends Packet{
|
||||||
handshakeStage;
|
handshakeStage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const logger = logFactory("main");
|
|||||||
const { requireEnvVars } = require("./helper/env.js");
|
const { requireEnvVars } = require("./helper/env.js");
|
||||||
const { exit } = require("process");
|
const { exit } = require("process");
|
||||||
const { exec } = require("./helper/exec.js");
|
const { exec } = require("./helper/exec.js");
|
||||||
|
const Os = require("os");
|
||||||
|
|
||||||
const { InfluxDB } = require("@influxdata/influxdb-client");
|
const { InfluxDB } = require("@influxdata/influxdb-client");
|
||||||
const InfluxChecks = require("./helper/influx-checks.js");
|
const InfluxChecks = require("./helper/influx-checks.js");
|
||||||
@@ -23,6 +24,7 @@ const env = process.env;
|
|||||||
{
|
{
|
||||||
env.LOGLEVEL ??= "INFO";
|
env.LOGLEVEL ??= "INFO";
|
||||||
env.WIFI_INTERFACE ??= "wlan0";
|
env.WIFI_INTERFACE ??= "wlan0";
|
||||||
|
env.HOSTNAME ??= Os.hostname();
|
||||||
}
|
}
|
||||||
// Required vars
|
// Required vars
|
||||||
let errorMsg = requireEnvVars([
|
let errorMsg = requireEnvVars([
|
||||||
@@ -56,6 +58,9 @@ if(errorMsg){
|
|||||||
exit(1);
|
exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
logger.debug("Get WriteApi & set default-hostname to", `'${env.HOSTNAME}'`);
|
||||||
|
const influxWriteApi = influxDb.getWriteApi(env.INFLUX_ORG, env.INFLUX_BUCKET, "us");
|
||||||
|
//influxWriteApi.useDefaultTags({"hostname": env.HOSTNAME});
|
||||||
logger.info("Influx ok");
|
logger.info("Influx ok");
|
||||||
|
|
||||||
logger.info("Starting tcpdump..");
|
logger.info("Starting tcpdump..");
|
||||||
@@ -67,7 +72,7 @@ if(errorMsg){
|
|||||||
let regexBlockStream = new RegexBlockStream(/^\d{2}:\d{2}:\d{2}.\d{6}.*(\n( {4,8}|\t\t?).*)+\n/gm);
|
let regexBlockStream = new RegexBlockStream(/^\d{2}:\d{2}:\d{2}.\d{6}.*(\n( {4,8}|\t\t?).*)+\n/gm);
|
||||||
let packetStreamFactory = new PacketStreamFactory();
|
let packetStreamFactory = new PacketStreamFactory();
|
||||||
let packetInfluxPointFactory = new PacketInfluxPointFactory();
|
let packetInfluxPointFactory = new PacketInfluxPointFactory();
|
||||||
let influxPointWriter = new InfluxPointWriter(influxDb, env.INFLUX_ORG, env.INFLUX_BUCKET);
|
let influxPointWriter = new InfluxPointWriter(influxWriteApi);
|
||||||
proc.stdout
|
proc.stdout
|
||||||
.setEncoding("utf8")
|
.setEncoding("utf8")
|
||||||
.pipe(regexBlockStream)
|
.pipe(regexBlockStream)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const logger = require.main.require("./helper/logger.js")("InfluxPointWriter");
|
const logger = require.main.require("./helper/logger.js")("InfluxPointWriter");
|
||||||
const { Writable } = require("stream");
|
const { Writable } = require("stream");
|
||||||
const {InfluxDB, Point, HttpError} = require("@influxdata/influxdb-client");
|
const { WriteApi } = require("@influxdata/influxdb-client");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get points and write them into influx
|
* Get points and write them into influx
|
||||||
@@ -8,16 +8,13 @@ const {InfluxDB, Point, HttpError} = require("@influxdata/influxdb-client");
|
|||||||
class InfluxPointWriter extends Writable{
|
class InfluxPointWriter extends Writable{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {InfluxDB} influxDb InfluxDb
|
* @param {WriteApi} writeApi WriteAPI from InfluxDB instance
|
||||||
* @param {string} org Organization to use
|
|
||||||
* @param {string} bucket Bucket to use
|
|
||||||
* @param {Partial<WriteOptions>} options Options for WriteApi
|
|
||||||
*/
|
*/
|
||||||
constructor(influxDb, org, bucket, options){
|
constructor(writeApi){
|
||||||
super({
|
super({
|
||||||
objectMode: true
|
objectMode: true
|
||||||
});
|
});
|
||||||
this._api = influxDb.getWriteApi(org, bucket, "us", options);
|
this._api = writeApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
_write(point, encoding, next){
|
_write(point, encoding, next){
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ const TAG_LIST = [
|
|||||||
|
|
||||||
/** Measurement-name and corresponding field-key */
|
/** Measurement-name and corresponding field-key */
|
||||||
const MEASUREMENT_MAP = new Map([
|
const MEASUREMENT_MAP = new Map([
|
||||||
["Signal", "signal"],
|
["rfmon_signal_dbm", "signal"],
|
||||||
["PayloadSize", "payloadSize"],
|
["rfmon_payloadsize_bytes", "payloadSize"],
|
||||||
["DataRate", "dataRate"],
|
["rfmon_datarate_bytes", "dataRate"],
|
||||||
["SSID", "ssid"],
|
["rfmon_ssid_names", "ssid"],
|
||||||
["AuthenticationType", "authenticationType"],
|
["rfmon_authenticationtype_info", "authenticationType"],
|
||||||
["AssociationSuccess", "associationIsSuccessful"],
|
["rfmon_associationsuccess_bools", "associationIsSuccessful"],
|
||||||
["DisassociationReason", "disassociationReason"],
|
["rfmon_disassociationreason_info", "disassociationReason"],
|
||||||
["HandshakeStage", "handshakeStage"],
|
["rfmon_handshakestage_info", "handshakeStage"],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
@@ -66,7 +66,10 @@ function tagObjectRecursively(point, tag, field, suffix = ""){
|
|||||||
tagObjectRecursively(point, tag, value, `_${key}${suffix}`);
|
tagObjectRecursively(point, tag, value, `_${key}${suffix}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else point.tag(tag+suffix, field);
|
else {
|
||||||
|
const name = (tag+suffix).toLowerCase();
|
||||||
|
point.tag(name, field);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Mapping for type -> field-method */
|
/** Mapping for type -> field-method */
|
||||||
|
|||||||
Reference in New Issue
Block a user