Skip to content

Commit

Permalink
Merge pull request #2232 from zerotier/unstable-api-fixes
Browse files Browse the repository at this point in the history
Unstable api fixes
  • Loading branch information
joseph-henry authored Mar 4, 2024
2 parents 024649c + 6e8fcce commit 5d8bd67
Showing 1 changed file with 32 additions and 28 deletions.
60 changes: 32 additions & 28 deletions controller/EmbeddedNetworkController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

auto nwMeta = json::object();
nwMeta["totalMemberCount"] = totalCount;
nwMeta["authorizedMemberCount"] = authorizedCount;
network["meta"] = nwMeta;
data.push_back(network);
}
}

data.push_back(network);
}
meta["networkCount"] = networkIds.size();
meta["networkCount"] = networkCount;

auto out = json::object();
out["data"] = data;
Expand Down Expand Up @@ -1090,26 +1094,26 @@ void EmbeddedNetworkController::configureHTTPControlPlane(

auto out = nlohmann::json::object();
auto meta = nlohmann::json::object();
auto members = nlohmann::json::array();
std::vector<json> memTmp;
if (_db.get(nwid, network, memTmp)) {
members.push_back(memTmp);
}

uint64_t authorizedCount = 0;
uint64_t totalCount = memTmp.size();
for (auto m = memTmp.begin(); m != memTmp.end(); ++m) {
bool a = OSUtils::jsonBool((*m)["authorized"], 0);
if (a) { authorizedCount++; }
}
uint64_t authorizedCount = 0;
uint64_t totalCount = memTmp.size();
for (auto m = memTmp.begin(); m != memTmp.end(); ++m) {
bool a = OSUtils::jsonBool((*m)["authorized"], 0);
if (a) { authorizedCount++; }
}

meta["totalCount"] = totalCount;
meta["authorizedCount"] = authorizedCount;
meta["totalCount"] = totalCount;
meta["authorizedCount"] = authorizedCount;

out["data"] = members;
out["meta"] = meta;
out["data"] = memTmp;
out["meta"] = meta;

setContent(req, res, out.dump());
setContent(req, res, out.dump());
} else {
res.status = 404;
return;
}
};
s.Get(memberListPath2, memberListGet2);
sv6.Get(memberListPath2, memberListGet2);
Expand Down

0 comments on commit 5d8bd67

Please sign in to comment.