Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/db/repositories/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,9 @@ export class MiscRepository extends BaseRepository {
to_node: row.to_node != null ? Number(row.to_node) : row.to_node,
relay_node: row.relay_node != null ? Number(row.relay_node) : row.relay_node,
created_at: row.created_at != null ? Number(row.created_at) : row.created_at,
// PostgreSQL lowercases unquoted aliases — normalize for frontend
from_node_longName: row.from_node_longName ?? row.from_node_longname ?? null,
to_node_longName: row.to_node_longName ?? row.to_node_longname ?? null,
} as DbPacketLog;
}

Expand Down
8 changes: 4 additions & 4 deletions src/db/repositories/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ export class NodesRepository extends BaseRepository {
lastPKIPacket: this.coerceBigintField(nodeData.lastPKIPacket ?? existingNode.lastPKIPacket),
// Don't update welcomedAt here - it's managed by markNodeAsWelcomedIfNotAlready
// to avoid race conditions where this upsert overwrites a concurrent welcome update
keyIsLowEntropy: nodeData.keyIsLowEntropy ?? existingNode.keyIsLowEntropy,
duplicateKeyDetected: nodeData.duplicateKeyDetected ?? existingNode.duplicateKeyDetected,
keyMismatchDetected: nodeData.keyMismatchDetected ?? existingNode.keyMismatchDetected,
keySecurityIssueDetails: nodeData.keySecurityIssueDetails ?? existingNode.keySecurityIssueDetails,
keyIsLowEntropy: nodeData.keyIsLowEntropy !== undefined ? nodeData.keyIsLowEntropy : existingNode.keyIsLowEntropy,
duplicateKeyDetected: nodeData.duplicateKeyDetected !== undefined ? nodeData.duplicateKeyDetected : existingNode.duplicateKeyDetected,
keyMismatchDetected: nodeData.keyMismatchDetected !== undefined ? nodeData.keyMismatchDetected : existingNode.keyMismatchDetected,
keySecurityIssueDetails: nodeData.keySecurityIssueDetails !== undefined ? nodeData.keySecurityIssueDetails : existingNode.keySecurityIssueDetails,
positionChannel: nodeData.positionChannel ?? existingNode.positionChannel,
positionPrecisionBits: nodeData.positionPrecisionBits ?? existingNode.positionPrecisionBits,
positionTimestamp: this.coerceBigintField(nodeData.positionTimestamp ?? existingNode.positionTimestamp),
Expand Down
10 changes: 5 additions & 5 deletions src/server/meshtasticManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2723,7 +2723,7 @@ class MeshtasticManager {
logger.warn(`⚠️ Low-entropy key detected for local node ${localNodeId}!`);
} else {
updateData.keyIsLowEntropy = false;
updateData.keySecurityIssueDetails = undefined;
updateData.keySecurityIssueDetails = null;
}

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

// Check if this node had a key mismatch that is now fixed
Expand Down Expand Up @@ -4398,10 +4398,10 @@ class MeshtasticManager {
}

nodeData.keyMismatchDetected = false;
nodeData.lastMeshReceivedKey = undefined;
nodeData.lastMeshReceivedKey = null;
// Don't clear keySecurityIssueDetails if there's a low-entropy issue
if (!isLowEntropy) {
nodeData.keySecurityIssueDetails = undefined;
nodeData.keySecurityIssueDetails = null;
}

// Clear the repair state and log success
Expand Down Expand Up @@ -5884,7 +5884,7 @@ class MeshtasticManager {
// Explicitly clear the flag when key is NOT low-entropy
// This ensures that if a node regenerates their key, the flag is cleared immediately
nodeData.keyIsLowEntropy = false;
nodeData.keySecurityIssueDetails = undefined;
nodeData.keySecurityIssueDetails = null;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/securityRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ router.post('/nodes/:nodeNum/clear', requirePermission('security', 'write'), asy
keyIsLowEntropy: false,
duplicateKeyDetected: false,
keyMismatchDetected: false,
keySecurityIssueDetails: undefined, // This will now properly clear the field
keySecurityIssueDetails: null, // null explicitly clears the field (undefined would preserve existing value)
});

// Clear time offset flags
Expand Down
Loading