From 647ee32c874cfa1afcf7e124c708d22f0b654ad4 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 23 Dec 2024 22:18:48 +1300 Subject: [PATCH] add button to dropdown menu to ping destination --- meshchat.py | 10 ++++--- .../messages/ConversationDropDownMenu.vue | 27 +++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/meshchat.py b/meshchat.py index 8e604e1..d3da58e 100644 --- a/meshchat.py +++ b/meshchat.py @@ -1163,8 +1163,9 @@ class ReticulumMeshChat: "message": f"Ping failed. Timed out after {timeout_seconds} seconds.", }, status=503) - # get number of hops to destination - hops = RNS.Transport.hops_to(destination_hash) + # get number of hops to destination and back from destination + hops_there = RNS.Transport.hops_to(destination_hash) + hops_back = receipt.proof_packet.hops # get rssi rssi = receipt.proof_packet.rssi @@ -1187,10 +1188,11 @@ class ReticulumMeshChat: rtt_duration_string = f"{rtt_milliseconds} ms" return web.json_response({ - "message": f"Valid reply from {receipt.destination.hash.hex()}: hops={hops} time={rtt_duration_string}", + "message": f"Valid reply from {receipt.destination.hash.hex()}\nDuration: {rtt_duration_string}\nHops There: {hops_there}\nHops Back: {hops_back}", "ping_result": { "rtt": rtt, - "hops": hops, + "hops_there": hops_there, + "hops_back": hops_back, "rssi": rssi, "snr": snr, "quality": quality, diff --git a/src/frontend/components/messages/ConversationDropDownMenu.vue b/src/frontend/components/messages/ConversationDropDownMenu.vue index 057b861..4f3bb09 100644 --- a/src/frontend/components/messages/ConversationDropDownMenu.vue +++ b/src/frontend/components/messages/ConversationDropDownMenu.vue @@ -19,6 +19,14 @@ + + + + + + Ping Destination + + @@ -84,6 +92,25 @@ export default { async onSetCustomDisplayName() { this.$emit("set-custom-display-name"); }, + async onPingDestination() { + try { + + // ping destination + const response = await window.axios.get(`/api/v1/ping/${this.peer.destination_hash}/lxmf.delivery`, { + params: { + timeout: 30, + }, + }); + + // show result + DialogUtils.alert(response.data.message); + + } catch(e) { + console.log(e); + const message = e.response?.data?.message ?? "Ping failed. Try again later"; + DialogUtils.alert(message); + } + }, }, }