Skip to content

fix(traceroute): skip processing our own outgoing traceroute responses (#1140)#1144

Merged
Yeraze merged 1 commit into
mainfrom
fix/traceroute-outgoing-response-1140
Dec 19, 2025
Merged

fix(traceroute): skip processing our own outgoing traceroute responses (#1140)#1144
Yeraze merged 1 commit into
mainfrom
fix/traceroute-outgoing-response-1140

Conversation

@Yeraze

@Yeraze Yeraze commented Dec 19, 2025

Copy link
Copy Markdown
Owner

Summary

  • Fixes incorrect "direct line" route segments shown on the map when another node traceroutes us
  • Skip processing traceroute responses that originate from our local node

Problem

When another node (A) sends a traceroute request to us (B):

  1. Our firmware responds with a traceroute response
  2. MeshMonitor captures our own outgoing response
  3. This response only has the forward route (path TO us), but routeBack is empty
  4. This causes a direct line to be drawn from us to the requester on the map

Solution

Check if fromNum equals our local node number in processTracerouteMessage(). If so, skip processing since it's our own response to someone else's request, not a traceroute result we requested.

Test plan

  • Have another node traceroute your MeshMonitor node
  • Verify no direct line appears on the map for the return path
  • Verify traceroutes you initiate still work correctly
  • Check logs for: Skipping traceroute response from local node

Closes #1140

🤖 Generated with Claude Code

#1140)

When another node traceroutes us, our firmware sends a response that we
capture. This response only contains the forward path (route) but not a
meaningful return path (routeBack), causing incorrect "direct line" route
segments to be displayed on the map.

Now we skip processing traceroute responses where fromNum equals our local
node number, since those are responses we sent, not results we requested.

Closes #1140

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 19, 2025

Copy link
Copy Markdown

Claude finished @Yeraze's task —— View job


Code Review Complete ✅

Todo List

  • Read and analyze the changed file (src/server/meshtasticManager.ts)
  • Review code quality and best practices
  • Check for potential bugs or edge cases
  • Evaluate performance considerations
  • Assess security concerns
  • Review test coverage needs
  • Provide comprehensive feedback

📋 Review Summary

This is a well-targeted fix for issue #1140 that addresses incorrect "direct line" route segments on the map when other nodes traceroute the local MeshMonitor node.

Code Quality & Best Practices

Excellent implementation with several strengths:

  • Clear intent: Comment explains exactly what the code does and why
  • Consistent pattern: Uses established this.localNodeInfo pattern already used elsewhere in the codebase
  • Appropriate logging: Uses logger.debug with clear message and context
  • Early return: Follows good practice of checking invalid conditions early
  • Proper formatting: Code follows existing style conventions

Logic Analysis

The fix correctly identifies the root cause:

  1. When node A traceroutes node B (us), B's firmware responds
  2. MeshMonitor captures its own outgoing response
  3. This response has forward route but empty routeBack
  4. The check fromNum === this.localNodeInfo.nodeNum properly identifies our own responses

Location: src/server/meshtasticManager.ts:2695-2698

🔍 Potential Issues

1. Null Safety Consideration

if (this.localNodeInfo && fromNum === this.localNodeInfo.nodeNum) {

The code correctly checks this.localNodeInfo exists before accessing .nodeNum. This is good defensive programming since localNodeInfo is initialized asynchronously.

2. Edge Case: Startup Race Condition
During startup, localNodeInfo might not be set yet when traceroute responses arrive. The null check handles this gracefully - the method will process the message normally until localNodeInfo is available.

Performance

Minimal impact:

  • Simple numeric comparison (===)
  • Early return avoids unnecessary processing
  • No database calls or complex operations

🔒 Security

No security concerns:

  • Uses existing validated data (fromNum, localNodeInfo.nodeNum)
  • No new attack vectors introduced
  • Defensive null checking prevents crashes

🧪 Test Coverage

Recommendation: Add a unit test to verify this behavior:

// Suggested test case
it('should skip traceroute responses from local node', () => {
  // Mock localNodeInfo with known nodeNum
  // Create meshPacket with from === localNodeInfo.nodeNum  
  // Verify processTracerouteMessage returns early
  // Verify debug log is called
});

The fix would benefit from a test in /src/server/meshtasticManager.test.ts to ensure the skip logic works correctly and regression protection.

📊 Overall Assessment

Score: 9/10 - Excellent implementation

Strengths:

Minor improvement:

  • Add unit test for regression protection

Recommendation

Approve this PR - The implementation is solid and addresses the issue correctly. Consider adding the suggested unit test as a follow-up task.


@Yeraze Yeraze merged commit c633dad into main Dec 19, 2025
14 checks passed
@Yeraze Yeraze deleted the fix/traceroute-outgoing-response-1140 branch December 19, 2025 17:11
@sibrat

sibrat commented Dec 30, 2025

Copy link
Copy Markdown

this bug is still present in last version (v2.21.12)
return paths (but actually direct line to initiator) from incoming traceroutes are still present on map

@Yeraze

Yeraze commented Dec 30, 2025

Copy link
Copy Markdown
Owner Author

Can you provide additional data? (Logs, screenshots)

@sibrat

sibrat commented Dec 30, 2025

Copy link
Copy Markdown

here is traceroute from r9oot to me :

#1 R9OOT 6el-Yagi Heltec v3 → Arbuz12/29/2025 22:01 11h ago
→ Forward: R9OOT 6el-Yagi Heltec v3 [🔜] (-12.8 dB) → Node !05618c01 [0561] (-13.8 dB) → Arbuz [arbz] [26.9 km]
← Return: Arbuz [arbz] → R9OOT 6el-Yagi Heltec v3 [🔜] [25.3 km]

here is log grep:

journalctl | grep -F 'Dec 29 22:01'
Dec 29 22:01:09 meshmonitor meshmonitor[3148]: [INFO] ⏹️  Inactive node notification service stopped
Dec 29 22:01:09 meshmonitor meshmonitor[3148]: [INFO] 🔔 Starting inactive node notification service (checking every 60 minutes, threshold: 24 hours, cooldown: 24 hours)
Dec 29 22:01:09 meshmonitor meshmonitor[3148]: [INFO] ✅ Inactive node notification service restarted (threshold: 24h, check: 60min, cooldown: 24h)
Dec 29 22:01:11 meshmonitor meshmonitor[3148]: [INFO] 🔔 [POLL] Endpoint called
Dec 29 22:01:11 meshmonitor meshmonitor[3148]: [INFO] 🔍 getDeviceConfig called - actualDeviceConfig.lora present: true
Dec 29 22:01:11 meshmonitor meshmonitor[3148]: [INFO] 🔍 getDeviceConfig called - actualModuleConfig present: true
Dec 29 22:01:11 meshmonitor meshmonitor[3148]: [INFO] ✅ Returning device config from actualDeviceConfig
Dec 29 22:01:13 meshmonitor meshmonitor[3148]: [INFO] 🗺️ Traceroute response from !9e9fc688: {
Dec 29 22:01:13 meshmonitor meshmonitor[3148]:   "route": [
Dec 29 22:01:13 meshmonitor meshmonitor[3148]:     90278913
Dec 29 22:01:13 meshmonitor meshmonitor[3148]:   ],
Dec 29 22:01:13 meshmonitor meshmonitor[3148]:   "snrTowards": [
Dec 29 22:01:13 meshmonitor meshmonitor[3148]:     -51,
Dec 29 22:01:13 meshmonitor meshmonitor[3148]:     -55
Dec 29 22:01:13 meshmonitor meshmonitor[3148]:   ]
Dec 29 22:01:13 meshmonitor meshmonitor[3148]: }
Dec 29 22:01:13 meshmonitor meshmonitor[3148]: [INFO] 📢 Broadcasting notifyOnTraceroute notification to 0 subscriptions
Dec 29 22:01:13 meshmonitor meshmonitor[3148]: [INFO] 📢 notifyOnTraceroute broadcast complete: 0 sent, 0 failed, 0 filtered
Dec 29 22:01:13 meshmonitor meshmonitor[3148]: [INFO] 📢 Broadcasting notifyOnTraceroute notification to 0 Apprise users
Dec 29 22:01:13 meshmonitor meshmonitor[3148]: [INFO] 📢 notifyOnTraceroute Apprise broadcast complete: 0 sent, 0 failed, 0 filtered
Dec 29 22:01:13 meshmonitor meshmonitor[3148]: [INFO] 📤 Sent traceroute notification for !9e9fc688 → !bba9440c

[rest is truncated]

as i can see log says that it was response from 9e9fc688 (which is r9oot indeed) but it is not.

dpaschal pushed a commit to dpaschal/meshcore-monitor that referenced this pull request Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Route segments on map: outgoing trace route response shown

2 participants