Update so that trace routes are reported as in phone apps.
This commit is contained in:
@ -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")
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -894,7 +894,7 @@
|
||||
<div class="block flex-1 px-4 py-2">
|
||||
<div class="relative flex min-w-0 flex-1 items-center">
|
||||
<div>
|
||||
<p class="text-sm font-medium text-gray-900">{{ traceroute.route.length }} hops {{ traceroute.channel_id ? `on ${traceroute.channel_id}` : '' }}</p>
|
||||
<p class="text-sm font-medium text-gray-900">{{ JSON.parse(traceroute.route).length }} hops {{ traceroute.channel_id ? `on ${traceroute.channel_id}` : '' }}</p>
|
||||
<div class="text-sm text-gray-700">Gated {{ moment(new Date(traceroute.updated_at)).fromNow() }}</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -1106,14 +1106,14 @@
|
||||
<div class="h-4 w-4 rounded-full bg-gray-100 ring-1 ring-gray-300"></div>
|
||||
</div>
|
||||
<div class="flex-auto py-0.5 text-sm leading-5 text-gray-500">
|
||||
<div class="font-medium text-gray-900">{{ findNodeById(selectedTraceRoute.node_id)?.long_name || '???' }}</div>
|
||||
<div>Hex ID: !{{ Number(selectedTraceRoute.node_id).toString(16) }}</div>
|
||||
<div class="font-medium text-gray-900">{{ findNodeById(selectedTraceRoute.to_id)?.long_name || '???' }}</div>
|
||||
<div>Hex ID: !{{ Number(selectedTraceRoute.to_id).toString(16) }}</div>
|
||||
<div>Started the traceroute</div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<!-- middleman nodes -->
|
||||
<li :onclick="`goToNode(${route})`" v-for="route of selectedTraceRoute.route" class="relative flex gap-x-4">
|
||||
<li :onclick="`goToNode(${route})`" v-for="route of JSON.parse(selectedTraceRoute.route)" class="relative flex gap-x-4">
|
||||
<div class="absolute left-0 top-0 flex w-6 justify-center -bottom-6">
|
||||
<div class="w-px bg-gray-200"></div>
|
||||
</div>
|
||||
@ -1127,6 +1127,21 @@
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<!-- Last node -->
|
||||
<li :onclick="`goToNode(${route})`" v-if="selectedTraceRoute.from_id" class="relative flex gap-x-4">
|
||||
<div class="absolute left-0 top-0 flex w-6 justify-center -bottom-6">
|
||||
<div class="w-px bg-gray-200"></div>
|
||||
</div>
|
||||
<div class="my-auto relative flex h-6 w-6 flex-none items-center justify-center bg-white">
|
||||
<div class="h-4 w-4 rounded-full bg-gray-100 ring-1 ring-gray-300"></div>
|
||||
</div>
|
||||
<div class="flex-auto py-0.5 text-sm leading-5 text-gray-500">
|
||||
<div class="font-medium text-gray-900">{{ findNodeById(selectedTraceRoute.from_id)?.long_name || '???' }}</div>
|
||||
<div>Hex ID: !{{ Number(selectedTraceRoute.from_id).toString(16) }}</div>
|
||||
<div>Replied to traceroute</div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<!-- last node in route -->
|
||||
<li :onclick="`goToNode(${route})`" v-if="selectedTraceRoute.gateway_id" class="relative flex gap-x-4">
|
||||
<div class="absolute left-0 top-0 flex w-6 justify-center h-6">
|
||||
|
Reference in New Issue
Block a user