Update the default port for [ips] and [ips_fixed]:

If a port number is not specified in the [ips] or [ips_fixed]
blocks, automatically add the new default peer port which was
registered with IANA: 2459. Also use 2459 if no port is specified
with manually using the `connect` command; previously it was
using 6561, which could have resulted in spurious failures.
This commit, if merged, fixes #2861.
This commit is contained in:
Gregory Tsipenyuk
2020-01-28 09:22:04 -05:00
committed by manojsdoshi
parent 2d23e7bd18
commit 645c06764b
3 changed files with 21 additions and 11 deletions

View File

@@ -554,14 +554,9 @@ OverlayImpl::onPrepare()
for (auto const& addr : addresses)
{
if (addr.port() == 0)
{
Throw<std::runtime_error>(
"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: ");
@@ -577,8 +572,19 @@ OverlayImpl::onPrepare()
[this](
std::string const& name,
std::vector<beast::IP::Endpoint> const& addresses) {
if (!addresses.empty())
m_peerFinder->addFixedPeer(name, addresses);
std::vector<beast::IP::Endpoint> 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);
});
}
}

View File

@@ -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

View File

@@ -22,6 +22,7 @@
#include <ripple/net/RPCErr.h>
#include <ripple/overlay/Overlay.h>
#include <ripple/protocol/ErrorCodes.h>
#include <ripple/protocol/SystemParameters.h>
#include <ripple/protocol/jss.h>
#include <ripple/rpc/Context.h>
#include <ripple/rpc/impl/Handler.h>
@@ -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());