-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c72eb05
commit 3869a6b
Showing
10 changed files
with
298 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<template> | ||
<Page> | ||
|
||
<!-- app bar --> | ||
<AppBar title="Trace Routes" :subtitle="subtitle"> | ||
<template v-slot:leading> | ||
<NodeIcon v-if="node" :node="node" class="mr-3"/> | ||
</template> | ||
<template v-slot:trailing> | ||
<IconButton v-if="node" @click="onNewTraceRouteClick(node)" class="mx-2 bg-transparent text-gray-700"> | ||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6"> | ||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" /> | ||
</svg> | ||
</IconButton> | ||
</template> | ||
</AppBar> | ||
|
||
<!-- list --> | ||
<div class="h-full w-full overflow-hidden"> | ||
<div v-for="traceRoute of reversedTraceRoutes" class="w-full"> | ||
<RouterLink :to="{ name: 'traceroute', params: { traceRouteId: traceRoute.id} }"> | ||
<div class="flex p-2 bg-white hover:bg-gray-50"> | ||
<div> | ||
<div class="text-sm text-gray-900"> | ||
<span class="font-medium">{{ getNodeLongName(traceRoute.to) || '???' }}</span> | ||
<span> to </span> | ||
<span class="font-medium">{{ getNodeLongName(traceRoute.from) || '???' }}</span> | ||
</div> | ||
<div class="text-sm text-gray-700"> | ||
{{ getTimeAgo(traceRoute.rxTime) }} • {{ traceRoute.data.route.length }} hop(s) on channel {{ getChannelName(traceRoute.channel) }} | ||
</div> | ||
</div> | ||
</div> | ||
</RouterLink> | ||
</div> | ||
</div> | ||
|
||
</Page> | ||
</template> | ||
|
||
<script> | ||
import GlobalState from "../../js/GlobalState.js"; | ||
import AppBar from "../AppBar.vue"; | ||
import NodeIcon from "../nodes/NodeIcon.vue"; | ||
import Page from "./Page.vue"; | ||
import NodeUtils from "../../js/NodeUtils.js"; | ||
import IconButton from "../IconButton.vue"; | ||
import NodeAPI from "../../js/NodeAPI.js"; | ||
import ChannelUtils from "../../js/ChannelUtils.js"; | ||
import TimeUtils from "../../js/TimeUtils.js"; | ||
export default { | ||
name: 'NodeTracesRoutePage', | ||
components: { | ||
Page, | ||
AppBar, | ||
IconButton, | ||
NodeIcon, | ||
}, | ||
props: { | ||
nodeId: String | Number, | ||
}, | ||
mounted() { | ||
// redirect to main page if node not found | ||
if(!this.node){ | ||
this.$router.push({ | ||
name: "main", | ||
}); | ||
return; | ||
} | ||
}, | ||
methods: { | ||
getNodeLongName: (nodeId) => NodeUtils.getNodeLongName(nodeId), | ||
getTimeAgo: (date) => TimeUtils.getTimeAgo(date), | ||
onNewTraceRouteClick(node) { | ||
NodeAPI.traceRoute(node.num); | ||
}, | ||
getChannelName: (channelId) => { | ||
return ChannelUtils.getChannelName(channelId) || `#${channelId}`; | ||
}, | ||
}, | ||
computed: { | ||
node() { | ||
return GlobalState.nodesById[this.nodeId]; | ||
}, | ||
subtitle() { | ||
return this.node ? this.getNodeLongName(this.node.num) : "Unknown Node"; | ||
}, | ||
traceRoutes() { | ||
// return traceroute responses from this node to us | ||
return Object.values(GlobalState.traceRoutesById).filter((traceRoute) => { | ||
return traceRoute.from === this.node.num && traceRoute.to === GlobalState.myNodeId; | ||
}); | ||
}, | ||
reversedTraceRoutes() { | ||
return this.traceRoutes.reverse(); | ||
}, | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
<template> | ||
<Page> | ||
|
||
<!-- app bar --> | ||
<AppBar title="TraceRoute" :subtitle="subtitle"/> | ||
|
||
<!-- list --> | ||
<div v-if="traceRoute" class="flex flex-col h-full w-full overflow-hidden"> | ||
<div class="overflow-y-auto"> | ||
|
||
<!-- details --> | ||
<div class="p-2 bg-white"> | ||
<ul role="list" class="space-y-3"> | ||
|
||
<!-- node that initiated traceroute --> | ||
<li class="relative flex gap-x-4"> | ||
<div class="absolute left-0 top-0 flex w-12 justify-center top-3 -bottom-3"> | ||
<div class="w-px bg-gray-200"></div> | ||
</div> | ||
<div class="my-auto relative flex flex-none items-center justify-center"> | ||
<div> | ||
<NodeIcon :node="findNodeById(this.traceRoute.to)"/> | ||
</div> | ||
</div> | ||
<div class="flex-auto py-0.5 text-sm leading-5 text-gray-500"> | ||
<div class="font-medium text-gray-900">{{ getNodeLongName(this.traceRoute.to) || '???' }}</div> | ||
<div>{{ getNodeHexId(this.traceRoute.to) }}</div> | ||
<div>Started the traceroute</div> | ||
</div> | ||
</li> | ||
|
||
<!-- middleman nodes --> | ||
<li v-for="route of this.traceRoute.data.route" class="relative flex gap-x-4"> | ||
<div class="absolute left-0 top-0 flex w-12 justify-center -bottom-3"> | ||
<div class="w-px bg-gray-200"></div> | ||
</div> | ||
<div class="my-auto relative flex flex-none items-center justify-center"> | ||
<div> | ||
<NodeIcon :node="findNodeById(route)"/> | ||
</div> | ||
</div> | ||
<div class="flex-auto py-0.5 text-sm leading-5 text-gray-500"> | ||
<div class="font-medium text-gray-900">{{ getNodeLongName(route) || '???' }}</div> | ||
<div>{{ getNodeHexId(route) }}</div> | ||
<div>Forwarded the packet</div> | ||
</div> | ||
</li> | ||
|
||
<!-- node that replied to traceroute --> | ||
<li v-if="this.traceRoute.from" class="relative flex gap-x-4"> | ||
<div class="absolute left-0 top-0 flex w-12 justify-center h-6"> | ||
<div class="w-px bg-gray-200"></div> | ||
</div> | ||
<div class="my-auto relative flex flex-none items-center justify-center"> | ||
<div> | ||
<NodeIcon :node="findNodeById(this.traceRoute.from)"/> | ||
</div> | ||
</div> | ||
<div class="flex-auto py-0.5 text-sm leading-5 text-gray-500"> | ||
|
||
<div class="font-medium text-gray-900">{{ getNodeLongName(this.traceRoute.from) || '???' }}</div> | ||
<div>{{ getNodeHexId(this.traceRoute.from) }}</div> | ||
<div>Replied to traceroute</div> | ||
</div> | ||
</li> | ||
|
||
</ul> | ||
|
||
</div> | ||
|
||
<!-- raw data --> | ||
<div> | ||
<div class="bg-gray-200 p-2 font-semibold">Raw Data</div> | ||
<div class="text-sm text-gray-700"> | ||
<pre class="bg-white p-2 overflow-x-auto">{{ JSON.stringify(this.traceRoute, null, 4) }}</pre> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
</Page> | ||
</template> | ||
|
||
<script> | ||
import GlobalState from "../../js/GlobalState.js"; | ||
import AppBar from "../AppBar.vue"; | ||
import Page from "./Page.vue"; | ||
import NodeUtils from "../../js/NodeUtils.js"; | ||
import NodeIcon from "../nodes/NodeIcon.vue"; | ||
import moment from "moment"; | ||
import ChannelUtils from "../../js/ChannelUtils.js"; | ||
import TimeUtils from "../../js/TimeUtils.js"; | ||
export default { | ||
name: 'TraceRoutePage', | ||
components: { | ||
NodeIcon, | ||
Page, | ||
AppBar, | ||
}, | ||
props: { | ||
traceRouteId: String | Number, | ||
}, | ||
mounted() { | ||
// redirect to main page if trace route not found | ||
if(!this.traceRoute){ | ||
this.$router.push({ | ||
name: "main", | ||
}); | ||
return; | ||
} | ||
}, | ||
methods: { | ||
getNodeHexId: (nodeId) => NodeUtils.getNodeHexId(nodeId), | ||
getNodeLongName: (nodeId) => NodeUtils.getNodeLongName(nodeId), | ||
findNodeById(nodeId){ | ||
return GlobalState.nodesById[nodeId]; | ||
}, | ||
getTimeAgo: (date) => TimeUtils.getTimeAgo(date), | ||
getChannelName: (channelId) => { | ||
return ChannelUtils.getChannelName(channelId) || `#${channelId}`; | ||
}, | ||
}, | ||
computed: { | ||
traceRoute() { | ||
return GlobalState.traceRoutesById[this.traceRouteId]; | ||
}, | ||
subtitle() { | ||
if(this.traceRoute){ | ||
return `${this.getTimeAgo(this.traceRoute.rxTime)} • ${this.traceRoute.data.route.length} hop(s) on channel ${this.getChannelName(this.traceRoute.channel)}`; | ||
} else { | ||
return `#${this.traceRouteId}`; | ||
} | ||
}, | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import GlobalState from "./GlobalState.js"; | ||
|
||
class ChannelUtils { | ||
|
||
static getChannelName(channelId) { | ||
const channel = GlobalState.channelsByIndex[channelId]; | ||
return channel?.settings?.name; | ||
} | ||
|
||
} | ||
|
||
export default ChannelUtils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters