Fix: Traceroute through MQTT misses uplink node if MQTT is encrypted#9798
Conversation
@domusonline, Welcome to Meshtastic!Thanks for opening your first pull request. We really appreciate it. We discuss work as a team in discord, please join us in the #firmware channel. Welcome to the team 😄 |
There was a problem hiding this comment.
Pull request overview
Fixes Meshtastic traceroute packets published via encrypted MQTT so the gateway node appears in the route (by ensuring the MQTT-encrypted payload reflects traceroute module in-place modifications).
Changes:
- Rebuilds the encrypted MQTT copy for
TRACEROUTE_APPpackets after modules run, then re-encodes/encrypts it before publishing to MQTT. - Skips MQTT publish for traceroute packets if re-encryption fails.
|
I agree with the co-pilot suggested changes. Some were considered but I tried to follow what has been done previously in other parts of the code. |
|
Thanks for your PR! Indeed it looks a bit cumbersome, but I think it's OK. We could also always re-encrypt it, but I think checking for the traceroute app is a nice optimization as encrypting can take a while. I responded to the AI's comments and I think indeed two of them are worth implementing. |
I updated the Router.cpp file with the following changes: I think it's more efficient, more resilient and looks a bit "cleaner" now. |
GUVWAF
left a comment
There was a problem hiding this comment.
Thanks for the effort!
Looks good to me.
|
@domusonline , are you familiar with the trunk code linter? We use it to keep all our formatting consistent. |
I installed it, tried to run it, but had some issues. Given the small ammount of lines changed I thought it followed the recommend formatting, but I noticed some automated test/validation apparently failed. I'm motivated to try more contributions and in case I do I'll make sure I clear the mentioned issues... |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…9798) * Attempt to fix issue 9713 * Code formatting issue. * Remade the fix to follow Copilot observations on PR * Rebuild after AI and GUVWAF * Update src/mesh/Router.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/mesh/Router.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * trunk fmt --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: GUVWAF <thijs@havinga.eu> Co-authored-by: GUVWAF <78759985+GUVWAF@users.noreply.github.com>
…eshtastic#9798) * Attempt to fix issue 9713 * Code formatting issue. * Remade the fix to follow Copilot observations on PR * Rebuild after AI and GUVWAF * Update src/mesh/Router.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/mesh/Router.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * trunk fmt --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: GUVWAF <thijs@havinga.eu> Co-authored-by: GUVWAF <78759985+GUVWAF@users.noreply.github.com>
…eshtastic#9798) * Attempt to fix issue 9713 * Code formatting issue. * Remade the fix to follow Copilot observations on PR * Rebuild after AI and GUVWAF * Update src/mesh/Router.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/mesh/Router.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * trunk fmt --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: GUVWAF <thijs@havinga.eu> Co-authored-by: GUVWAF <78759985+GUVWAF@users.noreply.github.com>
…eshtastic#9798) * Attempt to fix issue 9713 * Code formatting issue. * Remade the fix to follow Copilot observations on PR * Rebuild after AI and GUVWAF * Update src/mesh/Router.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/mesh/Router.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * trunk fmt --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: GUVWAF <thijs@havinga.eu> Co-authored-by: GUVWAF <78759985+GUVWAF@users.noreply.github.com>
This PR fixes #9713
As described in the bug, a traceroute that goes through MQTT server will not show the gateway node.
This is caused by the code in Router.cpp which saves the original image of the packet (before TraceRoute module changes it) and uses that image to send to the MQTT server.
The solution proposed works, but I don't find it the best due to these reasons:
The second issues caused a lot of "repeated ELSE" structures which look weird. But I couldn't find a better way to avoid calling mqtt::onSend with an invalid reference.
In favor of the fix it only applies to the specific situation where the packet is a traceroute. So the impact is rather low (just one or two IFs) for all the other cases.
I didn't try to avoid the release at the end of the method, because it is done even if the pointer is "nullptr" if I understood the code correctly.
I've tested this in the following way:
With this in mind, I just feel there would be more elegant ways to solve this, but I'm pretty confident it works and will only change the behavior when a node connected to MQTT receives and processes a traceroute. I'd be happy if anyone else can provide a better solution, but if that takes time I think this is a viable solution.
Appreciated the support and feedback I had on Discord and local mesh community.
🤝 Attestations
Heltec WSL V3