Skip to content

Commit d07eb51

Browse files
Yerazeclaude
andauthored
fix: clear key mismatch warning after successful purge resolution (#2349) (#2365)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3c3c0bf commit d07eb51

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

src/server/meshtasticManager.ts

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4358,33 +4358,38 @@ class MeshtasticManager {
43584358
}
43594359
}
43604360

4361-
// Existing block — only runs for PKI-error-based mismatches, NOT our proactive detection
4361+
// Clear mismatch flag when keys now match (post-purge resolution)
4362+
// or when a new key arrives (PKI-error-based resolution)
43624363
if (!newMismatchDetected) {
43634364
if (existingNode && existingNode.keyMismatchDetected) {
43644365
const oldKey = existingNode.publicKey;
43654366
const newKey = nodeData.publicKey;
43664367

43674368
if (oldKey !== newKey) {
4368-
// Key has changed - the mismatch is fixed!
4369+
// Key has changed - the mismatch is fixed via new key
43694370
logger.info(`🔐 Key mismatch RESOLVED for node ${nodeId} (${user.longName}) - received new key`);
4370-
nodeData.keyMismatchDetected = false;
4371-
nodeData.lastMeshReceivedKey = undefined;
4372-
// Don't clear keySecurityIssueDetails if there's a low-entropy issue
4373-
if (!isLowEntropy) {
4374-
nodeData.keySecurityIssueDetails = undefined;
4375-
}
4376-
4377-
// Clear the repair state and log success
4378-
databaseService.clearKeyRepairStateAsync(fromNum);
4379-
const nodeName = user.longName || user.shortName || nodeId;
4380-
databaseService.logKeyRepairAttemptAsync(fromNum, nodeName, 'fixed', true);
4371+
} else {
4372+
// Keys now match - the mismatch was fixed (e.g., device re-synced after purge)
4373+
logger.info(`🔐 Key mismatch RESOLVED for node ${nodeId} (${user.longName}) - keys now match`);
4374+
}
43814375

4382-
// Emit update to UI
4383-
dataEventEmitter.emitNodeUpdate(fromNum, {
4384-
keyMismatchDetected: false,
4385-
keySecurityIssueDetails: isLowEntropy ? nodeData.keySecurityIssueDetails : undefined
4386-
});
4376+
nodeData.keyMismatchDetected = false;
4377+
nodeData.lastMeshReceivedKey = undefined;
4378+
// Don't clear keySecurityIssueDetails if there's a low-entropy issue
4379+
if (!isLowEntropy) {
4380+
nodeData.keySecurityIssueDetails = undefined;
43874381
}
4382+
4383+
// Clear the repair state and log success
4384+
databaseService.clearKeyRepairStateAsync(fromNum);
4385+
const nodeName = user.longName || user.shortName || nodeId;
4386+
databaseService.logKeyRepairAttemptAsync(fromNum, nodeName, 'fixed', true);
4387+
4388+
// Emit update to UI
4389+
dataEventEmitter.emitNodeUpdate(fromNum, {
4390+
keyMismatchDetected: false,
4391+
keySecurityIssueDetails: isLowEntropy ? nodeData.keySecurityIssueDetails : undefined
4392+
});
43884393
}
43894394
}
43904395
}

0 commit comments

Comments
 (0)