From 2258e3a06587e8a57091a4c47ef6e9d3d2c23e6e Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Wed, 19 Mar 2025 10:58:03 -0400 Subject: [PATCH] correct issue with passing a key request to the upstream master; comment on self-delete operations, stop() for lookup tables; --- src/common/lookups/LookupTable.h | 1 + src/common/lookups/PeerListLookup.cpp | 2 +- src/common/lookups/TalkgroupRulesLookup.h | 1 + src/fne/CryptoContainer.h | 1 + src/fne/HostFNE.cpp | 5 +++++ src/fne/network/FNENetwork.cpp | 12 +++++++----- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/common/lookups/LookupTable.h b/src/common/lookups/LookupTable.h index 5fadd79c..452db861 100644 --- a/src/common/lookups/LookupTable.h +++ b/src/common/lookups/LookupTable.h @@ -86,6 +86,7 @@ namespace lookups /** * @brief Stops and unloads this lookup table. + * (NOTE: If the reload time for this lookup table is set to 0, a call to stop will also delete the object.) * @param noDestroy Flag indicating the lookup table should remain resident in memory after stopping. */ virtual void stop(bool noDestroy = false) diff --git a/src/common/lookups/PeerListLookup.cpp b/src/common/lookups/PeerListLookup.cpp index b41f1f15..eac7e77e 100644 --- a/src/common/lookups/PeerListLookup.cpp +++ b/src/common/lookups/PeerListLookup.cpp @@ -240,7 +240,7 @@ bool PeerListLookup::load() m_table[id] = PeerId(id, alias, password, peerLink, canRequestKeys, false); // Log depending on what was loaded - LogMessage(LOG_HOST, "Loaded peer ID %u%s into peer ID lookup table, %s%s", id, + LogMessage(LOG_HOST, "Loaded peer ID %u%s into peer ID lookup table, %s%s%s", id, (!alias.empty() ? (" (" + alias + ")").c_str() : ""), (!password.empty() ? "using unique peer password" : "using master password"), (peerLink) ? ", Peer-Link Enabled" : "", diff --git a/src/common/lookups/TalkgroupRulesLookup.h b/src/common/lookups/TalkgroupRulesLookup.h index 2df3e4ec..0bbb5f97 100644 --- a/src/common/lookups/TalkgroupRulesLookup.h +++ b/src/common/lookups/TalkgroupRulesLookup.h @@ -557,6 +557,7 @@ namespace lookups void stop(bool noDestroy = false); /** * @brief Reads the lookup table from the specified lookup table file. + * (NOTE: If the reload time for this lookup table is set to 0, a call to stop will also delete the object.) * @returns bool True, if lookup table was read, otherwise false. */ bool read(); diff --git a/src/fne/CryptoContainer.h b/src/fne/CryptoContainer.h index 0957d7fe..5d9842c6 100644 --- a/src/fne/CryptoContainer.h +++ b/src/fne/CryptoContainer.h @@ -184,6 +184,7 @@ public: /** * @brief Stops and unloads this lookup table. + * (NOTE: If the reload time for this lookup table is set to 0, a call to stop will also delete the object.) * @param noDestroy Flag indicating the lookup table should remain resident in memory after stopping. */ void stop(bool noDestroy = false); diff --git a/src/fne/HostFNE.cpp b/src/fne/HostFNE.cpp index 7bcdbe13..7709916e 100644 --- a/src/fne/HostFNE.cpp +++ b/src/fne/HostFNE.cpp @@ -295,6 +295,11 @@ int HostFNE::run() m_peerListLookup->setReloadTime(0U); // no reload m_peerListLookup->stop(); } + + if (m_cryptoLookup != nullptr) { + m_cryptoLookup->setReloadTime(0U); // no reload + m_cryptoLookup->stop(); + } #if !defined(_WIN32) if (m_tun != nullptr) { if (m_tun->isUp()) { diff --git a/src/fne/network/FNENetwork.cpp b/src/fne/network/FNENetwork.cpp index e15b04d4..2c51fc86 100644 --- a/src/fne/network/FNENetwork.cpp +++ b/src/fne/network/FNENetwork.cpp @@ -1122,8 +1122,10 @@ void* FNENetwork::threadedNetworkRx(void* arg) if (peerEntry.peerDefault()) { break; } else { - if (!peerEntry.canRequestKeys()) + if (!peerEntry.canRequestKeys()) { + LogError(LOG_NET, "PEER %u (%s) requested enc. key but is not allowed, no response", peerId, connection->identity().c_str()); break; + } } } } @@ -1188,15 +1190,15 @@ void* FNENetwork::threadedNetworkRx(void* arg) for (auto peer : network->m_host->m_peerNetworks) { if (peer.second != nullptr) { if (peer.second->isEnabled() && peer.second->isPeerLink()) { - LogMessage(LOG_NET, "PEER %u (%s) requesting key from upstream master, algId = $%02X, kID = $%04X", peerId, connection->identity().c_str(), + LogMessage(LOG_NET, "PEER %u (%s) no local key or container, requesting key from upstream master, algId = $%02X, kID = $%04X", peerId, connection->identity().c_str(), modifyKey->getAlgId(), modifyKey->getKId()); network->m_keyQueueMutex.try_lock_for(std::chrono::milliseconds(60)); network->m_peerLinkKeyQueue[peerId] = modifyKey->getKId(); network->m_keyQueueMutex.unlock(); - peer.second->writeMaster({ NET_FUNC::KEY_RSP, NET_SUBFUNC::NOP }, - req->buffer, req->length, RTP_END_OF_CALL_SEQ, 0U, false, false, peerId); + peer.second->writeMaster({ NET_FUNC::KEY_REQ, NET_SUBFUNC::NOP }, + req->buffer, req->length, RTP_END_OF_CALL_SEQ, 0U, false, false); } } } @@ -2640,7 +2642,7 @@ void FNENetwork::processTEKResponse(p25::kmm::KeyItem* rspKi, uint8_t algId, uin if (rspKi == nullptr) return; - LogMessage(LOG_NET, "Remote enc. key, algId = $%02X, kID = $%04X", algId, rspKi->kId()); + LogMessage(LOG_NET, "upstream master enc. key, algId = $%02X, kID = $%04X", algId, rspKi->kId()); m_keyQueueMutex.lock();