diff --git a/Builds/QtCreator/.gitignore b/Builds/QtCreator/.gitignore
new file mode 100644
index 000000000..20e0d48af
--- /dev/null
+++ b/Builds/QtCreator/.gitignore
@@ -0,0 +1,5 @@
+# QTCreator
+
+Makefile
+*.user
+
diff --git a/Builds/QtCreator/rippled.pro b/Builds/QtCreator/rippled.pro
new file mode 100644
index 000000000..8fc0f80bf
--- /dev/null
+++ b/Builds/QtCreator/rippled.pro
@@ -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
+
+
+
+
diff --git a/Builds/VisualStudio2012/RippleD.props b/Builds/VisualStudio2012/RippleD.props
index 6a999d5fd..2f398635c 100644
--- a/Builds/VisualStudio2012/RippleD.props
+++ b/Builds/VisualStudio2012/RippleD.props
@@ -15,7 +15,7 @@
_VARIADIC_MAX=10;_WIN32_WINNT=0x0600;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions)
true
Level3
- $(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)
+ $(RepoDir);$(RepoDir)\src\cpp\protobuf\src;$(RepoDir)\src\cpp\protobuf\vsprojects;$(RepoDir)\build\proto;$(RepoDir)\Subtrees;$(RepoDir)\Subtrees\leveldb;$(RepoDir)\Subtrees\leveldb\include;%(AdditionalIncludeDirectories)
/bigobj %(AdditionalOptions)
Async
diff --git a/Builds/VisualStudio2012/RippleD.vcxproj b/Builds/VisualStudio2012/RippleD.vcxproj
index 85bbf2d70..59eb30c3d 100644
--- a/Builds/VisualStudio2012/RippleD.vcxproj
+++ b/Builds/VisualStudio2012/RippleD.vcxproj
@@ -88,6 +88,12 @@
true
true
+
+ true
+ true
+ true
+ true
+
true
true
@@ -1321,6 +1327,7 @@
+
diff --git a/Builds/VisualStudio2012/RippleD.vcxproj.filters b/Builds/VisualStudio2012/RippleD.vcxproj.filters
index 236c04c78..71cc6b8f6 100644
--- a/Builds/VisualStudio2012/RippleD.vcxproj.filters
+++ b/Builds/VisualStudio2012/RippleD.vcxproj.filters
@@ -833,6 +833,8 @@
1. Modules\ripple_app
+
+ [1] Ripple\ripple_basics\utility
@@ -1545,6 +1547,9 @@
[1] Ripple\ripple_app\_main
+
+ [1] Ripple\ripple_basics\utility
+
diff --git a/TODO.txt b/TODO.txt
index 8d772e67e..a306a20f7 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -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
diff --git a/modules/ripple_app/ripple_app.cpp b/modules/ripple_app/ripple_app.cpp
index f32fd0bcd..c4f34736f 100644
--- a/modules/ripple_app/ripple_app.cpp
+++ b/modules/ripple_app/ripple_app.cpp
@@ -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
@@ -57,9 +57,9 @@
#include
#include
-#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
diff --git a/modules/ripple_basics/ripple_basics.cpp b/modules/ripple_basics/ripple_basics.cpp
index 1fa03c590..67495b7d5 100644
--- a/modules/ripple_basics/ripple_basics.cpp
+++ b/modules/ripple_basics/ripple_basics.cpp
@@ -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"
diff --git a/modules/ripple_basics/ripple_basics.h b/modules/ripple_basics/ripple_basics.h
index 559e3d915..49eabc212 100644
--- a/modules/ripple_basics/ripple_basics.h
+++ b/modules/ripple_basics/ripple_basics.h
@@ -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
- const T* get_pointer (std::shared_ptr const& ptr)
+{
+ template
+ const T* get_pointer (std::shared_ptr const& ptr)
{
return ptr.get();
}
@@ -64,11 +64,7 @@ namespace boost
# include
#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"
diff --git a/modules/ripple_basics/utility/ripple_Log.cpp b/modules/ripple_basics/utility/ripple_Log.cpp
index 48eba348d..348d25232 100644
--- a/modules/ripple_basics/utility/ripple_Log.cpp
+++ b/modules/ripple_basics/utility/ripple_Log.cpp
@@ -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 > 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::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);
}
}
diff --git a/modules/ripple_basics/utility/ripple_Log.h b/modules/ripple_basics/utility/ripple_Log.h
index 62f441c86..13c44ed15 100644
--- a/modules/ripple_basics/utility/ripple_Log.h
+++ b/modules/ripple_basics/utility/ripple_Log.h
@@ -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;
diff --git a/modules/ripple_basics/utility/ripple_LogFile.cpp b/modules/ripple_basics/utility/ripple_LogFile.cpp
new file mode 100644
index 000000000..8c6d0900f
--- /dev/null
+++ b/modules/ripple_basics/utility/ripple_LogFile.cpp
@@ -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 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;
+ }
+}
+
diff --git a/modules/ripple_basics/utility/ripple_LogFile.h b/modules/ripple_basics/utility/ripple_LogFile.h
new file mode 100644
index 000000000..1d457a9ae
--- /dev/null
+++ b/modules/ripple_basics/utility/ripple_LogFile.h
@@ -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 m_stream;
+ boost::filesystem::path m_path;
+};
+
+#endif
diff --git a/modules/ripple_core/functional/ripple_Config.cpp b/modules/ripple_core/functional/ripple_Config.cpp
index b30f5c21f..c58a0664e 100644
--- a/modules/ripple_core/functional/ripple_Config.cpp
+++ b/modules/ripple_core/functional/ripple_Config.cpp
@@ -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 (strTemp);
+ m_rpcPort = boost::lexical_cast (strTemp);
if (SectionSingleB (secConfig, "ledger_creator" , strTemp))
LEDGER_CREATOR = boost::lexical_cast (strTemp);
diff --git a/modules/ripple_core/functional/ripple_Config.h b/modules/ripple_core/functional/ripple_Config.h
index 865cc32c3..8fee07eaa 100644
--- a/modules/ripple_core/functional/ripple_Config.h
+++ b/modules/ripple_core/functional/ripple_Config.h
@@ -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 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;
diff --git a/package.json b/package.json
index 17d814811..9b13c2daa 100644
--- a/package.json
+++ b/package.json
@@ -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"
diff --git a/src/cpp/ripple/CallRPC.cpp b/src/cpp/ripple/CallRPC.cpp
index cf18272c8..01c3a1578 100644
--- a/src/cpp/ripple/CallRPC.cpp
+++ b/src/cpp/ripple/CallRPC.cpp
@@ -878,12 +878,13 @@ int commandLineRPC (const std::vector& 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));
diff --git a/src/cpp/ripple/RPCDoor.cpp b/src/cpp/ripple/RPCDoor.cpp
index 4b08f6014..ae6f11560 100644
--- a/src/cpp/ripple/RPCDoor.cpp
+++ b/src/cpp/ripple/RPCDoor.cpp
@@ -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 ()
diff --git a/src/cpp/ripple/ripple_Application.cpp b/src/cpp/ripple/ripple_Application.cpp
index ee5c9b0e3..6bac12560 100644
--- a/src/cpp/ripple/ripple_Application.cpp
+++ b/src/cpp/ripple/ripple_Application.cpp
@@ -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
{
diff --git a/src/cpp/ripple/ripple_Main.cpp b/src/cpp/ripple/ripple_Main.cpp
index d9f955294..23b2f619c 100644
--- a/src/cpp/ripple/ripple_Main.cpp
+++ b/src/cpp/ripple/ripple_Main.cpp
@@ -57,6 +57,10 @@ void printHelp (const po::options_description& desc)
cerr << desc << endl;
+ cerr << "Options: " << endl;
+ cerr << " -rpc-ip=[':']" << endl;
+ cerr << " -rpc-port=" << endl;
+ cerr << endl;
cerr << "Commands: " << endl;
cerr << " account_info |||| [] [strict]" << endl;
cerr << " account_lines |\"\" []" << 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 (), "Specify the configuration file.")
("rpc", "Perform rpc command (default).")
+ ("rpc_ip", po::value (), "Specify the IP address for RPC command.")
+ ("rpc_port", po::value (), "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 ());
+ }
+
+ // Override the RPC destination port number
+ //
+ if (vm.count ("rpc_port"))
+ {
+ // VFALCO TODO This should be a short.
+ theConfig.setRpcPort (vm ["rpc_port"].as ());
+ }
+ }
+
if (iResult)
{
nothing ();
diff --git a/test/buster.js b/test/buster.js
index c44540654..a62cd49dc 100644
--- a/test/buster.js
+++ b/test/buster.js
@@ -1,6 +1,6 @@
var config = module.exports;
-config["Newcoin tests"] = {
+config["Ripple tests"] = {
rootPath: "../",
environment: "node",
tests: [
diff --git a/test/runall.sh b/test/runall.sh
new file mode 100644
index 000000000..e0c25f2fe
--- /dev/null
+++ b/test/runall.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+for f in test/*.js
+do
+ node $f
+done