From 040c8f4de1a700411d4699aaeccfdb64bd184f44 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Tue, 9 Jul 2013 12:37:18 -0700 Subject: [PATCH] Add utility function for RPCServer --- TODO.txt | 6 ++++++ modules/ripple_app/basics/ripple_RPCServer.cpp | 11 +++++++++++ modules/ripple_app/basics/ripple_RPCServer.h | 6 ++++++ src/cpp/ripple/RPCDoor.cpp | 4 +++- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/TODO.txt b/TODO.txt index 3d538507e..5b8c719b6 100644 --- a/TODO.txt +++ b/TODO.txt @@ -2,6 +2,12 @@ RIPPLE TODO -------------------------------------------------------------------------------- +- Maybe rename RPCServer to RPCClientServicer + +- Take away the "I" prefix from abstract interface classes, in both the class + name and the file name. It is messing up sorting in the IDE. Use "Imp" or + suffix for implementations. + - Profile/VTune the application to identify hot spots * Determine why rippled has a slow startup on Windows * Improve the performance when running all unit tests on Windows diff --git a/modules/ripple_app/basics/ripple_RPCServer.cpp b/modules/ripple_app/basics/ripple_RPCServer.cpp index 175bdffbf..7c2f5afb1 100644 --- a/modules/ripple_app/basics/ripple_RPCServer.cpp +++ b/modules/ripple_app/basics/ripple_RPCServer.cpp @@ -281,6 +281,17 @@ private: boost::asio::placeholders::error))); } + //-------------------------------------------------------------------------- + + std::string getRemoteAddressText () + { + std::string address; + + address = mSocket.PlainSocket ().remote_endpoint ().address ().to_string (); + + return address; + } + private: NetworkOPs* const mNetOps; diff --git a/modules/ripple_app/basics/ripple_RPCServer.h b/modules/ripple_app/basics/ripple_RPCServer.h index 13a7f1cac..c38dc3db3 100644 --- a/modules/ripple_app/basics/ripple_RPCServer.h +++ b/modules/ripple_app/basics/ripple_RPCServer.h @@ -28,6 +28,12 @@ public: virtual boost::asio::ip::tcp::socket& getRawSocket () = 0; virtual void connected () = 0; + + /** Retrieve the remote address as a string. + + @return A std::string representing the remote address. + */ + virtual std::string getRemoteAddressText () = 0; }; #endif diff --git a/src/cpp/ripple/RPCDoor.cpp b/src/cpp/ripple/RPCDoor.cpp index 1197f5165..006213a20 100644 --- a/src/cpp/ripple/RPCDoor.cpp +++ b/src/cpp/ripple/RPCDoor.cpp @@ -43,6 +43,8 @@ bool RPCDoor::isClientAllowed (const std::string& ip) if (theConfig.RPC_ALLOW_REMOTE) return true; + // VFALCO TODO Represent ip addresses as a structure. Use isLoopback() member here + // if (ip == "127.0.0.1") return true; @@ -58,7 +60,7 @@ void RPCDoor::handleConnect (RPCServer::pointer new_connection, const boost::sys // Restrict callers by IP try { - if (!isClientAllowed (new_connection->getRawSocket ().remote_endpoint ().address ().to_string ())) + if (! isClientAllowed (new_connection->getRemoteAddressText ())) { startListening (); return;