NTCP2 transports through the Yggdrasil

This commit is contained in:
orignal 2021-01-31 17:25:07 -05:00
parent 9e5935aea5
commit aad2d68edb
7 changed files with 72 additions and 2 deletions

View file

@ -442,13 +442,27 @@ namespace transport
if (m_SSUServer && peer.router->IsSSU (!context.SupportsV6 ()))
{
auto address = peer.router->GetSSUAddress (!context.SupportsV6 ());
if (!m_CheckReserved || !i2p::util::net::IsInReservedRange(address->host))
if (address && (!m_CheckReserved || !i2p::util::net::IsInReservedRange(address->host)))
{
m_SSUServer->CreateSession (peer.router, address->host, address->port);
return true;
}
}
}
if (peer.numAttempts == 3) // Mesh
{
peer.numAttempts++;
if (context.SupportsMesh () && m_NTCP2Server)
{
auto address = peer.router->GetYggdrasilAddress ();
if (address)
{
auto s = std::make_shared<NTCP2Session> (*m_NTCP2Server, peer.router, address);
m_NTCP2Server->Connect (address->host, address->port, s);
return true;
}
}
}
LogPrint (eLogInfo, "Transports: No NTCP or SSU addresses available");
i2p::data::netdb.SetUnreachable (ident, true); // we are here because all connection attempts failed
peer.Done ();