Set admin privileges on websocket:

When the websocket connection is established, any configured administrative
privileges are applied to resource limits.
This commit is contained in:
Vinnie Falco
2015-10-02 19:32:29 -07:00
committed by Vinnie Falco
parent 84c0ae1c6d
commit 8b8334af86
4 changed files with 20 additions and 16 deletions

View File

@@ -112,9 +112,6 @@ public:
Consumer newInboundEndpoint (beast::IP::Endpoint const& address)
{
if (isWhitelisted (address))
return newAdminEndpoint (to_string (address));
Entry* entry (nullptr);
{
@@ -146,9 +143,6 @@ public:
Consumer newOutboundEndpoint (beast::IP::Endpoint const& address)
{
if (isWhitelisted (address))
return newAdminEndpoint (to_string (address));
Entry* entry (nullptr);
{
@@ -370,14 +364,6 @@ public:
//--------------------------------------------------------------------------
bool isWhitelisted (beast::IP::Endpoint const& address)
{
if (! is_public (address))
return true;
return false;
}
// Called periodically to expire entries and groom the table.
//
void periodicActivity ()

View File

@@ -22,6 +22,7 @@
#include <ripple/server/Port.h>
#include <ripple/json/json_value.h>
#include <ripple/resource/ResourceManager.h>
#include <beast/net/IPEndpoint.h>
#include <vector>
@@ -47,6 +48,11 @@ Role
requestRole (Role const& required, HTTP::Port const& port,
Json::Value const& jsonRPC, beast::IP::Endpoint const& remoteIp);
Resource::Consumer
requestInboundEndpoint (Resource::Manager& manager,
beast::IP::Endpoint const& remoteAddress,
HTTP::Port const& port);
} // ripple
#endif

View File

@@ -66,4 +66,15 @@ requestRole (Role const& required, HTTP::Port const& port,
return role;
}
Resource::Consumer
requestInboundEndpoint (Resource::Manager& manager,
beast::IP::Endpoint const& remoteAddress,
HTTP::Port const& port)
{
if (requestRole (Role::GUEST, port, Json::Value(), remoteAddress) ==
Role::ADMIN)
return manager.newAdminEndpoint (to_string (remoteAddress));
return manager.newInboundEndpoint(remoteAddress);
}
}

View File

@@ -34,6 +34,7 @@
#include <ripple/rpc/Coroutine.h>
#include <ripple/rpc/RPCHandler.h>
#include <ripple/server/Port.h>
#include <ripple/server/Role.h>
#include <ripple/json/to_string.h>
#include <ripple/rpc/RPCHandler.h>
#include <ripple/rpc/Yield.h>
@@ -133,8 +134,8 @@ ConnectionImpl <WebSocket>::ConnectionImpl (
connection_ptr const& cpConnection,
beast::IP::Endpoint const& remoteAddress,
boost::asio::io_service& io_service)
: InfoSub (source, // usage
resourceManager.newInboundEndpoint (remoteAddress))
: InfoSub (source, requestInboundEndpoint (
resourceManager, remoteAddress, handler.port()))
, app_(app)
, m_port (handler.port ())
, m_resourceManager (resourceManager)