mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
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:
committed by
Vinnie Falco
parent
84c0ae1c6d
commit
8b8334af86
@@ -112,9 +112,6 @@ public:
|
|||||||
|
|
||||||
Consumer newInboundEndpoint (beast::IP::Endpoint const& address)
|
Consumer newInboundEndpoint (beast::IP::Endpoint const& address)
|
||||||
{
|
{
|
||||||
if (isWhitelisted (address))
|
|
||||||
return newAdminEndpoint (to_string (address));
|
|
||||||
|
|
||||||
Entry* entry (nullptr);
|
Entry* entry (nullptr);
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -146,9 +143,6 @@ public:
|
|||||||
|
|
||||||
Consumer newOutboundEndpoint (beast::IP::Endpoint const& address)
|
Consumer newOutboundEndpoint (beast::IP::Endpoint const& address)
|
||||||
{
|
{
|
||||||
if (isWhitelisted (address))
|
|
||||||
return newAdminEndpoint (to_string (address));
|
|
||||||
|
|
||||||
Entry* entry (nullptr);
|
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.
|
// Called periodically to expire entries and groom the table.
|
||||||
//
|
//
|
||||||
void periodicActivity ()
|
void periodicActivity ()
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <ripple/server/Port.h>
|
#include <ripple/server/Port.h>
|
||||||
#include <ripple/json/json_value.h>
|
#include <ripple/json/json_value.h>
|
||||||
|
#include <ripple/resource/ResourceManager.h>
|
||||||
#include <beast/net/IPEndpoint.h>
|
#include <beast/net/IPEndpoint.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -47,6 +48,11 @@ Role
|
|||||||
requestRole (Role const& required, HTTP::Port const& port,
|
requestRole (Role const& required, HTTP::Port const& port,
|
||||||
Json::Value const& jsonRPC, beast::IP::Endpoint const& remoteIp);
|
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
|
} // ripple
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -66,4 +66,15 @@ requestRole (Role const& required, HTTP::Port const& port,
|
|||||||
return role;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include <ripple/rpc/Coroutine.h>
|
#include <ripple/rpc/Coroutine.h>
|
||||||
#include <ripple/rpc/RPCHandler.h>
|
#include <ripple/rpc/RPCHandler.h>
|
||||||
#include <ripple/server/Port.h>
|
#include <ripple/server/Port.h>
|
||||||
|
#include <ripple/server/Role.h>
|
||||||
#include <ripple/json/to_string.h>
|
#include <ripple/json/to_string.h>
|
||||||
#include <ripple/rpc/RPCHandler.h>
|
#include <ripple/rpc/RPCHandler.h>
|
||||||
#include <ripple/rpc/Yield.h>
|
#include <ripple/rpc/Yield.h>
|
||||||
@@ -133,8 +134,8 @@ ConnectionImpl <WebSocket>::ConnectionImpl (
|
|||||||
connection_ptr const& cpConnection,
|
connection_ptr const& cpConnection,
|
||||||
beast::IP::Endpoint const& remoteAddress,
|
beast::IP::Endpoint const& remoteAddress,
|
||||||
boost::asio::io_service& io_service)
|
boost::asio::io_service& io_service)
|
||||||
: InfoSub (source, // usage
|
: InfoSub (source, requestInboundEndpoint (
|
||||||
resourceManager.newInboundEndpoint (remoteAddress))
|
resourceManager, remoteAddress, handler.port()))
|
||||||
, app_(app)
|
, app_(app)
|
||||||
, m_port (handler.port ())
|
, m_port (handler.port ())
|
||||||
, m_resourceManager (resourceManager)
|
, m_resourceManager (resourceManager)
|
||||||
|
|||||||
Reference in New Issue
Block a user