mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-04 19:25:51 +00:00
Add pubkey_node and hostid to server stream messages (RIPD-407)
This commit is contained in:
committed by
Nik Bougalis
parent
dbe49bcd87
commit
c2276155bf
@@ -435,7 +435,7 @@ public:
|
||||
bool subLedger (InfoSub::ref ispListener, Json::Value& jvResult);
|
||||
bool unsubLedger (std::uint64_t uListener);
|
||||
|
||||
bool subServer (InfoSub::ref ispListener, Json::Value& jvResult);
|
||||
bool subServer (InfoSub::ref ispListener, Json::Value& jvResult, bool admin);
|
||||
bool unsubServer (std::uint64_t uListener);
|
||||
|
||||
bool subBook (InfoSub::ref ispListener, Book const&) override;
|
||||
@@ -2946,7 +2946,8 @@ bool NetworkOPsImp::unsubLedger (std::uint64_t uSeq)
|
||||
}
|
||||
|
||||
// <-- bool: true=added, false=already there
|
||||
bool NetworkOPsImp::subServer (InfoSub::ref isrListener, Json::Value& jvResult)
|
||||
bool NetworkOPsImp::subServer (InfoSub::ref isrListener, Json::Value& jvResult,
|
||||
bool admin)
|
||||
{
|
||||
uint256 uRandom;
|
||||
|
||||
@@ -2959,6 +2960,22 @@ bool NetworkOPsImp::subServer (InfoSub::ref isrListener, Json::Value& jvResult)
|
||||
jvResult[jss::server_status] = strOperatingMode ();
|
||||
jvResult[jss::load_base] = getApp().getFeeTrack ().getLoadBase ();
|
||||
jvResult[jss::load_factor] = getApp().getFeeTrack ().getLoadFactor ();
|
||||
jvResult[jss::pubkey_node] = getApp ().getLocalCredentials ().
|
||||
getNodePublic ().humanNodePublic ();
|
||||
|
||||
if (! admin)
|
||||
{
|
||||
// For a non admin connection, hash the node ID into a single RFC1751 word
|
||||
Blob const& addr (getApp ().getLocalCredentials ().getNodePublic ().
|
||||
getNodePublic ());
|
||||
jvResult[jss::hostid] = RFC1751::getWordFromBlob (addr.data (),
|
||||
addr.size ());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Only admins get the hostname for security reasons
|
||||
jvResult[jss::hostid] = beast::SystemStats::getComputerName ();
|
||||
}
|
||||
|
||||
ScopedLockType sl (mLock);
|
||||
return mSubServer.emplace (isrListener->getSeq (), isrListener).second;
|
||||
|
||||
@@ -66,7 +66,8 @@ public:
|
||||
virtual bool subLedger (ref ispListener, Json::Value& jvResult) = 0;
|
||||
virtual bool unsubLedger (std::uint64_t uListener) = 0;
|
||||
|
||||
virtual bool subServer (ref ispListener, Json::Value& jvResult) = 0;
|
||||
virtual bool subServer (ref ispListener, Json::Value& jvResult,
|
||||
bool admin) = 0;
|
||||
virtual bool unsubServer (std::uint64_t uListener) = 0;
|
||||
|
||||
virtual bool subBook (ref ispListener, Book const&) = 0;
|
||||
|
||||
@@ -112,7 +112,8 @@ Json::Value doSubscribe (RPC::Context& context)
|
||||
|
||||
if (streamName == "server")
|
||||
{
|
||||
context.netOps_.subServer (ispSub, jvResult);
|
||||
context.netOps_.subServer (ispSub, jvResult,
|
||||
context.role_ == Config::ADMIN);
|
||||
}
|
||||
else if (streamName == "ledger")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user