Uplink DMs not to us if MQTT encryption enabled (#5025)

* Uplink DMs not to us if MQTT encryption enabled

* Only really need to try uplinking encrypted packet if MQTT encryption is enabled

* Add log about publishing nothing when packet is not decrypted and encryption_enabled is false

* Improve comment
This commit is contained in:
GUVWAF
2024-10-10 22:11:58 +02:00
committed by GitHub
parent e8f287a36f
commit d55c08d5cd
3 changed files with 21 additions and 16 deletions

View File

@@ -613,8 +613,12 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
MeshModule::callModules(*p, src);
#if !MESHTASTIC_EXCLUDE_MQTT
// Mark as pki_encrypted if it is not yet decoded and MQTT encryption is also enabled, hash matches and it's a DM not to
// us (because we would be able to decrypt it)
if (!decoded && moduleConfig.mqtt.encryption_enabled && p->channel == 0x00 && p->to != NODENUM_BROADCAST && !isToUs(p))
p_encrypted->pki_encrypted = true;
// After potentially altering it, publish received message to MQTT if we're not the original transmitter of the packet
if ((decoded || (p->channel == 0x00 && p->to != NODENUM_BROADCAST)) && moduleConfig.mqtt.enabled && !isFromUs(p) && mqtt)
if ((decoded || p_encrypted->pki_encrypted) && moduleConfig.mqtt.enabled && !isFromUs(p) && mqtt)
mqtt->onSend(*p_encrypted, *p, p->channel);
#endif
}