Skip to content

Commit

Permalink
Publish peer and grpc ports to server_info
Browse files Browse the repository at this point in the history
  • Loading branch information
drlongle committed Feb 23, 2023
1 parent 1593d05 commit 7cad80a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ripple/app/main/GRPCServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ GRPCServerImpl::GRPCServerImpl(Application& app)
// if present, get endpoint from config
if (app_.config().exists("port_grpc"))
{
Section section = app_.config().section("port_grpc");
const auto& section = app_.config().section("port_grpc");

auto const optIp = section.get("ip");
if (!optIp)
Expand Down
19 changes: 17 additions & 2 deletions src/ripple/app/misc/NetworkOPs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
#include <boost/asio/ip/host_name.hpp>
#include <boost/asio/steady_timer.hpp>

#include <algorithm>
#include <mutex>
#include <string>
#include <tuple>
Expand Down Expand Up @@ -2663,8 +2664,9 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
}

// This array must be sorted in increasing order.
static constexpr std::array<std::string_view, 6> protocols{
"http", "https", "ws", "ws2", "wss", "wss2"};
static constexpr std::array<std::string_view, 7> protocols{
"http", "https", "peer", "ws", "ws2", "wss", "wss2"};
static_assert(std::is_sorted(std::begin(protocols), std::end(protocols)));
{
Json::Value ports{Json::arrayValue};
std::vector<std::string> proto;
Expand All @@ -2691,6 +2693,19 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
jv[jss::protocol].append(p);
}
}

if (app_.config().exists("port_grpc"))
{
auto const& grpcSection = app_.config().section("port_grpc");
auto const optPort = grpcSection.get("port");
if (optPort && grpcSection.get("ip"))
{
auto& jv = ports.append(Json::Value(Json::objectValue));
jv[jss::port] = *optPort;
jv[jss::protocol] = Json::Value{Json::arrayValue};
jv[jss::protocol].append("port_grpc");
}
}
info[jss::ports] = std::move(ports);
}

Expand Down

0 comments on commit 7cad80a

Please sign in to comment.