mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
fix http return value from one service when nework list is empty
This commit is contained in:
parent
544a4de1e0
commit
ecde26c823
1 changed files with 21 additions and 26 deletions
|
@ -1577,37 +1577,32 @@ public:
|
||||||
}
|
}
|
||||||
} else if (ps[0] == "network") {
|
} else if (ps[0] == "network") {
|
||||||
Mutex::Lock _l(_nets_m);
|
Mutex::Lock _l(_nets_m);
|
||||||
if (!_nets.empty()) {
|
if (ps.size() == 1) {
|
||||||
if (ps.size() == 1) {
|
// Return [array] of all networks
|
||||||
// Return [array] of all networks
|
|
||||||
|
|
||||||
res = nlohmann::json::array();
|
res = nlohmann::json::array();
|
||||||
|
|
||||||
for (auto it = _nets.begin(); it != _nets.end(); ++it) {
|
for (auto it = _nets.begin(); it != _nets.end(); ++it) {
|
||||||
NetworkState &ns = it->second;
|
NetworkState &ns = it->second;
|
||||||
nlohmann::json nj;
|
nlohmann::json nj;
|
||||||
_networkToJson(nj, ns);
|
_networkToJson(nj, ns);
|
||||||
res.push_back(nj);
|
res.push_back(nj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scode = 200;
|
||||||
|
} else if (ps.size() == 2) {
|
||||||
|
// Return a single network by ID or 404 if not found
|
||||||
|
|
||||||
|
const uint64_t wantnw = Utils::hexStrToU64(ps[1].c_str());
|
||||||
|
if (_nets.find(wantnw) != _nets.end()) {
|
||||||
|
res = json::object();
|
||||||
|
NetworkState& ns = _nets[wantnw];
|
||||||
|
_networkToJson(res, ns);
|
||||||
scode = 200;
|
scode = 200;
|
||||||
} else if (ps.size() == 2) {
|
|
||||||
// Return a single network by ID or 404 if not found
|
|
||||||
|
|
||||||
const uint64_t wantnw = Utils::hexStrToU64(ps[1].c_str());
|
|
||||||
if (_nets.find(wantnw) != _nets.end()) {
|
|
||||||
res = json::object();
|
|
||||||
NetworkState& ns = _nets[wantnw];
|
|
||||||
_networkToJson(res, ns);
|
|
||||||
scode = 200;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "not found\n");
|
|
||||||
scode = 404;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "_nets is empty??\n");
|
fprintf(stderr, "not found\n");
|
||||||
scode = 500;
|
scode = 404;
|
||||||
}
|
}
|
||||||
} else if (ps[0] == "peer") {
|
} else if (ps[0] == "peer") {
|
||||||
ZT_PeerList *pl = _node->peers();
|
ZT_PeerList *pl = _node->peers();
|
||||||
|
|
Loading…
Add table
Reference in a new issue