Skip to content

Commit 3526e82

Browse files
Yerazeclaude
andauthored
fix: PG packet monitor names and key mismatch flag not clearing (#2406)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4f5858a commit 3526e82

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

src/db/repositories/misc.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,9 @@ export class MiscRepository extends BaseRepository {
838838
to_node: row.to_node != null ? Number(row.to_node) : row.to_node,
839839
relay_node: row.relay_node != null ? Number(row.relay_node) : row.relay_node,
840840
created_at: row.created_at != null ? Number(row.created_at) : row.created_at,
841+
// PostgreSQL lowercases unquoted aliases — normalize for frontend
842+
from_node_longName: row.from_node_longName ?? row.from_node_longname ?? null,
843+
to_node_longName: row.to_node_longName ?? row.to_node_longname ?? null,
841844
} as DbPacketLog;
842845
}
843846

src/db/repositories/nodes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ export class NodesRepository extends BaseRepository {
164164
lastPKIPacket: this.coerceBigintField(nodeData.lastPKIPacket ?? existingNode.lastPKIPacket),
165165
// Don't update welcomedAt here - it's managed by markNodeAsWelcomedIfNotAlready
166166
// to avoid race conditions where this upsert overwrites a concurrent welcome update
167-
keyIsLowEntropy: nodeData.keyIsLowEntropy ?? existingNode.keyIsLowEntropy,
168-
duplicateKeyDetected: nodeData.duplicateKeyDetected ?? existingNode.duplicateKeyDetected,
169-
keyMismatchDetected: nodeData.keyMismatchDetected ?? existingNode.keyMismatchDetected,
170-
keySecurityIssueDetails: nodeData.keySecurityIssueDetails ?? existingNode.keySecurityIssueDetails,
167+
keyIsLowEntropy: nodeData.keyIsLowEntropy !== undefined ? nodeData.keyIsLowEntropy : existingNode.keyIsLowEntropy,
168+
duplicateKeyDetected: nodeData.duplicateKeyDetected !== undefined ? nodeData.duplicateKeyDetected : existingNode.duplicateKeyDetected,
169+
keyMismatchDetected: nodeData.keyMismatchDetected !== undefined ? nodeData.keyMismatchDetected : existingNode.keyMismatchDetected,
170+
keySecurityIssueDetails: nodeData.keySecurityIssueDetails !== undefined ? nodeData.keySecurityIssueDetails : existingNode.keySecurityIssueDetails,
171171
positionChannel: nodeData.positionChannel ?? existingNode.positionChannel,
172172
positionPrecisionBits: nodeData.positionPrecisionBits ?? existingNode.positionPrecisionBits,
173173
positionTimestamp: this.coerceBigintField(nodeData.positionTimestamp ?? existingNode.positionTimestamp),

src/server/meshtasticManager.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,7 +2723,7 @@ class MeshtasticManager {
27232723
logger.warn(`⚠️ Low-entropy key detected for local node ${localNodeId}!`);
27242724
} else {
27252725
updateData.keyIsLowEntropy = false;
2726-
updateData.keySecurityIssueDetails = undefined;
2726+
updateData.keySecurityIssueDetails = null;
27272727
}
27282728

27292729
await databaseService.nodes.upsertNode(updateData);
@@ -4322,7 +4322,7 @@ class MeshtasticManager {
43224322
// Explicitly clear the flag when key is NOT low-entropy
43234323
// This ensures that if a node regenerates their key, the flag is cleared immediately
43244324
nodeData.keyIsLowEntropy = false;
4325-
nodeData.keySecurityIssueDetails = undefined;
4325+
nodeData.keySecurityIssueDetails = null;
43264326
}
43274327

43284328
// Check if this node had a key mismatch that is now fixed
@@ -4398,10 +4398,10 @@ class MeshtasticManager {
43984398
}
43994399

44004400
nodeData.keyMismatchDetected = false;
4401-
nodeData.lastMeshReceivedKey = undefined;
4401+
nodeData.lastMeshReceivedKey = null;
44024402
// Don't clear keySecurityIssueDetails if there's a low-entropy issue
44034403
if (!isLowEntropy) {
4404-
nodeData.keySecurityIssueDetails = undefined;
4404+
nodeData.keySecurityIssueDetails = null;
44054405
}
44064406

44074407
// Clear the repair state and log success
@@ -5884,7 +5884,7 @@ class MeshtasticManager {
58845884
// Explicitly clear the flag when key is NOT low-entropy
58855885
// This ensures that if a node regenerates their key, the flag is cleared immediately
58865886
nodeData.keyIsLowEntropy = false;
5887-
nodeData.keySecurityIssueDetails = undefined;
5887+
nodeData.keySecurityIssueDetails = null;
58885888
}
58895889
}
58905890
}

src/server/routes/securityRoutes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ router.post('/nodes/:nodeNum/clear', requirePermission('security', 'write'), asy
275275
keyIsLowEntropy: false,
276276
duplicateKeyDetected: false,
277277
keyMismatchDetected: false,
278-
keySecurityIssueDetails: undefined, // This will now properly clear the field
278+
keySecurityIssueDetails: null, // null explicitly clears the field (undefined would preserve existing value)
279279
});
280280

281281
// Clear time offset flags

0 commit comments

Comments
 (0)