diff --git a/modules/ripple_core/functional/ripple_Config.cpp b/modules/ripple_core/functional/ripple_Config.cpp index 568f708ed8..741c528908 100644 --- a/modules/ripple_core/functional/ripple_Config.cpp +++ b/modules/ripple_core/functional/ripple_Config.cpp @@ -578,5 +578,23 @@ int Config::getSize (SizedItemName item) return -1; } +void Config::setRpcIpAndOptionalPort (std::string const& newAddress) +{ + String const s (newAddress.c_str ()); + + int const colonPosition = s.lastIndexOfChar (':'); + + if (colonPosition != -1) + { + String const ipPart = s.substring (0, colonPosition); + String const portPart = s.substring (colonPosition + 1, s.length ()); + + setRpcIP (ipPart.toRawUTF8 ()); + setRpcPort (portPart.getIntValue ()); + } + else + { + setRpcIP (newAddress); + } +} -// vim:ts=4 diff --git a/modules/ripple_core/functional/ripple_Config.h b/modules/ripple_core/functional/ripple_Config.h index 8fee07eaa3..0d9b3c1c5a 100644 --- a/modules/ripple_core/functional/ripple_Config.h +++ b/modules/ripple_core/functional/ripple_Config.h @@ -181,6 +181,14 @@ public: */ int getRpcPort () const { return m_rpcPort; } + /** Set the client or server RPC IP and optional port. + + @note The string is not syntax checked. + + @param newAddress A string in the format [':'] + */ + void setRpcIpAndOptionalPort (std::string const& newAddress); + /** Set the client or server RPC IP. @note The string is not syntax-checked. diff --git a/src/cpp/ripple/ripple_Main.cpp b/src/cpp/ripple/ripple_Main.cpp index a5b42f972a..21c5d8b59e 100644 --- a/src/cpp/ripple/ripple_Main.cpp +++ b/src/cpp/ripple/ripple_Main.cpp @@ -164,7 +164,7 @@ 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_ip", po::value (), "Specify the IP address for RPC command. Format: [':']") ("rpc_port", po::value (), "Specify the port number for RPC command.") ("standalone,a", "Run with no peers.") ("testnet,t", "Run in test net mode.") @@ -302,7 +302,7 @@ int rippleMain (int argc, char** argv) // if (vm.count ("rpc_ip")) { - theConfig.setRpcIP (vm ["rpc_ip"].as ()); + theConfig.setRpcIpAndOptionalPort (vm ["rpc_ip"].as ()); } // Override the RPC destination port number