Browse Source

check if NTCP2 address is valid before connection attempt

pull/1626/head
orignal 4 years ago
parent
commit
2e0019c8c8
  1. 12
      libi2pd/Transports.cpp

12
libi2pd/Transports.cpp

@ -397,16 +397,24 @@ namespace transport
if (!peer.numAttempts) // NTCP2 ipv6 if (!peer.numAttempts) // NTCP2 ipv6
{ {
if (context.SupportsV6 ()) if (context.SupportsV6 ())
{
address = peer.router->GetPublishedNTCP2V6Address (); address = peer.router->GetPublishedNTCP2V6Address ();
if (address && m_CheckReserved && !i2p::util::net::IsInReservedRange(address->host))
address = nullptr;
}
peer.numAttempts++; peer.numAttempts++;
} }
if (!address && peer.numAttempts == 1) // NTCP2 ipv4 if (!address && peer.numAttempts == 1) // NTCP2 ipv4
{ {
if (context.SupportsV4 ()) if (context.SupportsV4 () && !peer.router->IsUnreachable ())
{
address = peer.router->GetPublishedNTCP2V4Address (); address = peer.router->GetPublishedNTCP2V4Address ();
if (address && m_CheckReserved && !i2p::util::net::IsInReservedRange(address->host))
address = nullptr;
}
peer.numAttempts++; peer.numAttempts++;
} }
if (address && !peer.router->IsUnreachable () && (!m_CheckReserved || !i2p::util::net::IsInReservedRange(address->host))) if (address)
{ {
auto s = std::make_shared<NTCP2Session> (*m_NTCP2Server, peer.router, address); auto s = std::make_shared<NTCP2Session> (*m_NTCP2Server, peer.router, address);

Loading…
Cancel
Save