A little bit more controller code cleanup.

This commit is contained in:
Adam Ierymenko 2016-08-25 16:25:28 -07:00
parent b5e0d014ab
commit df1ce856c9

View file

@ -1606,26 +1606,29 @@ void EmbeddedNetworkController::_circuitTestCallback(ZT_Node *node,ZT_CircuitTes
void EmbeddedNetworkController::_getNetworkMemberInfo(uint64_t now,uint64_t nwid,_NetworkMemberInfo &nmi)
{
Mutex::Lock _mcl(_networkMemberCache_m);
auto memberCacheEntry = _networkMemberCache[nwid];
std::map< Address,nlohmann::json > &memberCacheEntry = _networkMemberCache[nwid];
nmi.totalMemberCount = memberCacheEntry.size();
for(std::map< Address,nlohmann::json >::const_iterator nm(memberCacheEntry.begin());nm!=memberCacheEntry.end();++nm) {
for(std::map< Address,nlohmann::json >::iterator nm(memberCacheEntry.begin());nm!=memberCacheEntry.end();++nm) {
if (_jB(nm->second["authorized"],false)) {
++nmi.authorizedMemberCount;
auto mlog = nm->second["recentLog"];
if (nm->second.count("recentLog")) {
json &mlog = nm->second["recentLog"];
if ((mlog.is_array())&&(mlog.size() > 0)) {
auto mlog1 = mlog[0];
json &mlog1 = mlog[0];
if (mlog1.is_object()) {
if ((now - _jI(mlog1["ts"],0ULL)) < ZT_NETCONF_NODE_ACTIVE_THRESHOLD)
++nmi.activeMemberCount;
}
}
}
if (_jB(nm->second["activeBridge"],false)) {
nmi.activeBridges.insert(nm->first);
}
auto mips = nm->second["ipAssignments"];
if (nm->second.count("ipAssignments")) {
json &mips = nm->second["ipAssignments"];
if (mips.is_array()) {
for(unsigned long i=0;i<mips.size();++i) {
InetAddress mip(_jS(mips[i],""));
@ -1633,6 +1636,7 @@ void EmbeddedNetworkController::_getNetworkMemberInfo(uint64_t now,uint64_t nwid
nmi.allocatedIps.insert(mip);
}
}
}
} else {
nmi.mostRecentDeauthTime = std::max(nmi.mostRecentDeauthTime,_jI(nm->second["lastDeauthorizedTime"],0ULL));
}