mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-29 23:45:51 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
@@ -659,7 +659,12 @@ Json::Value callRPC(const std::string& strIp, const int iPort, const std::string
|
||||
{
|
||||
// Connect to localhost
|
||||
if (!theConfig.QUIET)
|
||||
{
|
||||
std::cerr << "Connecting to: " << strIp << ":" << iPort << std::endl;
|
||||
std::cerr << "Username: " << strUsername << ":" << strPassword << std::endl;
|
||||
std::cerr << "Path: " << strPassword << std::endl;
|
||||
std::cerr << "Method: " << strMethod << std::endl;
|
||||
}
|
||||
|
||||
boost::asio::ip::tcp::endpoint
|
||||
endpoint(boost::asio::ip::address::from_string(strIp), iPort);
|
||||
@@ -668,18 +673,21 @@ Json::Value callRPC(const std::string& strIp, const int iPort, const std::string
|
||||
if (stream.fail())
|
||||
throw std::runtime_error("couldn't connect to server");
|
||||
|
||||
cLog(lsDEBUG) << "connected" << std::endl;
|
||||
// HTTP basic authentication
|
||||
std::string strUserPass64 = EncodeBase64(strUsername + ":" + strPassword);
|
||||
std::map<std::string, std::string> mapRequestHeaders;
|
||||
mapRequestHeaders["Authorization"] = std::string("Basic ") + strUserPass64;
|
||||
|
||||
cLog(lsDEBUG) << "requesting" << std::endl;
|
||||
// Send request
|
||||
std::string strRequest = JSONRPCRequest(strMethod, params, Json::Value(1));
|
||||
cLog(lsDEBUG) << "send request " << strMethod << " : " << strRequest << std::endl;
|
||||
cLog(lsDEBUG) << "send request " << strMethod << " : " << strRequest << std::endl;
|
||||
|
||||
std::string strPost = createHTTPPost(strPath, strRequest, mapRequestHeaders);
|
||||
stream << strPost << std::flush;
|
||||
|
||||
// std::cerr << "post " << strPost << std::endl;
|
||||
std::cerr << "post " << strPost << std::endl;
|
||||
|
||||
// Receive reply
|
||||
std::map<std::string, std::string> mapHeaders;
|
||||
|
||||
@@ -2305,8 +2305,11 @@ Json::Value RPCHandler::doSubscribe(Json::Value jvRequest)
|
||||
|
||||
if (jvRequest.isMember("url"))
|
||||
{
|
||||
// Temporarily off.
|
||||
#if 0
|
||||
if (mRole != ADMIN)
|
||||
return rpcError(rpcNO_PERMISSION);
|
||||
#endif
|
||||
|
||||
std::string strUrl = jvRequest["url"].asString();
|
||||
std::string strUsername = jvRequest.isMember("username") ? jvRequest["username"].asString() : "";
|
||||
|
||||
@@ -21,6 +21,9 @@ RPCSub::RPCSub(const std::string& strUrl, const std::string& strUsername, const
|
||||
}
|
||||
|
||||
mSeq = 1;
|
||||
|
||||
if (mPort < 0)
|
||||
mPort = 80;
|
||||
}
|
||||
|
||||
void RPCSub::sendThread()
|
||||
@@ -55,9 +58,11 @@ void RPCSub::sendThread()
|
||||
// Send outside of the lock.
|
||||
if (bSend)
|
||||
{
|
||||
// Drop result.
|
||||
try
|
||||
{
|
||||
cLog(lsDEBUG) << boost::str(boost::format("callRPC calling: %s") % mIp);
|
||||
|
||||
// Drop result.
|
||||
(void) callRPC(mIp, mPort, mUsername, mPassword, mPath, "event", jvEvent);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
@@ -76,9 +81,12 @@ void RPCSub::send(const Json::Value& jvObj)
|
||||
{
|
||||
// Drop the previous event.
|
||||
|
||||
cLog(lsDEBUG) << boost::str(boost::format("callRPC drop"));
|
||||
mDeque.pop_back();
|
||||
}
|
||||
|
||||
cLog(lsDEBUG) << boost::str(boost::format("callRPC push: %s") % jvObj);
|
||||
|
||||
mDeque.push_back(std::make_pair(mSeq++, jvObj));
|
||||
|
||||
if (!mSending)
|
||||
@@ -86,6 +94,7 @@ void RPCSub::send(const Json::Value& jvObj)
|
||||
// Start a sending thread.
|
||||
mSending = true;
|
||||
|
||||
cLog(lsDEBUG) << boost::str(boost::format("callRPC start"));
|
||||
boost::thread(boost::bind(&RPCSub::sendThread, this)).detach();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user