add support to reload TG and RID lists via REST API for the FNE;

pull/55/head
Bryan Biedenkapp 2 years ago
parent 1de86458a6
commit 3335f7be39

@ -96,6 +96,13 @@ namespace lookups
return ret; return ret;
} }
/// <summary>Reads the lookup table from the specified lookup table file.</summary>
/// <returns>True, if lookup table was read, otherwise false.</returns>
virtual bool reload()
{
return load();
}
/// <summary>Clears all entries from the lookup table.</summary> /// <summary>Clears all entries from the lookup table.</summary>
virtual void clear() virtual void clear()
{ {

@ -395,6 +395,9 @@ namespace lookups
/// <summary>Reads the lookup table from the specified lookup table file.</summary> /// <summary>Reads the lookup table from the specified lookup table file.</summary>
/// <returns>True, if lookup table was read, otherwise false.</returns> /// <returns>True, if lookup table was read, otherwise false.</returns>
bool read(); bool read();
/// <summary>Reads the lookup table from the specified lookup table file.</summary>
/// <returns>True, if lookup table was read, otherwise false.</returns>
bool reload() { return load(); }
/// <summary>Clears all entries from the lookup table.</summary> /// <summary>Clears all entries from the lookup table.</summary>
void clear(); void clear();

@ -281,6 +281,13 @@ void FNENetwork::clock(uint32_t ms)
uint64_t now = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count(); uint64_t now = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();
if (m_forceListUpdate) {
for (auto peer : m_peers) {
peerACLUpdate(peer.first);
}
m_forceListUpdate = false;
}
m_maintainenceTimer.clock(ms); m_maintainenceTimer.clock(ms);
if (m_maintainenceTimer.isRunning() && m_maintainenceTimer.hasExpired()) { if (m_maintainenceTimer.isRunning() && m_maintainenceTimer.hasExpired()) {
// check to see if any peers have been quiet (no ping) longer than allowed // check to see if any peers have been quiet (no ping) longer than allowed

@ -310,6 +310,8 @@ namespace network
bool m_filterHeaders; bool m_filterHeaders;
bool m_filterTerminators; bool m_filterTerminators;
bool m_forceListUpdate;
std::vector<uint32_t> m_dropU2UPeerTable; std::vector<uint32_t> m_dropU2UPeerTable;
bool m_enableInfluxDB; bool m_enableInfluxDB;

@ -582,6 +582,9 @@ void RESTAPI::initializeEndpoints()
m_dispatcher.match(FNE_GET_FORCE_UPDATE).get(REST_API_BIND(RESTAPI::restAPI_GetForceUpdate, this)); m_dispatcher.match(FNE_GET_FORCE_UPDATE).get(REST_API_BIND(RESTAPI::restAPI_GetForceUpdate, this));
m_dispatcher.match(FNE_GET_RELOAD_TGS).get(REST_API_BIND(RESTAPI::restAPI_GetReloadTGs, this));
m_dispatcher.match(FNE_GET_RELOAD_RIDS).get(REST_API_BIND(RESTAPI::restAPI_GetReloadRIDs, this));
m_dispatcher.match(FNE_GET_AFF_LIST).get(REST_API_BIND(RESTAPI::restAPI_GetAffList, this)); m_dispatcher.match(FNE_GET_AFF_LIST).get(REST_API_BIND(RESTAPI::restAPI_GetAffList, this));
/* /*
@ -1171,11 +1174,55 @@ void RESTAPI::restAPI_GetForceUpdate(const HTTPPayload& request, HTTPPayload& re
json::object response = json::object(); json::object response = json::object();
setResponseDefaultStatus(response); setResponseDefaultStatus(response);
/*
if (m_network != nullptr) { if (m_network != nullptr) {
m_network->m_forceListUpdate = true; m_network->m_forceListUpdate = true;
} }
*/
reply.payload(response);
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="reply"></param>
/// <param name="match"></param>
void RESTAPI::restAPI_GetReloadTGs(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match)
{
if (!validateAuth(request, reply)) {
return;
}
json::object response = json::object();
setResponseDefaultStatus(response);
if (m_network != nullptr) {
m_network->m_tidLookup->reload();
}
reply.payload(response);
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="reply"></param>
/// <param name="match"></param>
void RESTAPI::restAPI_GetReloadRIDs(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match)
{
if (!validateAuth(request, reply)) {
return;
}
json::object response = json::object();
setResponseDefaultStatus(response);
if (m_network != nullptr) {
m_network->m_ridLookup->reload();
}
reply.payload(response); reply.payload(response);
} }

@ -127,6 +127,11 @@ private:
/// <summary></summary> /// <summary></summary>
void restAPI_GetForceUpdate(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); void restAPI_GetForceUpdate(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match);
/// <summary></summary>
void restAPI_GetReloadTGs(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match);
/// <summary></summary>
void restAPI_GetReloadRIDs(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match);
/// <summary></summary> /// <summary></summary>
void restAPI_GetAffList(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); void restAPI_GetAffList(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match);

@ -35,6 +35,9 @@
#define FNE_GET_FORCE_UPDATE "/force-update" #define FNE_GET_FORCE_UPDATE "/force-update"
#define FNE_GET_RELOAD_TGS "/reload-tgs"
#define FNE_GET_RELOAD_RIDS "/reload-rids"
#define FNE_GET_AFF_LIST "/report-affiliations" #define FNE_GET_AFF_LIST "/report-affiliations"
#endif // __FNE_REST_DEFINES_H__ #endif // __FNE_REST_DEFINES_H__

@ -45,6 +45,8 @@
#define RCD_FNE_GET_TGIDLIST "fne-tgidlist" #define RCD_FNE_GET_TGIDLIST "fne-tgidlist"
#define RCD_FNE_GET_FORCEUPDATE "fne-force-update" #define RCD_FNE_GET_FORCEUPDATE "fne-force-update"
#define RCD_FNE_GET_AFFLIST "fne-affs" #define RCD_FNE_GET_AFFLIST "fne-affs"
#define RCD_FNE_GET_RELOADTGS "fne-reload-tgs"
#define RCD_FNE_GET_RELOADRIDS "fne-reload-rids"
#define RCD_MODE "mdm-mode" #define RCD_MODE "mdm-mode"
#define RCD_MODE_OPT_IDLE "idle" #define RCD_MODE_OPT_IDLE "idle"
@ -200,6 +202,8 @@ void usage(const char* message, const char* arg)
reply += " fne-tgidlist Retrieves the list of configured TGIDs (Converged FNE only)\r\n"; reply += " fne-tgidlist Retrieves the list of configured TGIDs (Converged FNE only)\r\n";
reply += " fne-force-update Forces the FNE to send list update (Converged FNE only)\r\n"; reply += " fne-force-update Forces the FNE to send list update (Converged FNE only)\r\n";
reply += " fne-affs Retrieves the list of currently affiliated SUs (Converged FNE only)\r\n"; reply += " fne-affs Retrieves the list of currently affiliated SUs (Converged FNE only)\r\n";
reply += " fne-reload-tgs Forces the FNE to reload its TGID list from disk (Converged FNE only)\r\n";
reply += " fne-reload-rids Forces the FNE to reload its RID list from disk (Converged FNE only)\r\n";
reply += "\r\n"; reply += "\r\n";
reply += " mdm-mode <mode> Set current mode of host (idle, lockout, dmr, p25, nxdn)\r\n"; reply += " mdm-mode <mode> Set current mode of host (idle, lockout, dmr, p25, nxdn)\r\n";
reply += " mdm-kill Causes the host to quit\r\n"; reply += " mdm-kill Causes the host to quit\r\n";
@ -811,6 +815,12 @@ int main(int argc, char** argv)
else if (rcom == RCD_FNE_GET_AFFLIST) { else if (rcom == RCD_FNE_GET_AFFLIST) {
retCode = client->send(HTTP_GET, FNE_GET_AFF_LIST, json::object(), response); retCode = client->send(HTTP_GET, FNE_GET_AFF_LIST, json::object(), response);
} }
else if (rcom == RCD_FNE_GET_RELOADTGS) {
retCode = client->send(HTTP_GET, FNE_GET_RELOAD_TGS, json::object(), response);
}
else if (rcom == RCD_FNE_GET_RELOADRIDS) {
retCode = client->send(HTTP_GET, FNE_GET_RELOAD_RIDS, json::object(), response);
}
else { else {
args.clear(); args.clear();
LogError(LOG_REST, BAD_CMD_STR " (\"%s\")", rcom.c_str()); LogError(LOG_REST, BAD_CMD_STR " (\"%s\")", rcom.c_str());

Loading…
Cancel
Save

Powered by TurnKey Linux.