Added in Libresapi: Getting node name in PeersHandler

This commit is contained in:
Konrad 2017-12-27 22:38:04 +01:00
parent 2db25d40cb
commit b24d772278
2 changed files with 24 additions and 0 deletions

View File

@ -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;

View File

@ -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);