Merge branch 'feature-cleanup' of github.com:vinniefalco/rippled into develop

Conflicts:
	Builds/VisualStudio2012/RippleD.vcxproj.filters
This commit is contained in:
JoelKatz
2013-07-07 15:29:16 -07:00
22 changed files with 464 additions and 168 deletions

5
Builds/QtCreator/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
# QTCreator
Makefile
*.user

View File

@@ -0,0 +1,85 @@
# Google Protocol Buffers support
PROTOPATH += .
PROTOPATH += ../Protocol
for(p, PROTOPATH):PROTOPATHS += --proto_path=$${p}
protobuf_decl.name = protobuf header
protobuf_decl.input = PROTOS
protobuf_decl.output = ${QMAKE_FILE_BASE}.pb.h
protobuf_decl.commands = protoc --cpp_out="../../build/proto/" --proto_path="../../src/cpp/ripple" ${QMAKE_FILE_NAME}
protobuf_decl.variable_out = GENERATED_FILES
QMAKE_EXTRA_COMPILERS += protobuf_decl
protobuf_impl.name = protobuf implementation
protobuf_impl.input = PROTOS
protobuf_impl.output = ${QMAKE_FILE_BASE}.pb.cc
protobuf_impl.depends = ${QMAKE_FILE_BASE}.pb.h
protobuf_impl.commands = $$escape_expand(\n)
protobuf_impl.variable_out = GENERATED_SOURCES
QMAKE_EXTRA_COMPILERS += protobuf_impl
# Ripple compilation
DESTDIR = ../../build/QtCreator
OBJECTS_DIR = ../../build/QtCreator/obj
TEMPLATE = app
CONFIG += console thread
CONFIG -= qt gui
QMAKE_CXXFLAGS += \
-Wno-sign-compare \
-Wno-char-subscripts \
-Wno-invalid-offsetof \
-Wno-unused-parameter \
-Wformat \
-O0 \
-pthread
INCLUDEPATH += \
"../.." \
"../../build/proto" \
"../../Subtrees" \
"../../Subtrees/leveldb/" \
"../../Subtrees/leveldb/port" \
"../../Subtrees/leveldb/include"
SOURCES += \
../../Subtrees/beast/modules/beast_basics/beast_basics.cpp \
../../Subtrees/beast/modules/beast_core/beast_core.cpp \
../../modules/ripple_app/ripple_app_pt1.cpp \
../../modules/ripple_app/ripple_app_pt2.cpp \
../../modules/ripple_app/ripple_app_pt3.cpp \
../../modules/ripple_app/ripple_app_pt4.cpp \
../../modules/ripple_app/ripple_app_pt5.cpp \
../../modules/ripple_app/ripple_app_pt6.cpp \
../../modules/ripple_app/ripple_app_pt7.cpp \
../../modules/ripple_app/ripple_app_pt8.cpp \
../../modules/ripple_basics/ripple_basics.cpp \
../../modules/ripple_core/ripple_core.cpp \
../../modules/ripple_client/ripple_client.cpp \
../../modules/ripple_data/ripple_data.cpp \
../../modules/ripple_json/ripple_json.cpp \
../../modules/ripple_leveldb/ripple_leveldb.cpp \
../../modules/ripple_sqlite/ripple_sqlite.c \
../../modules/ripple_websocket/ripple_websocket.cpp \
../../build/proto/ripple.pb.cc
PROTOS = ../../src/cpp/ripple/ripple.proto
LIBS += \
-lboost_date_time-mt\
-lboost_filesystem-mt \
-lboost_program_options-mt \
-lboost_regex-mt \
-lboost_system-mt \
-lboost_thread-mt \
-lboost_random-mt \
-lprotobuf \
-lssl \
-lrt

View File

@@ -15,7 +15,7 @@
<PreprocessorDefinitions>_VARIADIC_MAX=10;_WIN32_WINNT=0x0600;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>$(RepoDir);$(RepoDir)\src\cpp\protobuf\src;$(RepoDir)\src\cpp\protobuf\vsprojects;$(RepoDir)\build\proto;$(RepoDir)\Subtrees;$(RepoDir)\Subtrees\leveldb;$(RepoDir)\Subtrees\leveldb\include;$(RepoDir)\Subtrees\beast;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(RepoDir);$(RepoDir)\src\cpp\protobuf\src;$(RepoDir)\src\cpp\protobuf\vsprojects;$(RepoDir)\build\proto;$(RepoDir)\Subtrees;$(RepoDir)\Subtrees\leveldb;$(RepoDir)\Subtrees\leveldb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<ExceptionHandling>Async</ExceptionHandling>
</ClCompile>

View File

@@ -88,6 +88,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_basics\utility\ripple_LogFile.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_basics\utility\ripple_RandomNumbers.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -1321,6 +1327,7 @@
<ClInclude Include="..\..\modules\ripple_basics\utility\ripple_HashUtilities.h" />
<ClInclude Include="..\..\modules\ripple_basics\utility\ripple_IniFile.h" />
<ClInclude Include="..\..\modules\ripple_basics\utility\ripple_Log.h" />
<ClInclude Include="..\..\modules\ripple_basics\utility\ripple_LogFile.h" />
<ClInclude Include="..\..\modules\ripple_basics\utility\ripple_PlatformMacros.h" />
<ClInclude Include="..\..\modules\ripple_basics\utility\ripple_RandomNumbers.h" />
<ClInclude Include="..\..\modules\ripple_basics\utility\ripple_ScopedLock.h" />

View File

@@ -833,6 +833,8 @@
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt8.cpp">
<Filter>1. Modules\ripple_app</Filter>
<ClCompile Include="..\..\modules\ripple_basics\utility\ripple_LogFile.cpp">
<Filter>[1] Ripple\ripple_basics\utility</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
@@ -1545,6 +1547,9 @@
<ClInclude Include="..\..\src\cpp\ripple\ripple_ILoadManager.h">
<Filter>[1] Ripple\ripple_app\_main</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\ripple_basics\utility\ripple_LogFile.h">
<Filter>[1] Ripple\ripple_basics\utility</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\src\cpp\ripple\ripple.proto" />

View File

@@ -1,36 +1,14 @@
--------------------------------------------------------------------------------
LEVELDB TODO
--------------------------------------------------------------------------------
- Add VisualStudio 2012 project file to our fork
- Add LevelDB unity .cpp and .h to our fork
- Replace Beast specific platform macros with universal macros so that the
unity doesn't require Beast
- Submit LevelDB fork changes to Bitcoin upstream
--------------------------------------------------------------------------------
WEBSOCKET TODO
--------------------------------------------------------------------------------
*** Figure out how hard we want to fork websocket first **
- Think about stripping the ripple specifics out of AutoSocket, make AutoSocket
part of our websocketpp fork
- Regroup all the sources together in one directory
- Strip includes and enforce unity
- Put a new front-end on websocket to hide ALL of their classes and templates
from the host application, make this part of the websocket fork
--------------------------------------------------------------------------------
RIPPLE TODO
--------------------------------------------------------------------------------
- Profile/VTune the application to identify hot spots
* Determine why rippled has a slow startup on Windows
* Improve the performance when running all unit tests on Windows
- Class to represent IP and Port number, with members to print, check syntax,
etc... replace the boost calls.
- Remove dependence on JobQueue, LoadFeeTrack, and NetworkOPs from LoadManager
by providing an observer (beast::ListenerList or Listeners). This way
LoadManager does not need stopThread() function.
@@ -128,7 +106,46 @@ RIPPLE TODO
- Consolidate SQLite database classes: DatabaseCon, Database, SqliteDatabase.
--------------------------------------------------------------------------------
RANDOM NOTES
LEVELDB TODO
--------------------------------------------------------------------------------
- Add VisualStudio 2012 project file to our fork
- Add LevelDB unity .cpp and .h to our fork
- Replace Beast specific platform macros with universal macros so that the
unity doesn't require Beast
- Submit LevelDB fork changes to Bitcoin upstream
--------------------------------------------------------------------------------
WEBSOCKET TODO
--------------------------------------------------------------------------------
*** Figure out how hard we want to fork websocket first **
- Think about stripping the ripple specifics out of AutoSocket, make AutoSocket
part of our websocketpp fork
- Regroup all the sources together in one directory
- Strip includes and enforce unity
- Put a new front-end on websocket to hide ALL of their classes and templates
from the host application, make this part of the websocket fork
--------------------------------------------------------------------------------
PROTOCOL BUFFERS TODO
--------------------------------------------------------------------------------
- Create/maintain the protobuf Git repo (original uses SVN)
- Update the subtree
- Make a Visual Studio 2012 Project for source browsing
--------------------------------------------------------------------------------
NOTES
--------------------------------------------------------------------------------
LoadEvent

View File

@@ -15,7 +15,7 @@
#include "BeastConfig.h"
// This must come first to work around the boost placeholders issues
#include "modules/beast_basics/beast_basics.h"
#include "beast/modules/beast_basics/beast_basics.h"
// VFALCO NOTE Holy smokes...that's a lot of boost!!!
#include <boost/algorithm/string.hpp>
@@ -57,9 +57,9 @@
#include <boost/unordered_set.hpp>
#include <boost/weak_ptr.hpp>
#include "../modules/ripple_sqlite/ripple_sqlite.h" // for SqliteDatabase.cpp
#include "../ripple_sqlite/ripple_sqlite.h" // for SqliteDatabase.cpp
#include "../modules/ripple_core/ripple_core.h"
#include "../ripple_core/ripple_core.h"
// VFALCO TODO fix these warnings!
#ifdef _MSC_VER

View File

@@ -56,6 +56,7 @@ namespace ripple
#include "containers/ripple_TaggedCache.cpp"
#include "utility/ripple_Log.cpp"
#include "utility/ripple_LogFile.cpp"
#include "utility/ripple_ByteOrder.cpp"
#include "utility/ripple_CountedObject.cpp"

View File

@@ -23,7 +23,7 @@
#include "system/ripple_StandardIncludes.h"
// This must come before Boost, to fix the boost placeholders problem
#include "modules/beast_basics/beast_basics.h"
#include "beast/modules/beast_basics/beast_basics.h"
#include "system/ripple_BoostIncludes.h"
@@ -36,9 +36,9 @@
//
#if __cplusplus > 201100L
namespace boost
{
template <class T>
const T* get_pointer (std::shared_ptr<T> const& ptr)
{
template <class T>
const T* get_pointer (std::shared_ptr<T> const& ptr)
{
return ptr.get();
}
@@ -64,11 +64,7 @@ namespace boost
# include <sys/types.h>
#endif
#include "modules/beast_core/beast_core.h"
//#include "modules/beast_basics/beast_basics.h"
// VFALCO TODO Fix this for FreeBSD
//#include "modules/beast_basics/beast_basics.h"
#include "beast/modules/beast_core/beast_core.h"
#include "../ripple_json/ripple_json.h"
@@ -77,6 +73,7 @@ namespace ripple
using namespace beast;
#include "utility/ripple_LogFile.h"
#include "utility/ripple_Log.h" // Needed by others
#include "types/ripple_BasicTypes.h"

View File

@@ -4,14 +4,10 @@
*/
//==============================================================================
boost::recursive_mutex Log::sLock;
LogFile Log::s_logFile;
boost::recursive_mutex Log::s_lock;
LogSeverity Log::sMinSeverity = lsINFO;
std::ofstream* Log::outStream = NULL;
boost::filesystem::path* Log::pathToLog = NULL;
uint32 Log::logRotateCounter = 0;
//------------------------------------------------------------------------------
LogPartition* LogPartition::headLog = NULL;
@@ -43,25 +39,6 @@ std::vector< std::pair<std::string, std::string> > LogPartition::getSeverities (
//------------------------------------------------------------------------------
// VFALCO TODO remove original code once we know the replacement is correct.
// Original code
/*
std::string ls = oss.str();
size_t s = ls.find("\"secret\"");
if (s != std::string::npos)
{
s += 8;
size_t sEnd = ls.size() - 1;
if (sEnd > (s + 35))
sEnd = s + 35;
for (int i = s; i < sEnd; ++i)
ls[i] = '*';
}
logMsg += ls;
*/
//------------------------------------------------------------------------------
std::string Log::replaceFirstSecretWithAsterisks (std::string s)
{
using namespace std;
@@ -144,14 +121,10 @@ Log::~Log ()
void Log::print (std::string const& text, bool toStdErr)
{
boost::recursive_mutex::scoped_lock sl (sLock);
boost::recursive_mutex::scoped_lock sl (s_lock);
// Always write to the log file if it is open.
//
if (outStream != NULL)
{
(*outStream) << text << std::endl;
}
// Does nothing if not open.
s_logFile.writeln (text);
if (toStdErr)
{
@@ -170,61 +143,23 @@ void Log::print (std::string const& text, bool toStdErr)
}
}
std::string Log::rotateLog (void)
std::string Log::rotateLog ()
{
boost::recursive_mutex::scoped_lock sl (sLock);
boost::filesystem::path abs_path;
std::string abs_path_str;
bool const wasOpened = s_logFile.closeAndReopen ();
uint32 failsafe = 0;
std::string abs_new_path_str;
do
if (wasOpened)
{
std::string s;
std::stringstream out;
failsafe++;
if (failsafe == std::numeric_limits<uint32>::max ())
{
return "unable to create new log file; too many log files!";
}
abs_path = boost::filesystem::absolute ("");
abs_path /= *pathToLog;
abs_path_str = abs_path.parent_path ().string ();
out << logRotateCounter;
s = out.str ();
abs_new_path_str = abs_path_str + "/" + s + "_" + pathToLog->filename ().string ();
logRotateCounter++;
return "The log file was closed and reopened.";
}
while (boost::filesystem::exists (boost::filesystem::path (abs_new_path_str)));
outStream->close ();
try
else
{
boost::filesystem::rename (abs_path, boost::filesystem::path (abs_new_path_str));
return "The log file could not be closed and reopened.";
}
catch (...)
{
// unable to rename existing log file
}
setLogFile (*pathToLog);
return abs_new_path_str;
}
void Log::setMinSeverity (LogSeverity s, bool all)
{
boost::recursive_mutex::scoped_lock sl (sLock);
boost::recursive_mutex::scoped_lock sl (s_lock);
sMinSeverity = s;
@@ -234,7 +169,7 @@ void Log::setMinSeverity (LogSeverity s, bool all)
LogSeverity Log::getMinSeverity ()
{
boost::recursive_mutex::scoped_lock sl (sLock);
boost::recursive_mutex::scoped_lock sl (s_lock);
return sMinSeverity;
}
@@ -292,28 +227,11 @@ LogSeverity Log::stringToSeverity (const std::string& s)
void Log::setLogFile (boost::filesystem::path const& path)
{
std::ofstream* newStream = new std::ofstream (path.c_str (), std::fstream::app);
bool const wasOpened = s_logFile.open (path.c_str ());
if (!newStream->good ())
if (! wasOpened)
{
Log (lsFATAL) << "Unable to open logfile " << path;
delete newStream;
newStream = NULL;
}
boost::recursive_mutex::scoped_lock sl (sLock);
if (outStream != NULL)
delete outStream;
outStream = newStream;
if (pathToLog != &path)
{
if (pathToLog != NULL)
delete pathToLog;
pathToLog = new boost::filesystem::path (path);
}
}

View File

@@ -115,6 +115,13 @@ public:
static void setLogFile (boost::filesystem::path const& pathToLogFile);
/** Rotate the log file.
The log file is closed and reopened. This is for compatibility
with log management tools.
@return A human readable string describing the result of the operation.
*/
static std::string rotateLog ();
public:
@@ -185,18 +192,14 @@ private:
maximumMessageCharacters = 12 * 1024
};
// VFALCO TODO looks like there are really TWO classes in here.
// One is a stream target for '<<' operator and the other
// is a singleton. Split the singleton out to a new class.
//
static boost::recursive_mutex sLock;
static LogSeverity sMinSeverity;
static std::ofstream* outStream;
static boost::filesystem::path* pathToLog;
static uint32 logRotateCounter;
static std::string replaceFirstSecretWithAsterisks (std::string s);
// Singleton variables
//
static LogFile s_logFile;
static boost::recursive_mutex s_lock;
static LogSeverity sMinSeverity;
mutable std::ostringstream oss;
LogSeverity mSeverity;
std::string mPartitionName;

View File

@@ -0,0 +1,69 @@
//------------------------------------------------------------------------------
/*
Copyright (c) 2011-2013, OpenCoin, Inc.
*/
//==============================================================================
LogFile::LogFile ()
: m_stream (nullptr)
{
}
LogFile::~LogFile ()
{
}
bool LogFile::isOpen () const noexcept
{
return m_stream != nullptr;
}
bool LogFile::open (boost::filesystem::path const& path)
{
close ();
bool wasOpened = false;
// VFALCO TODO Make this work with Unicode file paths
ScopedPointer <std::ofstream> stream (
new std::ofstream (path.c_str (), std::fstream::app));
if (stream->good ())
{
m_path = path;
m_stream = stream.release ();
wasOpened = true;
}
return wasOpened;
}
bool LogFile::closeAndReopen ()
{
close ();
return open (m_path);
}
void LogFile::close ()
{
m_stream = nullptr;
}
void LogFile::write (char const* text)
{
if (m_stream != nullptr)
(*m_stream) << text;
}
void LogFile::writeln (char const* text)
{
if (m_stream != nullptr)
{
(*m_stream) << text;
(*m_stream) << std::endl;
}
}

View File

@@ -0,0 +1,93 @@
//------------------------------------------------------------------------------
/*
Copyright (c) 2011-2013, OpenCoin, Inc.
*/
//==============================================================================
#ifndef RIPPLE_LOGFILE_H_INCLUDED
#define RIPPLE_LOGFILE_H_INCLUDED
/** Manages a system file containing logged output.
The system file remains open during program execution. Interfaces
are provided for interoperating with standard log management
tools like logrotate(8):
http://linuxcommand.org/man_pages/logrotate8.html
@note None of the listed interfaces are thread-safe.
*/
class LogFile : Uncopyable
{
public:
/** Construct with no associated system file.
A system file may be associated later with @ref open.
@see open
*/
LogFile ();
/** Destroy the object.
If a system file is associated, it will be flushed and closed.
*/
~LogFile ();
/** Determine if a system file is associated with the log.
@return `true` if a system file is associated and opened for writing.
*/
bool isOpen () const noexcept;
/** Associate a system file with the log.
If the file does not exist an attempt is made to create it
and open it for writing. If the file already exists an attempt is
made to open it for appending.
If a system file is already associated with the log, it is closed first.
@return `true` if the file was opened.
*/
// VFALCO NOTE The parameter is unfortunately a boost type because it
// can be either wchar or char based depending on platform.
// TODO Replace with beast::File
//
bool open (boost::filesystem::path const& path);
/** Close and re-open the system file associated with the log
This assists in interoperating with external log management tools.
@return `true` if the file was opened.
*/
bool closeAndReopen ();
/** Close the system file if it is open.
*/
void close ();
/** write to the log file.
Does nothing if there is no associated system file.
*/
void write (char const* text);
/** write to the log file and append an end of line marker.
Does nothing if there is no associated system file.
*/
void writeln (char const* text);
/** Write to the log file using std::string.
*/
inline void write (std::string const& str) { write (str.c_str ()); }
inline void writeln (std::string const& str) { writeln (str.c_str ()); }
private:
ScopedPointer <std::ofstream> m_stream;
boost::filesystem::path m_path;
};
#endif

View File

@@ -209,6 +209,7 @@ void Config::setup (const std::string& strConf, bool bTestNet, bool bQuiet)
Config::Config ()
: SSL_CONTEXT (boost::asio::ssl::context::sslv23)
, m_rpcPort (5001)
{
//
// Defaults
@@ -218,7 +219,6 @@ Config::Config ()
NETWORK_START_TIME = 1319844908;
PEER_PORT = SYSTEM_PEER_PORT;
RPC_PORT = 5001;
RPC_SECURE = 0;
WEBSOCKET_PORT = SYSTEM_WEBSOCKET_PORT;
WEBSOCKET_PUBLIC_PORT = SYSTEM_WEBSOCKET_PUBLIC_PORT;
@@ -373,14 +373,14 @@ void Config::load ()
(void) SectionSingleB (secConfig, SECTION_RPC_ADMIN_PASSWORD, RPC_ADMIN_PASSWORD);
(void) SectionSingleB (secConfig, SECTION_RPC_ADMIN_USER, RPC_ADMIN_USER);
(void) SectionSingleB (secConfig, SECTION_RPC_IP, RPC_IP);
(void) SectionSingleB (secConfig, SECTION_RPC_IP, m_rpcIP);
(void) SectionSingleB (secConfig, SECTION_RPC_PASSWORD, RPC_PASSWORD);
(void) SectionSingleB (secConfig, SECTION_RPC_USER, RPC_USER);
(void) SectionSingleB (secConfig, SECTION_NODE_DB, NODE_DB);
(void) SectionSingleB (secConfig, SECTION_LDB_EPHEMERAL, LDB_EPHEMERAL);
if (SectionSingleB (secConfig, SECTION_RPC_PORT, strTemp))
RPC_PORT = boost::lexical_cast<int> (strTemp);
m_rpcPort = boost::lexical_cast<int> (strTemp);
if (SectionSingleB (secConfig, "ledger_creator" , strTemp))
LEDGER_CREATOR = boost::lexical_cast<bool> (strTemp);

View File

@@ -128,7 +128,7 @@ public:
- The ledger is not advanced automatically.
- If no ledger is loaded, the default ledger with the root
account is created.
*/
*/
bool RUN_STANDALONE;
// Note: The following parameters do not relate to the UNL or trust at all
@@ -160,9 +160,63 @@ public:
std::string WEBSOCKET_SSL_CHAIN;
std::string WEBSOCKET_SSL_KEY;
//----------------------------------------------------------------------------
//
// VFALCO NOTE Please follow this style for modifying or adding code in the file.
//
public:
/** Get the client or server RPC IP address.
@note The string may not always be in a valid parsable state.
@return A string representing the address.
*/
std::string getRpcIP () const { return m_rpcIP; }
/** Get the client or server RPC port number.
@note The port number may be invalid (out of range or zero)
@return The RPC port number.
*/
int getRpcPort () const { return m_rpcPort; }
/** Set the client or server RPC IP.
@note The string is not syntax-checked.
@param newIP A string representing the IP address to use.
*/
void setRpcIP (std::string const& newIP) { m_rpcIP = newIP; }
/** Set the client or server RPC port number.
@note The port number is not range checked.
@param newPort The RPC port number to use.
*/
void setRpcPort (int newPort) { m_rpcPort = newPort; }
/** Convert the RPC/port combination to a readable string.
*/
String const getRpcAddress ()
{
String s;
s << m_rpcIP.c_str () << ":" << m_rpcPort;
return s;
}
private:
std::string m_rpcIP;
// VFALCO TODO This should be a short.
int m_rpcPort;
//
//----------------------------------------------------------------------------
public:
// RPC parameters
std::string RPC_IP;
int RPC_PORT;
std::vector<std::string> RPC_ADMIN_ALLOW;
std::string RPC_ADMIN_PASSWORD;
std::string RPC_ADMIN_USER;
@@ -175,6 +229,7 @@ public:
std::string RPC_SSL_CERT;
std::string RPC_SSL_CHAIN;
std::string RPC_SSL_KEY;
//----------------------------------------------------------------------------
// Path searching
int PATH_SEARCH_SIZE;

View File

@@ -20,12 +20,12 @@
},
"scripts": {
"test": "node_modules/buster/bin/buster test"
"test": "./node_modules/buster/bin/buster test"
},
"repository": {
"type": "git",
"url": "git://github.com/jedmccaleb/NewCoin.git"
"url": "git://github.com/ripple/rippled.git"
},
"readmeFilename": "README.md"

View File

@@ -878,12 +878,13 @@ int commandLineRPC (const std::vector<std::string>& vCmd)
callRPC (
isService,
theConfig.RPC_IP, theConfig.RPC_PORT,
theConfig.RPC_USER, theConfig.RPC_PASSWORD,
theConfig.getRpcIP (),
theConfig.getRpcPort (),
theConfig.RPC_USER,
theConfig.RPC_PASSWORD,
"",
jvRequest.isMember ("method") // Allow parser to rewrite method.
? jvRequest["method"].asString ()
: vCmd[0],
? jvRequest["method"].asString () : vCmd[0],
jvParams, // Parsed, execute.
false,
BIND_TYPE (callRPCHandler, &jvOutput, P_1));

View File

@@ -11,11 +11,11 @@ extern void initSSLContext (boost::asio::ssl::context& context,
RPCDoor::RPCDoor (boost::asio::io_service& io_service)
: mAcceptor (io_service,
boost::asio::ip::tcp::endpoint (boost::asio::ip::address::from_string (theConfig.RPC_IP), theConfig.RPC_PORT))
boost::asio::ip::tcp::endpoint (boost::asio::ip::address::from_string (theConfig.getRpcIP ()), theConfig.getRpcPort ()))
, mDelayTimer (io_service)
, mSSLContext (boost::asio::ssl::context::sslv23)
{
WriteLog (lsINFO, RPCDoor) << "RPC port: " << theConfig.RPC_IP << " " << theConfig.RPC_PORT << " allow remote: " << theConfig.RPC_ALLOW_REMOTE;
WriteLog (lsINFO, RPCDoor) << "RPC port: " << theConfig.getRpcAddress().toRawUTF8() << " allow remote: " << theConfig.RPC_ALLOW_REMOTE;
if (theConfig.RPC_SECURE != 0)
initSSLContext (mSSLContext, theConfig.RPC_SSL_KEY, theConfig.RPC_SSL_CERT, theConfig.RPC_SSL_CHAIN);
@@ -25,7 +25,7 @@ RPCDoor::RPCDoor (boost::asio::io_service& io_service)
RPCDoor::~RPCDoor ()
{
WriteLog (lsINFO, RPCDoor) << "RPC port: " << theConfig.RPC_IP << " " << theConfig.RPC_PORT << " allow remote: " << theConfig.RPC_ALLOW_REMOTE;
WriteLog (lsINFO, RPCDoor) << "RPC port: " << theConfig.getRpcAddress().toRawUTF8() << " allow remote: " << theConfig.RPC_ALLOW_REMOTE;
}
void RPCDoor::startListening ()

View File

@@ -588,7 +588,7 @@ void Application::setup ()
//
// Allow RPC connections.
//
if (!theConfig.RPC_IP.empty () && theConfig.RPC_PORT)
if (! theConfig.getRpcIP().empty () && theConfig.getRpcPort() != 0)
{
try
{

View File

@@ -57,6 +57,10 @@ void printHelp (const po::options_description& desc)
cerr << desc << endl;
cerr << "Options: " << endl;
cerr << " -rpc-ip=<ip-address>[':'<port-number>]" << endl;
cerr << " -rpc-port=<port-number>" << endl;
cerr << endl;
cerr << "Commands: " << endl;
cerr << " account_info <account>|<nickname>|<seed>|<pass_phrase>|<key> [<ledger>] [strict]" << endl;
cerr << " account_lines <account> <account>|\"\" [<ledger>]" << endl;
@@ -155,6 +159,7 @@ int rippleMain (int argc, char** argv)
int iResult = 0;
po::variables_map vm; // Map of options.
// VFALCO TODO Replace boost program options with something from Beast.
//
// Set up option parsing.
//
@@ -163,6 +168,8 @@ int rippleMain (int argc, char** argv)
("help,h", "Display this message.")
("conf", po::value<std::string> (), "Specify the configuration file.")
("rpc", "Perform rpc command (default).")
("rpc_ip", po::value <std::string> (), "Specify the IP address for RPC command.")
("rpc_port", po::value <int> (), "Specify the port number for RPC command.")
("standalone,a", "Run with no peers.")
("testnet,t", "Run in test net mode.")
("unittest,u", "Perform unit tests.")
@@ -232,13 +239,21 @@ int rippleMain (int argc, char** argv)
}
if (vm.count ("quiet"))
{
Log::setMinSeverity (lsFATAL, true);
}
else if (vm.count ("verbose"))
{
Log::setMinSeverity (lsTRACE, true);
}
else
{
Log::setMinSeverity (lsINFO, true);
}
// VFALCO TODO make these singletons that initialize statically
// VFALCO TODO make this a singleton that initializes statically
// Or could make it a SharedSingleton
//
LEFInit ();
if (vm.count ("unittest"))
@@ -283,6 +298,26 @@ int rippleMain (int argc, char** argv)
theConfig.VALIDATION_QUORUM = 2;
}
if (iResult == 0)
{
// These overrides must happen after the config file is loaded.
// Override the RPC destination IP address
//
if (vm.count ("rpc_ip"))
{
theConfig.setRpcIP (vm ["rpc_ip"].as <std::string> ());
}
// Override the RPC destination port number
//
if (vm.count ("rpc_port"))
{
// VFALCO TODO This should be a short.
theConfig.setRpcPort (vm ["rpc_port"].as <int> ());
}
}
if (iResult)
{
nothing ();

View File

@@ -1,6 +1,6 @@
var config = module.exports;
config["Newcoin tests"] = {
config["Ripple tests"] = {
rootPath: "../",
environment: "node",
tests: [

5
test/runall.sh Normal file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
for f in test/*.js
do
node $f
done