diff --git a/libresapi/src/api/PeersHandler.cpp b/libresapi/src/api/PeersHandler.cpp index e0792e355..b3f48c7fc 100644 --- a/libresapi/src/api/PeersHandler.cpp +++ b/libresapi/src/api/PeersHandler.cpp @@ -250,6 +250,7 @@ PeersHandler::PeersHandler( StateTokenServer* sts, RsNotify* notify, addResourceHandler("set_network_options", this, &PeersHandler::handleSetNetworkOptions); addResourceHandler("get_pgp_options", this, &PeersHandler::handleGetPGPOptions); addResourceHandler("set_pgp_options", this, &PeersHandler::handleSetPGPOptions); + addResourceHandler("get_node_name", this, &PeersHandler::handleGetNodeName); addResourceHandler("get_node_options", this, &PeersHandler::handleGetNodeOptions); addResourceHandler("set_node_options", this, &PeersHandler::handleSetNodeOptions); addResourceHandler("examine_cert", this, &PeersHandler::handleExamineCert); @@ -1139,6 +1140,28 @@ void PeersHandler::handleSetPGPOptions(Request& req, Response& resp) resp.setOk(); } +void PeersHandler::handleGetNodeName(Request& req, Response& resp) +{ + std::string peer_id; + req.mStream << makeKeyValueReference("peer_id", peer_id); + + RsPeerId peerId(peer_id); + RsPeerDetails detail; + if(!mRsPeers->getPeerDetails(peerId, detail)) + { + resp.setFail(); + return; + } + + resp.mDataStream << makeKeyValue("peer_id", detail.id.toStdString()); + resp.mDataStream << makeKeyValue("name", detail.name); + resp.mDataStream << makeKeyValue("location", detail.location); + resp.mDataStream << makeKeyValue("pgp_id", detail.gpg_id.toStdString()); + resp.mDataStream << makeKeyValue("last_contact", detail.lastConnect); + + resp.setOk(); +} + void PeersHandler::handleGetNodeOptions(Request& req, Response& resp) { std::string peer_id; diff --git a/libresapi/src/api/PeersHandler.h b/libresapi/src/api/PeersHandler.h index b34e4db8a..d15705602 100644 --- a/libresapi/src/api/PeersHandler.h +++ b/libresapi/src/api/PeersHandler.h @@ -70,6 +70,7 @@ private: void handleGetPGPOptions(Request& req, Response& resp); void handleSetPGPOptions(Request& req, Response& resp); + void handleGetNodeName(Request& req, Response& resp); void handleGetNodeOptions(Request& req, Response& resp); void handleSetNodeOptions(Request& req, Response& resp);