Support dns in gRPC connection for reporting ETL

This commit is contained in:
CJ Cobb
2021-02-22 15:39:07 -05:00
committed by manojsdoshi
parent 2eb1c6a396
commit 6298daba1a
2 changed files with 19 additions and 5 deletions

View File

@@ -867,7 +867,7 @@
#
# source_ip = <IP-address>
#
# Required. IP address of the ETL source
# Required. IP address of the ETL source. Can also be a DNS record.
#
# source_ws_port = <number>
#

View File

@@ -63,14 +63,28 @@ ETLSource::ETLSource(
, app_(etl_.getApplication())
, timer_(ioc_)
{
std::string connectionString;
try
{
connectionString =
beast::IP::Endpoint(
boost::asio::ip::make_address(ip_), std::stoi(grpcPort_))
.to_string();
JLOG(journal_.info())
<< "Using IP to connect to ETL source: " << connectionString;
}
catch (std::exception const&)
{
connectionString = "dns:" + ip_ + ":" + grpcPort_;
JLOG(journal_.info())
<< "Using DNS to connect to ETL source: " << connectionString;
}
try
{
stub_ = org::xrpl::rpc::v1::XRPLedgerAPIService::NewStub(
grpc::CreateChannel(
beast::IP::Endpoint(
boost::asio::ip::make_address(ip_), std::stoi(grpcPort_))
.to_string(),
grpc::InsecureChannelCredentials()));
connectionString, grpc::InsecureChannelCredentials()));
JLOG(journal_.info()) << "Made stub for remote = " << toString();
}
catch (std::exception const& e)