mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-18 02:40:13 +00:00
Improve full controller network list api
it was counting incorrectly in some cases and returning empty objects. Basically just handling if network data is null
This commit is contained in:
parent
024649c175
commit
559e8a907b
@ -918,6 +918,7 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
|
||||
|
||||
auto meta = json::object();
|
||||
auto data = json::array();
|
||||
uint64_t networkCount = 0;
|
||||
|
||||
for(std::set<uint64_t>::const_iterator nwid(networkIds.begin()); nwid != networkIds.end(); ++nwid) {
|
||||
json network;
|
||||
@ -927,23 +928,26 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
|
||||
|
||||
std::vector<json> memTmp;
|
||||
if (_db.get(*nwid, network, memTmp)) {
|
||||
uint64_t authorizedCount = 0;
|
||||
uint64_t totalCount = memTmp.size();
|
||||
if (!network.is_null()) {
|
||||
uint64_t authorizedCount = 0;
|
||||
uint64_t totalCount = memTmp.size();
|
||||
networkCount++;
|
||||
|
||||
for (auto m = memTmp.begin(); m != memTmp.end(); ++m) {
|
||||
bool a = OSUtils::jsonBool((*m)["authorized"], 0);
|
||||
if (a) { authorizedCount++; }
|
||||
for (auto m = memTmp.begin(); m != memTmp.end(); ++m) {
|
||||
bool a = OSUtils::jsonBool((*m)["authorized"], 0);
|
||||
if (a) { authorizedCount++; }
|
||||
}
|
||||
|
||||
auto nwMeta = json::object();
|
||||
nwMeta["totalMemberCount"] = totalCount;
|
||||
nwMeta["authorizedMemberCount"] = authorizedCount;
|
||||
network["meta"] = nwMeta;
|
||||
|
||||
data.push_back(network);
|
||||
}
|
||||
|
||||
auto nwMeta = json::object();
|
||||
nwMeta["totalMemberCount"] = totalCount;
|
||||
nwMeta["authorizedMemberCount"] = authorizedCount;
|
||||
network["meta"] = nwMeta;
|
||||
}
|
||||
|
||||
data.push_back(network);
|
||||
}
|
||||
meta["networkCount"] = networkIds.size();
|
||||
meta["networkCount"] = networkCount;
|
||||
|
||||
auto out = json::object();
|
||||
out["data"] = data;
|
||||
|
Loading…
Reference in New Issue
Block a user