mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 06:25:51 +00:00
Add rpc_ip and rpc_port command line overrides
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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 ()
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
Reference in New Issue
Block a user