mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-27 15:15:52 +00:00
Forward client IP to rippled when proxying (#77)
This commit is contained in:
@@ -11,7 +11,8 @@ make_WsContext(
|
||||
std::shared_ptr<ETLLoadBalancer> const& balancer,
|
||||
std::shared_ptr<WsBase> const& session,
|
||||
Backend::LedgerRange const& range,
|
||||
Counters& counters)
|
||||
Counters& counters,
|
||||
std::string const& clientIp)
|
||||
{
|
||||
if (!request.contains("command"))
|
||||
return {};
|
||||
@@ -27,7 +28,8 @@ make_WsContext(
|
||||
balancer,
|
||||
session,
|
||||
range,
|
||||
counters};
|
||||
counters,
|
||||
clientIp};
|
||||
}
|
||||
|
||||
std::optional<Context>
|
||||
@@ -37,7 +39,8 @@ make_HttpContext(
|
||||
std::shared_ptr<SubscriptionManager> const& subscriptions,
|
||||
std::shared_ptr<ETLLoadBalancer> const& balancer,
|
||||
Backend::LedgerRange const& range,
|
||||
RPC::Counters& counters)
|
||||
RPC::Counters& counters,
|
||||
std::string const& clientIp)
|
||||
{
|
||||
if (!request.contains("method") || !request.at("method").is_string())
|
||||
return {};
|
||||
@@ -67,7 +70,8 @@ make_HttpContext(
|
||||
balancer,
|
||||
nullptr,
|
||||
range,
|
||||
counters};
|
||||
counters,
|
||||
clientIp};
|
||||
}
|
||||
|
||||
boost::json::object
|
||||
@@ -162,7 +166,7 @@ buildResponse(Context const& ctx)
|
||||
{
|
||||
if (shouldForwardToRippled(ctx))
|
||||
{
|
||||
auto res = ctx.balancer->forwardToRippled(ctx.params);
|
||||
auto res = ctx.balancer->forwardToRippled(ctx.params, ctx.clientIp);
|
||||
|
||||
ctx.counters.rpcForwarded(ctx.method);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user