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
18 changes: 11 additions & 7 deletions src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
6 changes: 6 additions & 0 deletions src/mesh/PhoneAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,12 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
LOG_DEBUG("Send config: bluetooth");
fromRadioScratch.config.which_payload_variant = meshtastic_Config_bluetooth_tag;
fromRadioScratch.config.payload_variant.bluetooth = config.bluetooth;
#ifdef MESHTASTIC_PHONEAPI_ACCESS_CONTROL
if (!getAdminAuthorized()) {
// The pairing PIN is a shared secret; never expose it to an unauthenticated client.
fromRadioScratch.config.payload_variant.bluetooth.fixed_pin = 0;
}
#endif
break;
case meshtastic_Config_security_tag:
LOG_DEBUG("Send config: security");
Expand Down
6 changes: 6 additions & 0 deletions src/mesh/api/PacketAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
#include "RadioInterface.h"
#include "modules/NodeInfoModule.h"

#ifdef MESHTASTIC_PHONEAPI_ACCESS_CONTROL
// receivePacket() dispatches ToRadio straight to MeshService, bypassing handleToRadioPacket and so
// the lockdown admin gate. Fail the build rather than silently ship an admin-auth bypass.
#error "USE_PACKET_API is incompatible with MESHTASTIC_PHONEAPI_ACCESS_CONTROL (PacketAPI bypasses the lockdown admin gate)"
#endif

PacketAPI *packetAPI = nullptr;

PacketAPI *PacketAPI::create(PacketServer *_server)
Expand Down
Loading