Forward client IP to rippled when proxying (#77)

This commit is contained in:
CJ Cobb
2022-01-05 14:51:00 -05:00
committed by GitHub
parent 41e412302b
commit 49c7c9989f
11 changed files with 37 additions and 86 deletions

View File

@@ -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);