added ability to save RID/TGID lookups from the FNE to local files

pull/51/head
W3AXL 2 years ago
parent b75389cd47
commit 9675f42db5

@ -62,6 +62,9 @@ network:
# Flag indicating whether the local host lookup tables (RID, TGID, etc) will be updated from the network. # Flag indicating whether the local host lookup tables (RID, TGID, etc) will be updated from the network.
updateLookups: false 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. # Flag indicating whether or not the host activity log will be sent to the network.
allowActivityTransfer: true allowActivityTransfer: true
# Flag indicating whether or not the host diagnostic log will be sent to the network. # Flag indicating whether or not the host diagnostic log will be sent to the network.

@ -382,10 +382,10 @@ bool TalkgroupRulesLookup::save()
for (auto entry : m_groupVoice) { for (auto entry : m_groupVoice) {
yaml::Node& gv = groupVoiceList.push_back(); yaml::Node& gv = groupVoiceList.push_back();
entry.getYaml(gv); entry.getYaml(gv);
LogDebug(LOG_HOST, "Added TGID %s to yaml TG list", gv["name"].as<std::string>().c_str()); //LogDebug(LOG_HOST, "Added TGID %s to yaml TG list", gv["name"].as<std::string>().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 // Set the new rules
newRules["groupVoice"] = groupVoiceList; newRules["groupVoice"] = groupVoiceList;
@ -397,7 +397,7 @@ bool TalkgroupRulesLookup::save()
} }
try { 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()); yaml::Serialize(newRules, m_rulesFile.c_str());
LogDebug(LOG_HOST, "Saved TGID config file to %s", m_rulesFile.c_str()); LogDebug(LOG_HOST, "Saved TGID config file to %s", m_rulesFile.c_str());
} }

@ -619,7 +619,7 @@ bool HostFNE::createPeerNetworks()
} }
// initialize networking // 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); network->setMetadata(identity, rxFrequency, txFrequency, 0.0F, 0.0F, 0, 0, 0, latitude, longitude, 0, location);
if (encrypted) { if (encrypted) {
network->setPresharedKey(presharedKey); network->setPresharedKey(presharedKey);

@ -44,8 +44,8 @@ using namespace network;
/// <param name="allowDiagnosticTransfer">Flag indicating that the system diagnostic logs will be sent to the network.</param> /// <param name="allowDiagnosticTransfer">Flag indicating that the system diagnostic logs will be sent to the network.</param>
/// <param name="updateLookup">Flag indicating that the system will accept radio ID and talkgroup ID lookups from the network.</param> /// <param name="updateLookup">Flag indicating that the system will accept radio ID and talkgroup ID lookups from the network.</param>
PeerNetwork::PeerNetwork(const std::string& address, uint16_t port, uint16_t localPort, uint32_t peerId, const std::string& password, 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) : 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), Network(address, port, localPort, peerId, password, duplex, debug, dmr, p25, nxdn, slot1, slot2, allowActivityTransfer, allowDiagnosticTransfer, updateLookup, saveLookup),
m_blockTrafficToTable() m_blockTrafficToTable()
{ {
assert(!address.empty()); assert(!address.empty());

@ -31,7 +31,7 @@ namespace network
public: public:
/// <summary>Initializes a new instance of the PeerNetwork class.</summary> /// <summary>Initializes a new instance of the PeerNetwork class.</summary>
PeerNetwork(const std::string& address, uint16_t port, uint16_t localPort, uint32_t peerId, const std::string& password, 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);
/// <summary>Gets the blocked traffic peer ID table.</summary> /// <summary>Gets the blocked traffic peer ID table.</summary>
std::vector<uint32_t> blockTrafficTo() const { return m_blockTrafficToTable; } std::vector<uint32_t> blockTrafficTo() const { return m_blockTrafficToTable; }

@ -672,6 +672,7 @@ bool Host::createNetwork()
bool allowActivityTransfer = networkConf["allowActivityTransfer"].as<bool>(false); bool allowActivityTransfer = networkConf["allowActivityTransfer"].as<bool>(false);
bool allowDiagnosticTransfer = networkConf["allowDiagnosticTransfer"].as<bool>(false); bool allowDiagnosticTransfer = networkConf["allowDiagnosticTransfer"].as<bool>(false);
bool updateLookup = networkConf["updateLookups"].as<bool>(false); bool updateLookup = networkConf["updateLookups"].as<bool>(false);
bool saveLookup = networkConf["saveLookups"].as<bool>(false);
bool debug = networkConf["debug"].as<bool>(false); bool debug = networkConf["debug"].as<bool>(false);
bool encrypted = networkConf["encrypted"].as<bool>(false); bool encrypted = networkConf["encrypted"].as<bool>(false);
@ -751,6 +752,7 @@ bool Host::createNetwork()
LogInfo(" Allow Activity Log Transfer: %s", allowActivityTransfer ? "yes" : "no"); LogInfo(" Allow Activity Log Transfer: %s", allowActivityTransfer ? "yes" : "no");
LogInfo(" Allow Diagnostic Log Transfer: %s", allowDiagnosticTransfer ? "yes" : "no"); LogInfo(" Allow Diagnostic Log Transfer: %s", allowDiagnosticTransfer ? "yes" : "no");
LogInfo(" Update Lookups: %s", updateLookup ? "yes" : "no"); LogInfo(" Update Lookups: %s", updateLookup ? "yes" : "no");
LogInfo(" Save Network Lookups: %s", saveLookup ? "yes" : "no");
LogInfo(" Encrypted: %s", encrypted ? "yes" : "no"); LogInfo(" Encrypted: %s", encrypted ? "yes" : "no");
@ -774,7 +776,14 @@ bool Host::createNetwork()
// initialize networking // initialize networking
if (netEnable) { 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->setLookups(m_ridLookup, m_tidLookup);
m_network->setMetadata(m_identity, m_rxFrequency, m_txFrequency, entry.txOffsetMhz(), entry.chBandwidthKhz(), m_channelId, m_channelNo, m_network->setMetadata(m_identity, m_rxFrequency, m_txFrequency, entry.txOffsetMhz(), entry.chBandwidthKhz(), m_channelId, m_channelNo,

@ -49,7 +49,7 @@ using namespace network;
/// <param name="allowDiagnosticTransfer">Flag indicating that the system diagnostic logs will be sent to the network.</param> /// <param name="allowDiagnosticTransfer">Flag indicating that the system diagnostic logs will be sent to the network.</param>
/// <param name="updateLookup">Flag indicating that the system will accept radio ID and talkgroup ID lookups from the network.</param> /// <param name="updateLookup">Flag indicating that the system will accept radio ID and talkgroup ID lookups from the network.</param>
Network::Network(const std::string& address, uint16_t port, uint16_t localPort, uint32_t peerId, const std::string& password, 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), BaseNetwork(peerId, duplex, debug, slot1, slot2, allowActivityTransfer, allowDiagnosticTransfer, localPort),
m_pktLastSeq(0U), m_pktLastSeq(0U),
m_address(address), m_address(address),
@ -60,6 +60,7 @@ Network::Network(const std::string& address, uint16_t port, uint16_t localPort,
m_p25Enabled(p25), m_p25Enabled(p25),
m_nxdnEnabled(nxdn), m_nxdnEnabled(nxdn),
m_updateLookup(updateLookup), m_updateLookup(updateLookup),
m_saveLookup(saveLookup),
m_ridLookup(nullptr), m_ridLookup(nullptr),
m_tidLookup(nullptr), m_tidLookup(nullptr),
m_salt(nullptr), m_salt(nullptr),
@ -397,6 +398,10 @@ void Network::clock(uint32_t ms)
offs += 4U; offs += 4U;
} }
LogMessage(LOG_NET, "Network Announced %u whitelisted RIDs", len); 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; offs += 4U;
} }
LogMessage(LOG_NET, "Network Announced %u blacklisted RIDs", len); 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; offs += 5U;
} }
LogMessage(LOG_NET, "Activated %u TGs; loaded %u entries into lookup table", len, m_tidLookup->groupVoice().size()); 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; offs += 5U;
} }
LogMessage(LOG_NET, "Deactivated %u TGs; loaded %u entries into lookup table", len, m_tidLookup->groupVoice().size()); 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();
}
} }
} }
} }

@ -34,7 +34,7 @@ namespace network
public: public:
/// <summary>Initializes a new instance of the Network class.</summary> /// <summary>Initializes a new instance of the Network class.</summary>
Network(const std::string& address, uint16_t port, uint16_t localPort, uint32_t peerId, const std::string& password, 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);
/// <summary>Finalizes a instance of the Network class.</summary> /// <summary>Finalizes a instance of the Network class.</summary>
~Network() override; ~Network() override;
@ -84,6 +84,7 @@ namespace network
bool m_nxdnEnabled; bool m_nxdnEnabled;
bool m_updateLookup; bool m_updateLookup;
bool m_saveLookup;
lookups::RadioIdLookup* m_ridLookup; lookups::RadioIdLookup* m_ridLookup;
lookups::TalkgroupRulesLookup* m_tidLookup; lookups::TalkgroupRulesLookup* m_tidLookup;

Loading…
Cancel
Save

Powered by TurnKey Linux.