diff --git a/src/ripple/overlay/impl/OverlayImpl.cpp b/src/ripple/overlay/impl/OverlayImpl.cpp index 14fb679174d..aa469e308fd 100644 --- a/src/ripple/overlay/impl/OverlayImpl.cpp +++ b/src/ripple/overlay/impl/OverlayImpl.cpp @@ -577,14 +577,9 @@ OverlayImpl::onPrepare() for (auto const& addr : addresses) { if (addr.port() == 0) - { - Throw( - "Port not specified for " - "address:" + - addr.to_string()); - } - - ips.push_back(to_string(addr)); + ips.push_back(to_string(addr.at_port(DEFAULT_PEER_PORT))); + else + ips.push_back(to_string(addr)); } std::string const base("config: "); @@ -600,8 +595,19 @@ OverlayImpl::onPrepare() [this]( std::string const& name, std::vector const& addresses) { - if (!addresses.empty()) - m_peerFinder->addFixedPeer(name, addresses); + std::vector ips; + ips.reserve(addresses.size()); + + for (auto& addr : addresses) + { + if (addr.port() == 0) + ips.emplace_back(addr.address(), DEFAULT_PEER_PORT); + else + ips.emplace_back(addr); + } + + if (!ips.empty()) + m_peerFinder->addFixedPeer(name, ips); }); } } diff --git a/src/ripple/protocol/SystemParameters.h b/src/ripple/protocol/SystemParameters.h index dcadaab247c..a74155a6a32 100644 --- a/src/ripple/protocol/SystemParameters.h +++ b/src/ripple/protocol/SystemParameters.h @@ -61,4 +61,7 @@ static std::uint32_t constexpr XRP_LEDGER_EARLIEST_SEQ{32570}; } // namespace ripple +/** Default peer port (IANA registered) */ +inline std::uint16_t constexpr DEFAULT_PEER_PORT{2459}; + #endif diff --git a/src/ripple/rpc/handlers/Connect.cpp b/src/ripple/rpc/handlers/Connect.cpp index 4c6cddbc817..5863fe5e4d8 100644 --- a/src/ripple/rpc/handlers/Connect.cpp +++ b/src/ripple/rpc/handlers/Connect.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -53,7 +54,7 @@ doConnect(RPC::JsonContext& context) if (context.params.isMember(jss::port)) iPort = context.params[jss::port].asInt(); else - iPort = 6561; + iPort = DEFAULT_PEER_PORT; auto ip = beast::IP::Endpoint::from_string(context.params[jss::ip].asString());