From 567e67c1877e057f0f17a5e66cd8f2e54d0176da Mon Sep 17 00:00:00 2001 From: Gregory Tsipenyuk Date: Tue, 28 Jan 2020 09:13:45 -0500 Subject: [PATCH] Append default port (51235) in [ips] and [ips_fixed] when no port is specified FIXES: #2861 --- src/ripple/overlay/impl/OverlayImpl.cpp | 36 ++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/ripple/overlay/impl/OverlayImpl.cpp b/src/ripple/overlay/impl/OverlayImpl.cpp index 34b0a8af341..de2b24bdc8d 100644 --- a/src/ripple/overlay/impl/OverlayImpl.cpp +++ b/src/ripple/overlay/impl/OverlayImpl.cpp @@ -538,11 +538,15 @@ OverlayImpl::onPrepare() { if (addr.port () == 0) { - Throw ("Port not specified for " - "address:" + addr.to_string ()); + JLOG(journal_.debug()) << "Port not specified (bootstrapIps) for address:" + << addr.to_string () + << ", using default port 51235"; + beast::IP::Endpoint addr_default(addr.address(), 51235); + } + else + { + ips.push_back (to_string (addr)); } - - ips.push_back (to_string (addr)); } std::string const base ("config: "); @@ -558,8 +562,28 @@ OverlayImpl::onPrepare() std::string const& name, std::vector const& addresses) { - if (!addresses.empty ()) - m_peerFinder->addFixedPeer (name, addresses); + std::vector addresses_update; + addresses_update.reserve(addresses.size()); + for (auto const& addr : addresses) + { + if (addr.port () == 0) + { + JLOG(journal_.debug()) << "Port not specified (ips_fixed) for address:" + << addr.to_string () + << ", using default port 51235"; + beast::IP::Endpoint addr_default(addr.address(), 51235); + addresses_update.push_back(addr_default); + } + else + { + addresses_update.push_back(addr); + } + } + + if (!addresses_update.empty()) + { + m_peerFinder->addFixedPeer (name, addresses_update); + } }); } }