From 709a8463b84ddb82dccaead74d60f8f850ab2a8c Mon Sep 17 00:00:00 2001 From: CJ Cobb <46455409+cjcobb23@users.noreply.github.com> Date: Wed, 10 Aug 2022 15:02:31 -0400 Subject: [PATCH] server_info improvements (#240) * only return counters and etl info if client is localhost * move cache and etl info inside info --- src/rpc/handlers/ServerInfo.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/rpc/handlers/ServerInfo.cpp b/src/rpc/handlers/ServerInfo.cpp index 382447b68..f6d46711f 100644 --- a/src/rpc/handlers/ServerInfo.cpp +++ b/src/rpc/handlers/ServerInfo.cpp @@ -43,10 +43,15 @@ doServerInfo(Context const& context) info[JS(complete_ledgers)] = std::to_string(range->minSequence) + "-" + std::to_string(range->maxSequence); - info[JS(counters)] = boost::json::object{}; - info[JS(counters)].as_object()[JS(rpc)] = context.counters.report(); - info[JS(counters)].as_object()["subscriptions"] = - context.subscriptions->report(); + bool admin = context.clientIp == "127.0.0.1"; + + if (admin) + { + info[JS(counters)] = boost::json::object{}; + info[JS(counters)].as_object()[JS(rpc)] = context.counters.report(); + info[JS(counters)].as_object()["subscriptions"] = + context.subscriptions->report(); + } auto serverInfoRippled = context.balancer->forwardToRippled( {{"command", "server_info"}}, context.clientIp, context.yield); @@ -78,15 +83,18 @@ doServerInfo(Context const& context) validated[JS(reserve_base_xrp)] = fees->reserve.decimalXRP(); validated[JS(reserve_inc_xrp)] = fees->increment.decimalXRP(); - response["cache"] = boost::json::object{}; - auto& cache = response["cache"].as_object(); + info["cache"] = boost::json::object{}; + auto& cache = info["cache"].as_object(); cache["size"] = context.backend->cache().size(); cache["is_full"] = context.backend->cache().isFull(); cache["latest_ledger_seq"] = context.backend->cache().latestLedgerSequence(); - response["etl"] = context.etl->getInfo(); + if (admin) + { + info["etl"] = context.etl->getInfo(); + } return response; }