Improve CLI error handling when showing non-existent bond

This commit is contained in:
Joseph Henry 2024-03-04 23:23:14 -08:00
parent 364ac499eb
commit 9724e04e6e
No known key found for this signature in database
GPG Key ID: C45B33FF5EBC9344

View File

@ -1663,6 +1663,7 @@ public:
ZT_PeerList *pl = _node->peers(); ZT_PeerList *pl = _node->peers();
if (pl) { if (pl) {
bool foundBond = false;
auto id = req.matches[1]; auto id = req.matches[1];
auto out = json::object(); auto out = json::object();
uint64_t wantp = Utils::hexStrToU64(id.str().c_str()); uint64_t wantp = Utils::hexStrToU64(id.str().c_str());
@ -1672,12 +1673,18 @@ public:
if (bond) { if (bond) {
_peerToJson(out,&(pl->peers[i]),bond,(_tcpFallbackTunnel != (TcpConnection *)0)); _peerToJson(out,&(pl->peers[i]),bond,(_tcpFallbackTunnel != (TcpConnection *)0));
setContent(req, res, out.dump()); setContent(req, res, out.dump());
foundBond = true;
} else { } else {
setContent(req, res, ""); setContent(req, res, "");
res.status = 400; res.status = 400;
} }
break;
} }
} }
if (!foundBond) {
setContent(req, res, "");
res.status = 400;
}
} }
_node->freeQueryResult((void *)pl); _node->freeQueryResult((void *)pl);
}; };