diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj index c4b52e27fa..e5d5b1ccc5 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj +++ b/Builds/VisualStudio2013/RippleD.vcxproj @@ -3060,9 +3060,6 @@ True - - True - True @@ -3088,8 +3085,6 @@ - - diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters index 7e1248ce0f..cf069d223d 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters @@ -4185,9 +4185,6 @@ ripple\rpc\impl - - ripple\rpc\impl - ripple\rpc\impl @@ -4221,9 +4218,6 @@ ripple\rpc - - ripple\rpc - ripple\rpc diff --git a/src/BeastConfig.h b/src/BeastConfig.h index bf71a0bd1e..b066800a35 100644 --- a/src/BeastConfig.h +++ b/src/BeastConfig.h @@ -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 diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index 72f2abc249..b60b953c4f 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -175,7 +175,6 @@ public: std::unique_ptr m_networkOPs; std::unique_ptr m_deprecatedUNL; std::unique_ptr m_rpcHTTPServer; - RPCServerHandler m_rpcServerHandler; std::unique_ptr m_nodeStore; std::unique_ptr m_sntpClient; std::unique_ptr 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 diff --git a/src/ripple/app/main/RPCHTTPServer.cpp b/src/ripple/app/main/RPCHTTPServer.cpp index eb8fc54660..7f810e99eb 100644 --- a/src/ripple/app/main/RPCHTTPServer.cpp +++ b/src/ripple/app/main/RPCHTTPServer.cpp @@ -21,7 +21,6 @@ #include #include #include -#include 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 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) { diff --git a/src/ripple/rpc/RPCServerHandler.h b/src/ripple/rpc/RPCServerHandler.h deleted file mode 100644 index 5d78f01127..0000000000 --- a/src/ripple/rpc/RPCServerHandler.h +++ /dev/null @@ -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 const& headers); - - std::string processRequest ( - std::string const& request, - beast::IP::Endpoint const& remoteIPAddress); - -private: - NetworkOPs& m_networkOPs; - Resource::Manager& m_resourceManager; -}; - -} - -#endif diff --git a/src/ripple/rpc/handlers/Ledger.cpp b/src/ripple/rpc/handlers/Ledger.cpp index 6f95db9064..6e1b445088 100644 --- a/src/ripple/rpc/handlers/Ledger.cpp +++ b/src/ripple/rpc/handlers/Ledger.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include namespace ripple { diff --git a/src/ripple/rpc/impl/RPCHandler.cpp b/src/ripple/rpc/impl/RPCHandler.cpp index 36f227ca7e..7aefae7903 100644 --- a/src/ripple/rpc/impl/RPCHandler.cpp +++ b/src/ripple/rpc/impl/RPCHandler.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ripple/rpc/impl/RPCServerHandler.cpp b/src/ripple/rpc/impl/RPCServerHandler.cpp deleted file mode 100644 index a3a875a581..0000000000 --- a/src/ripple/rpc/impl/RPCServerHandler.cpp +++ /dev/null @@ -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 -#include -#include -#include -#include -#include - -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 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); -} - -} diff --git a/src/ripple/unity/rpcx.cpp b/src/ripple/unity/rpcx.cpp index d8a37586fa..6d28a231d9 100644 --- a/src/ripple/unity/rpcx.cpp +++ b/src/ripple/unity/rpcx.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include