From 7ceebe777736347a15c0b3d6161f8de341fcdc2b Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 2 Mar 2024 10:17:28 -0600 Subject: [PATCH 1/3] Filter out neighborinfo if we don't have the module enabled --- src/mesh/Router.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 4a6dc90074..3e40566aa2 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -469,8 +469,15 @@ void Router::perhapsHandleReceived(meshtastic_MeshPacket *p) // assert(radioConfig.has_preferences); bool ignore = is_in_repeated(config.lora.ignore_incoming, p->from) || (config.lora.ignore_mqtt && p->via_mqtt); + // Neighbor info module is disabled, ignore expensive neighbor info packets + if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag && + p->decoded.portnum == meshtastic_PortNum_NEIGHBORINFO_APP && + (!moduleConfig.has_neighbor_info || !moduleConfig.neighbor_info.enabled)) + ignore = true; + if (ignore) { - LOG_DEBUG("Ignoring incoming message, 0x%x is in our ignore list or came via MQTT\n", p->from); + LOG_DEBUG("Ignoring incoming message, 0x%x is in our ignore list, came via MQTT, or is on a portnum we haven't enabled\n", + p->from); } else if (ignore |= shouldFilterReceived(p)) { LOG_DEBUG("Incoming message was filtered 0x%x\n", p->from); } From 91a78d053a1835b502e21f80276ff477c404675c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 2 Mar 2024 17:03:15 -0600 Subject: [PATCH 2/3] Handlereceived instead --- src/mesh/Router.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 3e40566aa2..58ddc87ab2 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -435,6 +435,7 @@ NodeNum Router::getNodeNum() */ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src) { + bool skipHandle = false; // Also, we should set the time from the ISR and it should have msec level resolution p->rx_time = getValidTime(RTCQualityFromNet); // store the arrival timestamp for the phone // Store a copy of encrypted packet for MQTT @@ -451,8 +452,16 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src) else printPacket("handleReceived(REMOTE)", p); + // Neighbor info module is disabled, ignore expensive neighbor info packets + if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag && + p->decoded.portnum == meshtastic_PortNum_NEIGHBORINFO_APP && + (!moduleConfig.has_neighbor_info || !moduleConfig.neighbor_info.enabled)) { + cancelSending(p->from, p->id); + skipHandle = true; + } + // Publish received message to MQTT if we're not the original transmitter of the packet - if (moduleConfig.mqtt.enabled && getFrom(p) != nodeDB.getNodeNum() && mqtt) + if (!skipHandle && moduleConfig.mqtt.enabled && getFrom(p) != nodeDB.getNodeNum() && mqtt) mqtt->onSend(*p_encrypted, *p, p->channel); } else { printPacket("packet decoding failed or skipped (no PSK?)", p); @@ -461,7 +470,8 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src) packetPool.release(p_encrypted); // Release the encrypted packet // call modules here - MeshModule::callPlugins(*p, src); + if (!skipHandle) + MeshModule::callPlugins(*p, src); } void Router::perhapsHandleReceived(meshtastic_MeshPacket *p) @@ -469,15 +479,8 @@ void Router::perhapsHandleReceived(meshtastic_MeshPacket *p) // assert(radioConfig.has_preferences); bool ignore = is_in_repeated(config.lora.ignore_incoming, p->from) || (config.lora.ignore_mqtt && p->via_mqtt); - // Neighbor info module is disabled, ignore expensive neighbor info packets - if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag && - p->decoded.portnum == meshtastic_PortNum_NEIGHBORINFO_APP && - (!moduleConfig.has_neighbor_info || !moduleConfig.neighbor_info.enabled)) - ignore = true; - if (ignore) { - LOG_DEBUG("Ignoring incoming message, 0x%x is in our ignore list, came via MQTT, or is on a portnum we haven't enabled\n", - p->from); + LOG_DEBUG("Ignoring incoming message, 0x%x is in our ignore list or came via MQTT\n", p->from); } else if (ignore |= shouldFilterReceived(p)) { LOG_DEBUG("Incoming message was filtered 0x%x\n", p->from); } From 414148a2082c5ed4e868f6cc86516dec913d49d5 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 3 Mar 2024 08:34:57 -0600 Subject: [PATCH 3/3] Add debug message --- src/mesh/Router.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 58ddc87ab2..1d6a2d96b9 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -456,6 +456,7 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src) if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag && p->decoded.portnum == meshtastic_PortNum_NEIGHBORINFO_APP && (!moduleConfig.has_neighbor_info || !moduleConfig.neighbor_info.enabled)) { + LOG_DEBUG("Neighbor info module is disabled, ignoring neighbor packet\n"); cancelSending(p->from, p->id); skipHandle = true; }