diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 6fcaa8e..23d71e1 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -163,7 +163,9 @@ model TextMessage { model TraceRoute { id BigInt @id @default(autoincrement()) - node_id BigInt + from_id BigInt @default(0) + to_id BigInt @default(0) + want_response Boolean @default(true) route Json channel Int? @@ -176,7 +178,8 @@ model TraceRoute { @@index(created_at) @@index(updated_at) - @@index(node_id) + @@index(from_id) + @@index(to_id) @@map("traceroutes") } diff --git a/src/index.js b/src/index.js index 894998b..d9574e2 100644 --- a/src/index.js +++ b/src/index.js @@ -282,7 +282,9 @@ app.get('/api/v1/nodes/:nodeId/traceroutes', async (req, res) => { } // get latest traceroutes - const traceroutes = await prisma.$queryRaw`SELECT * FROM traceroutes WHERE node_id = ${node.node_id} and JSON_LENGTH(route) > 0 and gateway_id is not null order by id desc limit ${count}`; + // We want replies where want_response is false and it will be "to" the + // requester. + const traceroutes = await prisma.$queryRaw`SELECT * FROM traceroutes WHERE want_response = false and to_id = ${node.node_id} and gateway_id is not null order by id desc limit ${count}`; res.json({ traceroutes: traceroutes, diff --git a/src/mqtt.js b/src/mqtt.js index a07c975..f2bb380 100644 --- a/src/mqtt.js +++ b/src/mqtt.js @@ -587,7 +587,9 @@ client.on("message", async (topic, message) => { try { await prisma.traceRoute.create({ data: { - node_id: envelope.packet.from, + from_id: envelope.packet.from, + to_id: envelope.packet.to, + want_response: envelope.packet.decoded.wantResponse, route: routeDiscovery.route, channel: envelope.packet.channel, packet_id: envelope.packet.id, diff --git a/src/public/index.html b/src/public/index.html index 62b5d76..62435cb 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -894,7 +894,7 @@
-

{{ traceroute.route.length }} hops {{ traceroute.channel_id ? `on ${traceroute.channel_id}` : '' }}

+

{{ JSON.parse(traceroute.route).length }} hops {{ traceroute.channel_id ? `on ${traceroute.channel_id}` : '' }}

Gated {{ moment(new Date(traceroute.updated_at)).fromNow() }}
@@ -1106,14 +1106,14 @@
-
{{ findNodeById(selectedTraceRoute.node_id)?.long_name || '???' }}
-
Hex ID: !{{ Number(selectedTraceRoute.node_id).toString(16) }}
+
{{ findNodeById(selectedTraceRoute.to_id)?.long_name || '???' }}
+
Hex ID: !{{ Number(selectedTraceRoute.to_id).toString(16) }}
Started the traceroute
-
  • +
  • @@ -1127,6 +1127,21 @@
  • + +
  • +
    +
    +
    +
    +
    +
    +
    +
    {{ findNodeById(selectedTraceRoute.from_id)?.long_name || '???' }}
    +
    Hex ID: !{{ Number(selectedTraceRoute.from_id).toString(16) }}
    +
    Replied to traceroute
    +
    +
  • +