Add 'hostid' to server_info

* Add json::Value conversion from beast::String
* Update rippled-example.cfg
This commit is contained in:
Vinnie Falco
2013-07-31 07:50:34 -07:00
parent f80c19577f
commit 052aee8f97
9 changed files with 58 additions and 36 deletions

View File

@@ -1387,12 +1387,28 @@ Json::Value NetworkOPs::getConsensusInfo ()
return info;
}
Json::Value NetworkOPs::getServerInfo (bool human, bool admin)
{
Json::Value info = Json::objectValue;
info ["build_version"] = BuildInfo::getBuildVersion ();
info ["client_version"] = BuildInfo::getClientVersion ();
// hostid: unique string describing the machine
if (human)
{
if (! admin)
{
// For a non admin connection, hash the node ID into a single RFC1751 word
Blob const& addr (getApp().getLocalCredentials ().getNodePublic ().getNodePublic ());
info ["hostid"] = RFC1751::getWordFromBlob (addr.data (), addr.size ());
}
else
{
// Only admins get the hostname for security reasons
info ["hostid"] = SystemStats::getComputerName();
}
}
info ["build_version"] = BuildInfo::getVersionString ();
if (getConfig ().TESTNET)
info["testnet"] = getConfig ().TESTNET;