mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-21 18:52:36 +10:00
Lockdown PIN redaction, a build guard, and favorite compaction (#11285)
* Redact the pairing PIN from unauthorized lockdown clients * Fail the build when PacketAPI would bypass the lockdown gate * Compact kept favorites when resetting the node database * Make the compaction loop reference const
This commit is contained in:
+11
-7
@@ -1607,15 +1607,19 @@ void NodeDB::resetNodes(bool keepFavorites)
|
||||
numMeshNodes = 1;
|
||||
if (keepFavorites) {
|
||||
LOG_INFO("Clearing node database - preserving favorites");
|
||||
for (size_t i = 0; i < meshNodes->size(); i++) {
|
||||
meshtastic_NodeInfoLite &node = meshNodes->at(i);
|
||||
if (i > 0 && !nodeInfoLiteIsFavorite(&node)) {
|
||||
eraseNodeSatellites(node.num);
|
||||
node = meshtastic_NodeInfoLite();
|
||||
} else {
|
||||
// Compact favorites into contiguous low slots: zeroing in place leaves one above
|
||||
// numMeshNodes, invisible to every `i < numMeshNodes` scan yet still serialized to flash.
|
||||
for (size_t i = 1; i < meshNodes->size(); i++) {
|
||||
const meshtastic_NodeInfoLite &node = meshNodes->at(i);
|
||||
if (nodeInfoLiteIsFavorite(&node)) {
|
||||
if (numMeshNodes != i)
|
||||
meshNodes->at(numMeshNodes) = node;
|
||||
numMeshNodes += 1;
|
||||
} else if (node.num) {
|
||||
eraseNodeSatellites(node.num);
|
||||
}
|
||||
};
|
||||
}
|
||||
std::fill(nodeDatabase.nodes.begin() + numMeshNodes, nodeDatabase.nodes.end(), meshtastic_NodeInfoLite());
|
||||
} else {
|
||||
LOG_INFO("Clearing node database - removing favorites");
|
||||
for (size_t i = 1; i < meshNodes->size(); i++) {
|
||||
|
||||
Reference in New Issue
Block a user