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

@@ -1,5 +1,11 @@
Vinnie Falco's Change Log Vinnie Falco's Change Log
2013/07/31
- Add "hostname" to server_info output
- Replace "build_version" in server_info with the actual build version
- Remove "client_version" from server_info
2013/07/30 2013/07/30
- Add FatalErrorReporter to main - Add FatalErrorReporter to main

View File

@@ -107,39 +107,6 @@ struct BuildInfo
/** The oldest protocol version we will accept. */ /** The oldest protocol version we will accept. */
static Protocol const& getMinimumProtocol (); static Protocol const& getMinimumProtocol ();
//--------------------------------------------------------------------------
//
// DEPRECATED STUFF
//
/** Retrieve the build version number.
This is typically incremented when an official version is publshed
with a list of changes.
Format is:
<major>.<minor>.<bugfix>
*/
static char const* getBuildVersion ()
{
return "0.0.1";
}
/** Retrieve the client API version number.
The client API version is incremented whenever a new feature
or breaking change is made to the websocket / RPC interface.
Format is:
<version-number>
*/
static char const* getClientVersion ()
{
return "1";
}
}; };
#endif #endif

View File

@@ -1387,12 +1387,28 @@ Json::Value NetworkOPs::getConsensusInfo ()
return info; return info;
} }
Json::Value NetworkOPs::getServerInfo (bool human, bool admin) Json::Value NetworkOPs::getServerInfo (bool human, bool admin)
{ {
Json::Value info = Json::objectValue; Json::Value info = Json::objectValue;
info ["build_version"] = BuildInfo::getBuildVersion (); // hostid: unique string describing the machine
info ["client_version"] = BuildInfo::getClientVersion (); 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) if (getConfig ().TESTNET)
info["testnet"] = getConfig ().TESTNET; info["testnet"] = getConfig ().TESTNET;

View File

@@ -470,4 +470,12 @@ void RFC1751::getEnglishFromKey (std::string& strHuman, const std::string& strKe
strHuman = strFirst + " " + strSecond; strHuman = strFirst + " " + strSecond;
} }
// vim:ts=4 String RFC1751::getWordFromBlob (void const* data, size_t bytes)
{
uint32 hash;
Murmur::Hash (data, bytes, 0, &hash);
return s_dictionary [hash % (sizeof (s_dictionary) / sizeof (s_dictionary [0]))];
}

View File

@@ -14,6 +14,15 @@ public:
static void getEnglishFromKey (std::string& strHuman, const std::string& strKey); static void getEnglishFromKey (std::string& strHuman, const std::string& strKey);
/** Chooses a single dictionary word from the data.
This is not particularly secure but it can be useful to provide
a unique name for something given a GUID or fixed data. We use
it to turn the pubkey_node into an easily remembered and identified
4 character string.
*/
static String getWordFromBlob (void const* data, size_t bytes);
private: private:
static unsigned long extract (char* s, int start, int length); static unsigned long extract (char* s, int start, int length);
static void btoe (std::string& strHuman, const std::string& strData); static void btoe (std::string& strHuman, const std::string& strData);

View File

@@ -33,6 +33,7 @@ namespace ripple
#include "crypto/ripple_CBigNum.h" #include "crypto/ripple_CBigNum.h"
#include "crypto/ripple_Base58.h" // VFALCO TODO Can be moved to .cpp if we clean up setAlphabet stuff #include "crypto/ripple_Base58.h" // VFALCO TODO Can be moved to .cpp if we clean up setAlphabet stuff
#include "crypto/ripple_Base58Data.h" #include "crypto/ripple_Base58Data.h"
#include "crypto/ripple_RFC1751.h"
#include "protocol/ripple_FieldNames.h" #include "protocol/ripple_FieldNames.h"
#include "protocol/ripple_HashPrefix.h" #include "protocol/ripple_HashPrefix.h"

View File

@@ -377,6 +377,18 @@ Value::Value ( const std::string& value )
value_.string_ = valueAllocator ()->duplicateStringValue ( value.c_str (), value_.string_ = valueAllocator ()->duplicateStringValue ( value.c_str (),
(unsigned int)value.length () ); (unsigned int)value.length () );
}
Value::Value (beast::String const& beastString)
: type_ ( stringValue )
, allocated_ ( true )
, comments_ ( 0 )
# ifdef JSON_VALUE_USE_INTERNAL_MAP
, itemIsUsed_ ( 0 )
#endif
{
value_.string_ = valueAllocator ()->duplicateStringValue ( beastString.toStdString ().c_str (),
(unsigned int)beastString.length () );
} }
Value::Value ( const StaticString& value ) Value::Value ( const StaticString& value )

View File

@@ -193,6 +193,7 @@ public:
*/ */
Value ( const StaticString& value ); Value ( const StaticString& value );
Value ( const std::string& value ); Value ( const std::string& value );
Value (beast::String const& beastString);
# ifdef JSON_USE_CPPTL # ifdef JSON_USE_CPPTL
Value ( const CppTL::ConstString& value ); Value ( const CppTL::ConstString& value );
# endif # endif

View File

@@ -108,6 +108,8 @@
# #
# [rpc_admin_allow] # [rpc_admin_allow]
# Specify an list of IP addresses allowed to have admin access. One per line. # Specify an list of IP addresses allowed to have admin access. One per line.
# If you want to test the output of non-admin commands add this section and
# just put an ip address not under your control.
# #
# Defaults to 127.0.0.1. # Defaults to 127.0.0.1.
# #