From 961ea71c84cd281ad3870e3cd857ab9997173ac1 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 19 Mar 2024 02:27:23 +1300 Subject: [PATCH] collect channel and gateway data for traceroutes --- .../migration.sql | 5 +++++ prisma/schema.prisma | 5 +++++ src/mqtt.js | 4 ++++ 3 files changed, 14 insertions(+) create mode 100644 prisma/migrations/20240318102858_add_channel_and_gateway_columns_to_traceroutes_table/migration.sql diff --git a/prisma/migrations/20240318102858_add_channel_and_gateway_columns_to_traceroutes_table/migration.sql b/prisma/migrations/20240318102858_add_channel_and_gateway_columns_to_traceroutes_table/migration.sql new file mode 100644 index 0000000..5e87d73 --- /dev/null +++ b/prisma/migrations/20240318102858_add_channel_and_gateway_columns_to_traceroutes_table/migration.sql @@ -0,0 +1,5 @@ +-- AlterTable +ALTER TABLE `traceroutes` ADD COLUMN `channel` INTEGER NULL, + ADD COLUMN `channel_id` VARCHAR(191) NULL, + ADD COLUMN `gateway_id` BIGINT NULL, + ADD COLUMN `packet_id` BIGINT NULL; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 0dba014..3df4362 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -151,6 +151,11 @@ model TraceRoute { node_id BigInt route Json + channel Int? + packet_id BigInt? + channel_id String? + gateway_id BigInt? + created_at DateTime @default(now()) updated_at DateTime @default(now()) @updatedAt diff --git a/src/mqtt.js b/src/mqtt.js index 9274326..e8bafc1 100644 --- a/src/mqtt.js +++ b/src/mqtt.js @@ -380,6 +380,10 @@ client.on("message", async (topic, message) => { data: { node_id: envelope.packet.from, route: routeDiscovery.route, + channel: envelope.packet.channel, + packet_id: envelope.packet.id, + channel_id: envelope.channelId, + gateway_id: envelope.gatewayId ? BigInt('0x' + envelope.gatewayId.replaceAll("!", "")) : null, // convert hex id "!f96a92f0" to bigint }, }); } catch (e) {