mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Remove legacy support for endpoint dissemination:
Support for IPv6 messages was added with commit 08382d866b
and version 1.1.0. No peer presently connected to the network in a useful capacity fails
to understand v2 messages.
This commit removes the code that generates and processes v1 messages and deletes legacy
messages from the protocol buffer definition file.
This commit is contained in:
@@ -1371,84 +1371,34 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMPeerShardInfo> const& m)
|
||||
void
|
||||
PeerImp::onMessage(std::shared_ptr<protocol::TMEndpoints> const& m)
|
||||
{
|
||||
if (sanity_.load() != Sanity::sane)
|
||||
{
|
||||
// Don't allow endpoints from peer not known sane
|
||||
// Don't allow endpoints from peers that are not known sane or are
|
||||
// not using a version of the message that we support:
|
||||
if (sanity_.load() != Sanity::sane || m->version() != 2)
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<PeerFinder::Endpoint> endpoints;
|
||||
endpoints.reserve(m->endpoints_v2().size());
|
||||
|
||||
if (m->endpoints_v2().size())
|
||||
for (auto const& tm : m->endpoints_v2())
|
||||
{
|
||||
endpoints.reserve(m->endpoints_v2().size());
|
||||
for (auto const& tm : m->endpoints_v2())
|
||||
auto result = beast::IP::Endpoint::from_string_checked(tm.endpoint());
|
||||
if (!result)
|
||||
{
|
||||
// these endpoint strings support ipv4 and ipv6
|
||||
auto result =
|
||||
beast::IP::Endpoint::from_string_checked(tm.endpoint());
|
||||
if (!result)
|
||||
{
|
||||
JLOG(p_journal_.error())
|
||||
<< "failed to parse incoming endpoint: {" << tm.endpoint()
|
||||
<< "}";
|
||||
continue;
|
||||
}
|
||||
|
||||
// If hops == 0, this Endpoint describes the peer we are connected
|
||||
// to -- in that case, we take the remote address seen on the
|
||||
// socket and store that in the IP::Endpoint. If this is the first
|
||||
// time, then we'll verify that their listener can receive incoming
|
||||
// by performing a connectivity test. if hops > 0, then we just
|
||||
// take the address/port we were given
|
||||
|
||||
endpoints.emplace_back(
|
||||
tm.hops() > 0 ? *result
|
||||
: remote_address_.at_port(result->port()),
|
||||
tm.hops());
|
||||
JLOG(p_journal_.trace())
|
||||
<< "got v2 EP: " << endpoints.back().address
|
||||
<< ", hops = " << endpoints.back().hops;
|
||||
JLOG(p_journal_.error()) << "failed to parse incoming endpoint: {"
|
||||
<< tm.endpoint() << "}";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// this branch can be removed once the entire network is operating with
|
||||
// endpoint_v2() items (strings)
|
||||
endpoints.reserve(m->endpoints().size());
|
||||
for (int i = 0; i < m->endpoints().size(); ++i)
|
||||
{
|
||||
PeerFinder::Endpoint endpoint;
|
||||
protocol::TMEndpoint const& tm(m->endpoints(i));
|
||||
|
||||
// hops
|
||||
endpoint.hops = tm.hops();
|
||||
// If hops == 0, this Endpoint describes the peer we are connected
|
||||
// to -- in that case, we take the remote address seen on the
|
||||
// socket and store that in the IP::Endpoint. If this is the first
|
||||
// time, then we'll verify that their listener can receive incoming
|
||||
// by performing a connectivity test. if hops > 0, then we just
|
||||
// take the address/port we were given
|
||||
|
||||
// ipv4
|
||||
if (endpoint.hops > 0)
|
||||
{
|
||||
in_addr addr;
|
||||
addr.s_addr = tm.ipv4().ipv4();
|
||||
beast::IP::AddressV4 v4(ntohl(addr.s_addr));
|
||||
endpoint.address =
|
||||
beast::IP::Endpoint(v4, tm.ipv4().ipv4port());
|
||||
}
|
||||
else
|
||||
{
|
||||
// This Endpoint describes the peer we are connected to.
|
||||
// We will take the remote address seen on the socket and
|
||||
// store that in the IP::Endpoint. If this is the first time,
|
||||
// then we'll verify that their listener can receive incoming
|
||||
// by performing a connectivity test.
|
||||
//
|
||||
endpoint.address =
|
||||
remote_address_.at_port(tm.ipv4().ipv4port());
|
||||
}
|
||||
endpoints.push_back(endpoint);
|
||||
JLOG(p_journal_.trace())
|
||||
<< "got v1 EP: " << endpoints.back().address
|
||||
<< ", hops = " << endpoints.back().hops;
|
||||
}
|
||||
endpoints.emplace_back(
|
||||
tm.hops() > 0 ? *result : remote_address_.at_port(result->port()),
|
||||
tm.hops());
|
||||
}
|
||||
|
||||
if (!endpoints.empty())
|
||||
|
||||
Reference in New Issue
Block a user