Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append default port (51235) in [ips] and [ips_fixed] when no port is specified #3235

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/ripple/overlay/impl/OverlayImpl.cpp
Original file line number Diff line number Diff line change
@@ -577,14 +577,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: ");
@@ -600,8 +595,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);
});
}
}
3 changes: 3 additions & 0 deletions src/ripple/protocol/SystemParameters.h
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion src/ripple/rpc/handlers/Connect.cpp
Original file line number Diff line number Diff line change
@@ -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;
gregtatcam marked this conversation as resolved.
Show resolved Hide resolved

auto ip =
beast::IP::Endpoint::from_string(context.params[jss::ip].asString());