diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index ed6e59ac13..51469ddc01 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -1231,12 +1231,12 @@ meshtastic_NodeInfoLite *NodeDB::getOrCreateMeshNode(NodeNum n) int oldestBoringIndex = -1; for (int i = 1; i < numMeshNodes; i++) { // Simply the oldest non-favorite node - if (!meshNodes->at(i).is_favorite && meshNodes->at(i).last_heard < oldest) { + if (!meshNodes->at(i).is_favorite && !meshNodes->at(i).is_ignored && meshNodes->at(i).last_heard < oldest) { oldest = meshNodes->at(i).last_heard; oldestIndex = i; } // The oldest "boring" node - if (!meshNodes->at(i).is_favorite && meshNodes->at(i).user.public_key.size == 0 && + if (!meshNodes->at(i).is_favorite && !meshNodes->at(i).is_ignored && meshNodes->at(i).user.public_key.size == 0 && meshNodes->at(i).last_heard < oldestBoring) { oldestBoring = meshNodes->at(i).last_heard; oldestBoringIndex = i; diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index d2017c2574..0663eec983 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -659,6 +659,13 @@ void Router::perhapsHandleReceived(meshtastic_MeshPacket *p) return; } + meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(p->from); + if (node != NULL && node->is_ignored) { + LOG_DEBUG("Ignore msg, 0x%x is ignored", p->from); + packetPool.release(p); + return; + } + if (p->from == NODENUM_BROADCAST) { LOG_DEBUG("Ignore msg from broadcast address"); packetPool.release(p); diff --git a/src/mesh/TypeConversions.cpp b/src/mesh/TypeConversions.cpp index 550f87021e..5fc6b8a646 100644 --- a/src/mesh/TypeConversions.cpp +++ b/src/mesh/TypeConversions.cpp @@ -12,6 +12,7 @@ meshtastic_NodeInfo TypeConversions::ConvertToNodeInfo(const meshtastic_NodeInfo info.channel = lite->channel; info.via_mqtt = lite->via_mqtt; info.is_favorite = lite->is_favorite; + info.is_ignored = lite->is_ignored; if (lite->has_hops_away) { info.has_hops_away = true; diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 5401e1fdb1..2ed053baed 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -283,6 +283,28 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta } break; } + case meshtastic_AdminMessage_set_ignored_node_tag: { + LOG_INFO("Client received set_ignored_node command"); + meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(r->set_ignored_node); + if (node != NULL) { + node->is_ignored = true; + node->has_device_metrics = false; + node->has_position = false; + node->user.public_key.size = 0; + node->user.public_key.bytes[0] = 0; + saveChanges(SEGMENT_DEVICESTATE, false); + } + break; + } + case meshtastic_AdminMessage_remove_ignored_node_tag: { + LOG_INFO("Client received remove_ignored_node command"); + meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(r->remove_ignored_node); + if (node != NULL) { + node->is_ignored = false; + saveChanges(SEGMENT_DEVICESTATE, false); + } + break; + } case meshtastic_AdminMessage_set_fixed_position_tag: { LOG_INFO("Client received set_fixed_position command"); meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeDB->getNodeNum());