mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
publish NTCP2 ipv6 address if applicable
This commit is contained in:
parent
ff8fb8000d
commit
8753186a0d
@ -1179,6 +1179,8 @@ namespace transport
|
||||
else
|
||||
{
|
||||
LogPrint (eLogDebug, "NTCP2: Connected to ", conn->GetSocket ().remote_endpoint ());
|
||||
if (conn->GetSocket ().local_endpoint ().protocol () == boost::asio::ip::tcp::v6()) // ipv6
|
||||
context.UpdateNTCP2V6Address (conn->GetSocket ().local_endpoint ().address ());
|
||||
conn->ClientLogin ();
|
||||
}
|
||||
}
|
||||
|
@ -453,6 +453,41 @@ namespace i2p
|
||||
UpdateRouterInfo ();
|
||||
}
|
||||
|
||||
void RouterContext::UpdateNTCP2V6Address (const boost::asio::ip::address& host)
|
||||
{
|
||||
bool updated = false;
|
||||
int port = 0;
|
||||
auto& addresses = m_RouterInfo.GetAddresses ();
|
||||
for (auto& addr: addresses)
|
||||
{
|
||||
if (addr->IsPublishedNTCP2 ())
|
||||
{
|
||||
if (addr->host.is_v6 ())
|
||||
{
|
||||
if (addr->host != host)
|
||||
{
|
||||
addr->host = host;
|
||||
updated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
port = addr->port; // NTCP2 v4
|
||||
}
|
||||
}
|
||||
|
||||
if (!updated)
|
||||
{
|
||||
if (port) // we have found NTCP2 v4 but not v6
|
||||
{
|
||||
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv);
|
||||
PublishNTCP2Address (port, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
UpdateRouterInfo ();
|
||||
}
|
||||
|
||||
void RouterContext::UpdateStats ()
|
||||
{
|
||||
if (m_IsFloodfill)
|
||||
|
@ -100,6 +100,7 @@ namespace i2p
|
||||
void SetSupportsV4 (bool supportsV4);
|
||||
|
||||
void UpdateNTCPV6Address (const boost::asio::ip::address& host); // called from NTCP session
|
||||
void UpdateNTCP2V6Address (const boost::asio::ip::address& host); // called from NTCP2 session
|
||||
void UpdateStats ();
|
||||
void CleanupDestination (); // garlic destination
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user