Browse Source

Improve CLI error handling when showing non-existent bond

Joseph Henry 1 year ago
parent
commit
9724e04e6e
1 changed files with 7 additions and 0 deletions
  1. 7 0
      service/OneService.cpp

+ 7 - 0
service/OneService.cpp

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