mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
.
This commit is contained in:
@@ -122,6 +122,7 @@
|
||||
<ClCompile Include="src\main.cpp" />
|
||||
<ClCompile Include="src\NetworkOPs.cpp" />
|
||||
<ClCompile Include="src\NewcoinAddress.cpp" />
|
||||
<ClCompile Include="src\NicknameState.cpp" />
|
||||
<ClCompile Include="src\PackedMessage.cpp" />
|
||||
<ClCompile Include="src\ParseSection.cpp" />
|
||||
<ClCompile Include="src\Peer.cpp" />
|
||||
|
||||
@@ -243,6 +243,9 @@
|
||||
<ClCompile Include="src\LedgerProposal.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\NicknameState.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Application.h">
|
||||
|
||||
@@ -145,6 +145,7 @@ Json::Value callRPC(const std::string& strMethod, const Json::Value& params)
|
||||
throw std::runtime_error("no response from server");
|
||||
|
||||
// Parse reply
|
||||
std::cout << "RPC reply: " << strReply << std::endl;
|
||||
Json::Reader reader;
|
||||
Json::Value valReply;
|
||||
if (!reader.parse(strReply, valReply))
|
||||
|
||||
@@ -11,7 +11,7 @@ using namespace boost::asio::ip;
|
||||
RPCDoor::RPCDoor(boost::asio::io_service& io_service) :
|
||||
mAcceptor(io_service, tcp::endpoint(address::from_string(theConfig.RPC_IP), theConfig.RPC_PORT))
|
||||
{
|
||||
cerr << "RPC port: " << theConfig.RPC_IP << " " << theConfig.RPC_PORT << endl;
|
||||
cerr << "RPC port: " << theConfig.RPC_IP << " " << theConfig.RPC_PORT << " allow remote: " << theConfig.RPC_ALLOW_REMOTE << endl;
|
||||
startListening();
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ void RPCServer::handle_read(const boost::system::error_code& e,
|
||||
if (result)
|
||||
{
|
||||
mReplyStr=handleRequest(mIncomingRequest.mBody);
|
||||
|
||||
sendReply();
|
||||
}
|
||||
else if (!result)
|
||||
@@ -2043,13 +2044,29 @@ Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params
|
||||
|
||||
void RPCServer::sendReply()
|
||||
{
|
||||
std::cout << "RPC reply: " << mReplyStr << std::endl;
|
||||
boost::asio::async_write(mSocket, boost::asio::buffer(mReplyStr),
|
||||
boost::bind(&RPCServer::handle_write, shared_from_this(),
|
||||
boost::asio::placeholders::error));
|
||||
}
|
||||
|
||||
void RPCServer::handle_write(const boost::system::error_code& /*error*/)
|
||||
|
||||
|
||||
void RPCServer::handle_write(const boost::system::error_code& e)
|
||||
{
|
||||
std::cout << "async_write complete " << e << std::endl;
|
||||
|
||||
if(!e)
|
||||
{
|
||||
// Initiate graceful connection closure.
|
||||
boost::system::error_code ignored_ec;
|
||||
mSocket.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored_ec);
|
||||
}
|
||||
|
||||
if (e != boost::asio::error::operation_aborted)
|
||||
{
|
||||
//connection_manager_.stop(shared_from_this());
|
||||
}
|
||||
}
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
10
src/rpc.cpp
10
src/rpc.cpp
@@ -96,18 +96,24 @@ std::string HTTPReply(int nStatus, const std::string& strMsg)
|
||||
else if (nStatus == 403) strStatus = "Forbidden";
|
||||
else if (nStatus == 404) strStatus = "Not Found";
|
||||
else if (nStatus == 500) strStatus = "Internal Server Error";
|
||||
std::string access;
|
||||
if(theConfig.RPC_ALLOW_REMOTE) access="Access-Control-Allow-Origin: *\r\n";
|
||||
else access="";
|
||||
|
||||
return strprintf(
|
||||
"HTTP/1.1 %d %s\r\n"
|
||||
"Date: %s\r\n"
|
||||
"Connection: close\r\n"
|
||||
"Connection: Keep-Alive\r\n"
|
||||
"%s"
|
||||
"Content-Length: %d\r\n"
|
||||
"Content-Type: application/json\r\n"
|
||||
"Content-Type: application/json; charset=UTF-8\r\n"
|
||||
"Server: coin-json-rpc/%s\r\n"
|
||||
"\r\n"
|
||||
"%s",
|
||||
nStatus,
|
||||
strStatus.c_str(),
|
||||
rfc1123Time().c_str(),
|
||||
access.c_str(),
|
||||
strMsg.size(),
|
||||
theConfig.VERSION_STR.c_str(),
|
||||
strMsg.c_str());
|
||||
|
||||
Reference in New Issue
Block a user