|
|
|
@ -300,7 +300,7 @@ namespace i2p
|
|
|
|
|
if (updated)
|
|
|
|
|
UpdateRouterInfo ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void RouterContext::UpdateNTCP2Address (bool enable)
|
|
|
|
|
{
|
|
|
|
|
auto& addresses = m_RouterInfo.GetAddresses ();
|
|
|
|
@ -327,6 +327,24 @@ namespace i2p
|
|
|
|
|
UpdateRouterInfo ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RouterContext::PublishSSU2Address (int port, bool publish, bool v4, bool v6)
|
|
|
|
|
{
|
|
|
|
|
if (!m_SSU2Keys || (publish && !port)) return;
|
|
|
|
|
bool updated = false;
|
|
|
|
|
for (auto& address : m_RouterInfo.GetAddresses ())
|
|
|
|
|
{
|
|
|
|
|
if (address->IsSSU2 () && (address->port != port || address->published != publish) &&
|
|
|
|
|
((v4 && address->IsV4 ()) || (v6 && address->IsV6 ())))
|
|
|
|
|
{
|
|
|
|
|
address->port = port;
|
|
|
|
|
address->published = publish;
|
|
|
|
|
updated = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (updated)
|
|
|
|
|
UpdateRouterInfo ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RouterContext::UpdateSSU2Address (bool enable)
|
|
|
|
|
{
|
|
|
|
|
auto& addresses = m_RouterInfo.GetAddresses ();
|
|
|
|
@ -594,17 +612,26 @@ namespace i2p
|
|
|
|
|
if (supportsV6)
|
|
|
|
|
{
|
|
|
|
|
// insert v6 addresses if necessary
|
|
|
|
|
bool foundSSU = false, foundNTCP2 = false;
|
|
|
|
|
bool foundSSU = false, foundNTCP2 = false, foundSSU2 = false;
|
|
|
|
|
uint16_t port = 0;
|
|
|
|
|
auto& addresses = m_RouterInfo.GetAddresses ();
|
|
|
|
|
for (auto& addr: addresses)
|
|
|
|
|
{
|
|
|
|
|
if (addr->IsV6 () && !i2p::util::net::IsYggdrasilAddress (addr->host))
|
|
|
|
|
{
|
|
|
|
|
if (addr->transportStyle == i2p::data::RouterInfo::eTransportSSU)
|
|
|
|
|
foundSSU = true;
|
|
|
|
|
else if (addr->transportStyle == i2p::data::RouterInfo::eTransportNTCP)
|
|
|
|
|
foundNTCP2 = true;
|
|
|
|
|
switch (addr->transportStyle)
|
|
|
|
|
{
|
|
|
|
|
case i2p::data::RouterInfo::eTransportSSU:
|
|
|
|
|
foundSSU = true;
|
|
|
|
|
break;
|
|
|
|
|
case i2p::data::RouterInfo::eTransportNTCP:
|
|
|
|
|
foundNTCP2 = true;
|
|
|
|
|
break;
|
|
|
|
|
case i2p::data::RouterInfo::eTransportSSU2:
|
|
|
|
|
foundSSU2 = true;
|
|
|
|
|
break;
|
|
|
|
|
default: ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
port = addr->port;
|
|
|
|
|
}
|
|
|
|
@ -641,6 +668,19 @@ namespace i2p
|
|
|
|
|
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, boost::asio::ip::address(), 0, i2p::data::RouterInfo::eV6);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// SSU2
|
|
|
|
|
if (!foundSSU2)
|
|
|
|
|
{
|
|
|
|
|
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
|
|
|
|
|
bool ssu2Published; i2p::config::GetOption("ssu2.published", ssu2Published);
|
|
|
|
|
if (ssu2Published)
|
|
|
|
|
{
|
|
|
|
|
uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
|
|
|
|
|
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, boost::asio::ip::address::from_string ("::1"), ssu2Port);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, i2p::data::RouterInfo::eV6);
|
|
|
|
|
}
|
|
|
|
|
m_RouterInfo.EnableV6 ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|