From 28502a762fd02c42d528c76b2a9e10a776040a41 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 6 Dec 2023 14:02:41 -0600 Subject: [PATCH] Added Known-Only rebroadcast mode behavior (#2993) --- src/mesh/Router.cpp | 6 ++++++ src/modules/RoutingModule.cpp | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index b2d8d585d..ff657fd11 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -299,6 +299,12 @@ bool perhapsDecode(meshtastic_MeshPacket *p) config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_ALL_SKIP_DECODING) return false; + if (config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_KNOWN_ONLY && + !nodeDB.getMeshNode(p->from)->has_user) { + LOG_DEBUG("Node 0x%x not in NodeDB. Rebroadcast mode KNOWN_ONLY will ignore packet\n", p->from); + return false; + } + if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) return true; // If packet was already decoded just return diff --git a/src/modules/RoutingModule.cpp b/src/modules/RoutingModule.cpp index d81311481..edeb1fb86 100644 --- a/src/modules/RoutingModule.cpp +++ b/src/modules/RoutingModule.cpp @@ -46,5 +46,6 @@ void RoutingModule::sendAckNak(meshtastic_Routing_Error err, NodeNum to, PacketI RoutingModule::RoutingModule() : ProtobufModule("routing", meshtastic_PortNum_ROUTING_APP, &meshtastic_Routing_msg) { isPromiscuous = true; - encryptedOk = config.device.rebroadcast_mode != meshtastic_Config_DeviceConfig_RebroadcastMode_LOCAL_ONLY; + encryptedOk = config.device.rebroadcast_mode != meshtastic_Config_DeviceConfig_RebroadcastMode_LOCAL_ONLY && + config.device.rebroadcast_mode != meshtastic_Config_DeviceConfig_RebroadcastMode_KNOWN_ONLY; }