mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 18:45:52 +00:00
Remove obsolete RPCServerHandler:
This removes the legacy RPCServerHandler, which has been replaced by the asynchronous RPC-HTTP/S server and corresponding RPCHTTPHandler.
This commit is contained in:
@@ -3060,9 +3060,6 @@
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\RPCHandler.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\RPCServerHandler.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\Status.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
@@ -3088,8 +3085,6 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\RPCHandler.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\RPCServerHandler.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\Status.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\sitefiles\impl\Logic.h">
|
||||
|
||||
@@ -4185,9 +4185,6 @@
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\RPCHandler.cpp">
|
||||
<Filter>ripple\rpc\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\RPCServerHandler.cpp">
|
||||
<Filter>ripple\rpc\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\Status.cpp">
|
||||
<Filter>ripple\rpc\impl</Filter>
|
||||
</ClCompile>
|
||||
@@ -4221,9 +4218,6 @@
|
||||
<ClInclude Include="..\..\src\ripple\rpc\RPCHandler.h">
|
||||
<Filter>ripple\rpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\RPCServerHandler.h">
|
||||
<Filter>ripple\rpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\Status.h">
|
||||
<Filter>ripple\rpc</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -233,10 +233,4 @@
|
||||
#define RIPPLE_STRUCTURED_OVERLAY_SERVER 1
|
||||
#endif
|
||||
|
||||
/** Config: RIPPLE_ASYNC_RPC_HANDLER
|
||||
*/
|
||||
#ifndef RIPPLE_ASYNC_RPC_HANDLER
|
||||
#define RIPPLE_ASYNC_RPC_HANDLER 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -175,7 +175,6 @@ public:
|
||||
std::unique_ptr <NetworkOPs> m_networkOPs;
|
||||
std::unique_ptr <UniqueNodeList> m_deprecatedUNL;
|
||||
std::unique_ptr <RPCHTTPServer> m_rpcHTTPServer;
|
||||
RPCServerHandler m_rpcServerHandler;
|
||||
std::unique_ptr <NodeStore::Database> m_nodeStore;
|
||||
std::unique_ptr <SNTPClient> m_sntpClient;
|
||||
std::unique_ptr <TxQueue> m_txQueue;
|
||||
@@ -316,9 +315,6 @@ public:
|
||||
*m_jobQueue, *m_networkOPs, *m_resourceManager,
|
||||
setup_RPC(getConfig()["rpc"])))
|
||||
|
||||
// passive object, not a Service
|
||||
, m_rpcServerHandler (*m_networkOPs, *m_resourceManager)
|
||||
|
||||
, m_nodeStore (m_nodeStoreManager->make_Database ("NodeStore.main",
|
||||
m_nodeStoreScheduler, m_logs.journal("NodeObject"),
|
||||
4, // four read threads for now
|
||||
@@ -808,41 +804,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Allow RPC connections.
|
||||
//
|
||||
#if RIPPLE_ASYNC_RPC_HANDLER
|
||||
m_rpcHTTPServer->setup (m_journal);
|
||||
|
||||
#else
|
||||
if (! getConfig ().getRpcIP().empty () && getConfig ().getRpcPort() != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_rpcDoor.reset (RPCDoor::New (m_mainIoPool, m_rpcServerHandler));
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
// Must run as directed or exit.
|
||||
m_journal.fatal <<
|
||||
"Can not open RPC service: " << e.what ();
|
||||
|
||||
exit (3);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_journal.info << "RPC interface: disabled";
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Begin connecting to network.
|
||||
//
|
||||
if (!getConfig ().RUN_STANDALONE)
|
||||
{
|
||||
// Should this message be here, conceptually? In theory this sort
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <ripple/http/Session.h>
|
||||
#include <ripple/app/main/RPCHTTPServer.h>
|
||||
#include <ripple/rpc/RPCHandler.h>
|
||||
#include <ripple/rpc/RPCServerHandler.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -35,7 +34,6 @@ public:
|
||||
beast::Journal m_journal;
|
||||
JobQueue& m_jobQueue;
|
||||
NetworkOPs& m_networkOPs;
|
||||
RPCServerHandler m_deprecatedHandler;
|
||||
HTTP::Server m_server;
|
||||
std::unique_ptr <RippleSSLContext> m_context;
|
||||
RPC::Setup setup_;
|
||||
@@ -48,7 +46,6 @@ public:
|
||||
, m_journal (deprecatedLogs().journal("HTTP-RPC"))
|
||||
, m_jobQueue (jobQueue)
|
||||
, m_networkOPs (networkOPs)
|
||||
, m_deprecatedHandler (networkOPs, resourceManager)
|
||||
, m_server (*this, deprecatedLogs().journal("HTTP"))
|
||||
, setup_ (setup)
|
||||
{
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_RPCSERVERHANDLER_H_INCLUDED
|
||||
#define RIPPLE_RPCSERVERHANDLER_H_INCLUDED
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class NetworkOPs;
|
||||
|
||||
/** Handles RPC requests.
|
||||
*/
|
||||
class RPCServerHandler : public RPCServer::Handler
|
||||
{
|
||||
public:
|
||||
RPCServerHandler (NetworkOPs&, Resource::Manager&);
|
||||
|
||||
std::string createResponse (int statusCode, std::string const& description);
|
||||
bool isAuthorized (std::map <std::string, std::string> const& headers);
|
||||
|
||||
std::string processRequest (
|
||||
std::string const& request,
|
||||
beast::IP::Endpoint const& remoteIPAddress);
|
||||
|
||||
private:
|
||||
NetworkOPs& m_networkOPs;
|
||||
Resource::Manager& m_resourceManager;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/core/LoadFeeTrack.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <ripple/common/jsonrpc_fields.h>
|
||||
#include <ripple/app/main/RPCHTTPServer.h>
|
||||
#include <ripple/rpc/RPCHandler.h>
|
||||
#include <ripple/rpc/RPCServerHandler.h>
|
||||
#include <ripple/rpc/impl/Tuning.h>
|
||||
#include <ripple/rpc/impl/Context.h>
|
||||
#include <ripple/rpc/impl/Handler.h>
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/app/main/RPCHTTPServer.h>
|
||||
#include <ripple/core/Config.h>
|
||||
#include <ripple/core/LoadFeeTrack.h>
|
||||
#include <ripple/rpc/RPCHandler.h>
|
||||
#include <ripple/rpc/RPCServerHandler.h>
|
||||
#include <ripple/rpc/impl/Tuning.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
RPCServerHandler::RPCServerHandler (
|
||||
NetworkOPs& networkOPs,
|
||||
Resource::Manager& resourceManager)
|
||||
: m_networkOPs (networkOPs)
|
||||
, m_resourceManager (resourceManager)
|
||||
{
|
||||
}
|
||||
|
||||
std::string RPCServerHandler::createResponse (
|
||||
int statusCode,
|
||||
std::string const& description)
|
||||
{
|
||||
return HTTPReply (statusCode, description);
|
||||
}
|
||||
|
||||
bool RPCServerHandler::isAuthorized (
|
||||
std::map <std::string, std::string> const& headers)
|
||||
{
|
||||
return HTTPAuthorized (headers);
|
||||
}
|
||||
|
||||
std::string RPCServerHandler::processRequest (
|
||||
std::string const& request,
|
||||
beast::IP::Endpoint const& remoteIPAddress)
|
||||
{
|
||||
Json::Value jsonRequest;
|
||||
{
|
||||
Json::Reader reader;
|
||||
|
||||
if ((request.size() > ripple::RPC::Tuning::maxRequestSize) ||
|
||||
! reader.parse (request, jsonRequest) ||
|
||||
jsonRequest.isNull () ||
|
||||
! jsonRequest.isObject ())
|
||||
{
|
||||
return createResponse (400, "Unable to parse request");
|
||||
}
|
||||
}
|
||||
|
||||
auto const role = getConfig ().getAdminRole (jsonRequest, remoteIPAddress);
|
||||
|
||||
Resource::Consumer usage;
|
||||
|
||||
if (role == Config::ADMIN)
|
||||
{
|
||||
usage = m_resourceManager.newAdminEndpoint (
|
||||
remoteIPAddress.to_string());
|
||||
}
|
||||
else
|
||||
{
|
||||
usage = m_resourceManager.newInboundEndpoint (remoteIPAddress);
|
||||
}
|
||||
|
||||
if (usage.disconnect ())
|
||||
return createResponse (503, "Server is overloaded");
|
||||
|
||||
// Parse id now so errors from here on will have the id
|
||||
//
|
||||
// VFALCO NOTE Except that "id" isn't included in the following errors...
|
||||
//
|
||||
Json::Value const& id = jsonRequest ["id"];
|
||||
Json::Value const& method = jsonRequest ["method"];
|
||||
|
||||
if (method.isNull ())
|
||||
return createResponse (400, "Null method");
|
||||
|
||||
if (! method.isString ())
|
||||
return createResponse (400, "method is not string");
|
||||
|
||||
auto strMethod = method.asString ();
|
||||
if (strMethod.empty())
|
||||
return createResponse (400, "method is empty");
|
||||
|
||||
if (jsonRequest["params"].isNull())
|
||||
jsonRequest["params"] = Json::Value (Json::arrayValue);
|
||||
|
||||
// Parse params
|
||||
Json::Value& params = jsonRequest ["params"];
|
||||
|
||||
if (!params.isArray ())
|
||||
return HTTPReply (400, "params unparseable");
|
||||
|
||||
// VFALCO TODO Shouldn't we handle this earlier?
|
||||
//
|
||||
if (role == Config::FORBID)
|
||||
{
|
||||
// VFALCO TODO Needs implementing
|
||||
// FIXME Needs implementing
|
||||
// XXX This needs rate limiting to prevent brute forcing password.
|
||||
return HTTPReply (403, "Forbidden");
|
||||
}
|
||||
|
||||
// This code does all the work on the io_service thread and
|
||||
// has no rate-limiting based on source IP or anything.
|
||||
// This is a temporary safety
|
||||
if ((role != Config::ADMIN) && (getApp().getFeeTrack().isLoadedLocal()))
|
||||
{
|
||||
return HTTPReply (503, "Unable to service at this time");
|
||||
}
|
||||
|
||||
std::string response;
|
||||
|
||||
WriteLog (lsDEBUG, RPCServer) << "Query: " << strMethod << params;
|
||||
|
||||
{
|
||||
Json::Value ripple_params (params.size()
|
||||
? params [0u] : Json::Value (Json::objectValue));
|
||||
if (!ripple_params.isObject())
|
||||
return HTTPReply (400, "params must be an object");
|
||||
|
||||
ripple_params ["command"] = strMethod;
|
||||
RPC::Request req (deprecatedLogs().journal("RPCServer"),
|
||||
strMethod, ripple_params, getApp ());
|
||||
|
||||
// VFALCO Try processing the command using the new code
|
||||
if (getApp().getRPCManager().dispatch (req))
|
||||
{
|
||||
usage.charge (req.fee);
|
||||
WriteLog (lsDEBUG, RPCServer) << "Reply: " << req.result;
|
||||
return createResponse (200,
|
||||
JSONRPCReply (req.result, Json::Value (), id));
|
||||
}
|
||||
}
|
||||
|
||||
// legacy dispatcher
|
||||
Resource::Charge fee (Resource::feeReferenceRPC);
|
||||
RPCHandler rpcHandler (m_networkOPs);
|
||||
Json::Value const result = rpcHandler.doRpcCommand (
|
||||
strMethod, params, role, fee);
|
||||
|
||||
usage.charge (fee);
|
||||
|
||||
WriteLog (lsDEBUG, RPCServer) << "Reply: " << result;
|
||||
response = JSONRPCReply (result, Json::Value (), id);
|
||||
|
||||
return createResponse (200, response);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <ripple/rpc/impl/JsonObject.cpp>
|
||||
#include <ripple/rpc/impl/JsonWriter.cpp>
|
||||
#include <ripple/rpc/impl/Manager.cpp>
|
||||
#include <ripple/rpc/impl/RPCServerHandler.cpp>
|
||||
#include <ripple/rpc/impl/RPCHandler.cpp>
|
||||
#include <ripple/rpc/impl/Status.cpp>
|
||||
#include <ripple/rpc/impl/Status_test.cpp>
|
||||
|
||||
Reference in New Issue
Block a user