diff --git a/controller/EmbeddedNetworkController.cpp b/controller/EmbeddedNetworkController.cpp index 3ec024542..514e06d1f 100644 --- a/controller/EmbeddedNetworkController.cpp +++ b/controller/EmbeddedNetworkController.cpp @@ -569,26 +569,6 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpGET( } // else 404 - } else if ((path.size() == 1)&&(path[0] == "memberStatus")) { - - const uint64_t now = OSUtils::now(); - Mutex::Lock _l(_memberStatus_m); - responseBody.push_back('{'); - _db.eachId([this,&responseBody,&now](uint64_t networkId,uint64_t nodeId) { - char tmp[64]; - auto ms = this->_memberStatus.find(_MemberStatusKey(networkId,nodeId)); - Utils::snprintf(tmp,sizeof(tmp),"%s\"%.16llx-%.10llx\":%s", - (responseBody.length() > 1) ? "," : "", - (unsigned long long)networkId, - (unsigned long long)nodeId, - ((ms != _memberStatus.end())&&(ms->second.online(now))) ? "true" : "false"); - responseBody.append(tmp); - }); - responseBody.push_back('}'); - responseContentType = "application/json"; - - return 200; - } else { char tmp[4096]; @@ -1071,14 +1051,31 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpPOST( } else if (path[0] == "ping") { - json testRec; const uint64_t now = OSUtils::now(); - testRec["clock"] = now; - testRec["startTime"] = _startTime; - testRec["content"] = b; - responseBody = OSUtils::jsonDump(testRec); - _db.writeRaw("pong",responseBody); + bool first = true; + std::string pong("{\"memberStatus\":{"); + { + Mutex::Lock _l(_memberStatus_m); + _db.eachId([this,&pong,&now,&first](uint64_t networkId,uint64_t nodeId) { + char tmp[64]; + auto ms = this->_memberStatus.find(_MemberStatusKey(networkId,nodeId)); + Utils::snprintf(tmp,sizeof(tmp),"%s\"%.16llx-%.10llx\":%s", + (first) ? "" : ",", + (unsigned long long)networkId, + (unsigned long long)nodeId, + ((ms != _memberStatus.end())&&(ms->second.online(now))) ? "true" : "false"); + pong.append(tmp); + first = false; + }); + } + char tmp2[256]; + Utils::snprintf(tmp2,sizeof(tmp2),"},\"clock\":%llu,\"startTime\":%llu}",(unsigned long long)now,(unsigned long long)_startTime); + pong.append(tmp2); + _db.writeRaw("pong",pong); + + responseBody = "{}"; responseContentType = "application/json"; + return 200; } diff --git a/controller/EmbeddedNetworkController.hpp b/controller/EmbeddedNetworkController.hpp index faf7f0297..0a6b81762 100644 --- a/controller/EmbeddedNetworkController.hpp +++ b/controller/EmbeddedNetworkController.hpp @@ -114,7 +114,6 @@ private: if (!member.count("authorized")) member["authorized"] = false; if (!member.count("authHistory")) member["authHistory"] = nlohmann::json::array(); if (!member.count("ipAssignments")) member["ipAssignments"] = nlohmann::json::array(); - if (!member.count("recentLog")) member["recentLog"] = nlohmann::json::array(); if (!member.count("activeBridge")) member["activeBridge"] = false; if (!member.count("tags")) member["tags"] = nlohmann::json::array(); if (!member.count("capabilities")) member["capabilities"] = nlohmann::json::array(); @@ -123,6 +122,11 @@ private: if (!member.count("revision")) member["revision"] = 0ULL; if (!member.count("lastDeauthorizedTime")) member["lastDeauthorizedTime"] = 0ULL; if (!member.count("lastAuthorizedTime")) member["lastAuthorizedTime"] = 0ULL; + if (!member.count("vMajor")) member["vMajor"] = -1; + if (!member.count("vMinor")) member["vMinor"] = -1; + if (!member.count("vRev")) member["vRev"] = -1; + if (!member.count("vProto")) member["vProto"] = -1; + if (!member.count("physicalAddr")) member["physicalAddr"] = nlohmann::json(); member["objtype"] = "member"; } inline void _initNetwork(nlohmann::json &network) @@ -162,6 +166,8 @@ private: network.erase("authorizedMemberCount"); network.erase("activeMemberCount"); network.erase("totalMemberCount"); + // legacy fields + network.erase("lastModified"); } inline void _addMemberNonPersistedFields(uint64_t nwid,uint64_t nodeId,nlohmann::json &member,uint64_t now) { @@ -172,6 +178,10 @@ private: inline void _removeMemberNonPersistedFields(nlohmann::json &member) { member.erase("clock"); + // legacy fields + member.erase("recentLog"); + member.erase("lastModified"); + member.erase("lastRequestMetaData"); } const uint64_t _startTime;