diff --git a/configs/config.example.yml b/configs/config.example.yml index fe838c43..09af266c 100644 --- a/configs/config.example.yml +++ b/configs/config.example.yml @@ -62,6 +62,9 @@ network: # Flag indicating whether the local host lookup tables (RID, TGID, etc) will be updated from the network. updateLookups: false + # Flag indicating whether the local host lookup tables will be saved to local files when updated from the network + # This is handy if your site occasionally operates in site trunking mode without a connection to the FNE + saveLookups: false # Flag indicating whether or not the host activity log will be sent to the network. allowActivityTransfer: true # Flag indicating whether or not the host diagnostic log will be sent to the network. diff --git a/src/common/lookups/TalkgroupRulesLookup.cpp b/src/common/lookups/TalkgroupRulesLookup.cpp index 7864912c..a0404c85 100644 --- a/src/common/lookups/TalkgroupRulesLookup.cpp +++ b/src/common/lookups/TalkgroupRulesLookup.cpp @@ -382,10 +382,10 @@ bool TalkgroupRulesLookup::save() for (auto entry : m_groupVoice) { yaml::Node& gv = groupVoiceList.push_back(); entry.getYaml(gv); - LogDebug(LOG_HOST, "Added TGID %s to yaml TG list", gv["name"].as().c_str()); + //LogDebug(LOG_HOST, "Added TGID %s to yaml TG list", gv["name"].as().c_str()); } - LogDebug(LOG_HOST, "Got final GroupVoiceList YAML size of %u", groupVoiceList.size()); + //LogDebug(LOG_HOST, "Got final GroupVoiceList YAML size of %u", groupVoiceList.size()); // Set the new rules newRules["groupVoice"] = groupVoiceList; @@ -397,7 +397,7 @@ bool TalkgroupRulesLookup::save() } try { - LogDebug(LOG_HOST, "Saving TGID file to %s", m_rulesFile.c_str()); + //LogDebug(LOG_HOST, "Saving TGID file to %s", m_rulesFile.c_str()); yaml::Serialize(newRules, m_rulesFile.c_str()); LogDebug(LOG_HOST, "Saved TGID config file to %s", m_rulesFile.c_str()); } diff --git a/src/fne/HostFNE.cpp b/src/fne/HostFNE.cpp index a118c3b5..a82e2598 100644 --- a/src/fne/HostFNE.cpp +++ b/src/fne/HostFNE.cpp @@ -619,7 +619,7 @@ bool HostFNE::createPeerNetworks() } // initialize networking - network::PeerNetwork* network = new PeerNetwork(masterAddress, masterPort, 0U, id, password, true, debug, m_dmrEnabled, m_p25Enabled, m_nxdnEnabled, true, true, m_allowActivityTransfer, m_allowDiagnosticTransfer, false); + network::PeerNetwork* network = new PeerNetwork(masterAddress, masterPort, 0U, id, password, true, debug, m_dmrEnabled, m_p25Enabled, m_nxdnEnabled, true, true, m_allowActivityTransfer, m_allowDiagnosticTransfer, false, false); network->setMetadata(identity, rxFrequency, txFrequency, 0.0F, 0.0F, 0, 0, 0, latitude, longitude, 0, location); if (encrypted) { network->setPresharedKey(presharedKey); diff --git a/src/fne/network/PeerNetwork.cpp b/src/fne/network/PeerNetwork.cpp index 02fb7306..3595f9d2 100644 --- a/src/fne/network/PeerNetwork.cpp +++ b/src/fne/network/PeerNetwork.cpp @@ -44,8 +44,8 @@ using namespace network; /// Flag indicating that the system diagnostic logs will be sent to the network. /// Flag indicating that the system will accept radio ID and talkgroup ID lookups from the network. PeerNetwork::PeerNetwork(const std::string& address, uint16_t port, uint16_t localPort, uint32_t peerId, const std::string& password, - bool duplex, bool debug, bool dmr, bool p25, bool nxdn, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup) : - Network(address, port, localPort, peerId, password, duplex, debug, dmr, p25, nxdn, slot1, slot2, allowActivityTransfer, allowDiagnosticTransfer, updateLookup), + bool duplex, bool debug, bool dmr, bool p25, bool nxdn, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup, bool saveLookup) : + Network(address, port, localPort, peerId, password, duplex, debug, dmr, p25, nxdn, slot1, slot2, allowActivityTransfer, allowDiagnosticTransfer, updateLookup, saveLookup), m_blockTrafficToTable() { assert(!address.empty()); diff --git a/src/fne/network/PeerNetwork.h b/src/fne/network/PeerNetwork.h index 26f4c8e1..51bf463c 100644 --- a/src/fne/network/PeerNetwork.h +++ b/src/fne/network/PeerNetwork.h @@ -31,7 +31,7 @@ namespace network public: /// Initializes a new instance of the PeerNetwork class. PeerNetwork(const std::string& address, uint16_t port, uint16_t localPort, uint32_t peerId, const std::string& password, - bool duplex, bool debug, bool dmr, bool p25, bool nxdn, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup); + bool duplex, bool debug, bool dmr, bool p25, bool nxdn, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup, bool saveLookup); /// Gets the blocked traffic peer ID table. std::vector blockTrafficTo() const { return m_blockTrafficToTable; } diff --git a/src/host/Host.Config.cpp b/src/host/Host.Config.cpp index 274ef1d4..c3eb6c54 100644 --- a/src/host/Host.Config.cpp +++ b/src/host/Host.Config.cpp @@ -672,6 +672,7 @@ bool Host::createNetwork() bool allowActivityTransfer = networkConf["allowActivityTransfer"].as(false); bool allowDiagnosticTransfer = networkConf["allowDiagnosticTransfer"].as(false); bool updateLookup = networkConf["updateLookups"].as(false); + bool saveLookup = networkConf["saveLookups"].as(false); bool debug = networkConf["debug"].as(false); bool encrypted = networkConf["encrypted"].as(false); @@ -751,6 +752,7 @@ bool Host::createNetwork() LogInfo(" Allow Activity Log Transfer: %s", allowActivityTransfer ? "yes" : "no"); LogInfo(" Allow Diagnostic Log Transfer: %s", allowDiagnosticTransfer ? "yes" : "no"); LogInfo(" Update Lookups: %s", updateLookup ? "yes" : "no"); + LogInfo(" Save Network Lookups: %s", saveLookup ? "yes" : "no"); LogInfo(" Encrypted: %s", encrypted ? "yes" : "no"); @@ -774,7 +776,14 @@ bool Host::createNetwork() // initialize networking if (netEnable) { - m_network = new Network(address, port, local, id, password, m_duplex, debug, m_dmrEnabled, m_p25Enabled, m_nxdnEnabled, slot1, slot2, allowActivityTransfer, allowDiagnosticTransfer, updateLookup); + m_network = new Network( + address, port, local, + id, password, m_duplex, + debug, m_dmrEnabled, m_p25Enabled, + m_nxdnEnabled, slot1, slot2, + allowActivityTransfer, allowDiagnosticTransfer, updateLookup, + saveLookup + ); m_network->setLookups(m_ridLookup, m_tidLookup); m_network->setMetadata(m_identity, m_rxFrequency, m_txFrequency, entry.txOffsetMhz(), entry.chBandwidthKhz(), m_channelId, m_channelNo, diff --git a/src/host/network/Network.cpp b/src/host/network/Network.cpp index 189c7a72..d76e03b0 100644 --- a/src/host/network/Network.cpp +++ b/src/host/network/Network.cpp @@ -49,7 +49,7 @@ using namespace network; /// Flag indicating that the system diagnostic logs will be sent to the network. /// Flag indicating that the system will accept radio ID and talkgroup ID lookups from the network. Network::Network(const std::string& address, uint16_t port, uint16_t localPort, uint32_t peerId, const std::string& password, - bool duplex, bool debug, bool dmr, bool p25, bool nxdn, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup) : + bool duplex, bool debug, bool dmr, bool p25, bool nxdn, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup, bool saveLookup) : BaseNetwork(peerId, duplex, debug, slot1, slot2, allowActivityTransfer, allowDiagnosticTransfer, localPort), m_pktLastSeq(0U), m_address(address), @@ -60,6 +60,7 @@ Network::Network(const std::string& address, uint16_t port, uint16_t localPort, m_p25Enabled(p25), m_nxdnEnabled(nxdn), m_updateLookup(updateLookup), + m_saveLookup(saveLookup), m_ridLookup(nullptr), m_tidLookup(nullptr), m_salt(nullptr), @@ -397,6 +398,10 @@ void Network::clock(uint32_t ms) offs += 4U; } LogMessage(LOG_NET, "Network Announced %u whitelisted RIDs", len); + // Save to file if enabled and we got RIDs + if (m_saveLookup && len > 0) { + m_ridLookup->commit(); + } } } } @@ -415,6 +420,10 @@ void Network::clock(uint32_t ms) offs += 4U; } LogMessage(LOG_NET, "Network Announced %u blacklisted RIDs", len); + // Save to file if enabled and we got RIDs + if (m_saveLookup && len > 0) { + m_ridLookup->commit(); + } } } } @@ -444,6 +453,10 @@ void Network::clock(uint32_t ms) offs += 5U; } LogMessage(LOG_NET, "Activated %u TGs; loaded %u entries into lookup table", len, m_tidLookup->groupVoice().size()); + // Save if saving from network is enabled + if (m_saveLookup && len > 0) { + m_tidLookup->commit(); + } } } } @@ -469,6 +482,10 @@ void Network::clock(uint32_t ms) offs += 5U; } LogMessage(LOG_NET, "Deactivated %u TGs; loaded %u entries into lookup table", len, m_tidLookup->groupVoice().size()); + // Save if saving from network is enabled + if (m_saveLookup && len > 0) { + m_tidLookup->commit(); + } } } } diff --git a/src/host/network/Network.h b/src/host/network/Network.h index e1db1aa8..b22e14ef 100644 --- a/src/host/network/Network.h +++ b/src/host/network/Network.h @@ -34,7 +34,7 @@ namespace network public: /// Initializes a new instance of the Network class. Network(const std::string& address, uint16_t port, uint16_t localPort, uint32_t peerId, const std::string& password, - bool duplex, bool debug, bool dmr, bool p25, bool nxdn, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup); + bool duplex, bool debug, bool dmr, bool p25, bool nxdn, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup, bool saveLookup); /// Finalizes a instance of the Network class. ~Network() override; @@ -84,6 +84,7 @@ namespace network bool m_nxdnEnabled; bool m_updateLookup; + bool m_saveLookup; lookups::RadioIdLookup* m_ridLookup; lookups::TalkgroupRulesLookup* m_tidLookup;