mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
delete address if corresponding transport is disabled
This commit is contained in:
parent
8ee461f60a
commit
e91d0bbec8
@ -702,12 +702,12 @@ namespace i2p
|
||||
if (!port) port = SelectRandomPort ();
|
||||
}
|
||||
// NTCP2
|
||||
if (!foundNTCP2)
|
||||
{
|
||||
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||
bool ntcp2Published; i2p::config::GetOption("ntcp2.published", ntcp2Published);
|
||||
if (ntcp2)
|
||||
{
|
||||
if (!foundNTCP2)
|
||||
{
|
||||
bool ntcp2Published; i2p::config::GetOption("ntcp2.published", ntcp2Published);
|
||||
if (ntcp2Published)
|
||||
{
|
||||
std::string ntcp2Host;
|
||||
@ -723,11 +723,13 @@ namespace i2p
|
||||
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, boost::asio::ip::address(), 0, i2p::data::RouterInfo::eV6);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_RouterInfo.RemoveNTCP2Address (false);
|
||||
// SSU2
|
||||
if (!foundSSU2)
|
||||
{
|
||||
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
|
||||
if (ssu2)
|
||||
{
|
||||
if (!foundSSU2)
|
||||
{
|
||||
bool ssu2Published; i2p::config::GetOption("ssu2.published", ssu2Published);
|
||||
if (ssu2Published)
|
||||
@ -740,6 +742,9 @@ namespace i2p
|
||||
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, i2p::data::RouterInfo::eV6);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_RouterInfo.RemoveSSU2Address (false);
|
||||
if (ntcp2 || ssu2)
|
||||
m_RouterInfo.EnableV6 ();
|
||||
}
|
||||
else
|
||||
@ -781,10 +786,10 @@ namespace i2p
|
||||
if (!port) port = SelectRandomPort ();
|
||||
}
|
||||
// NTCP2
|
||||
if (!foundNTCP2)
|
||||
{
|
||||
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||
if (ntcp2)
|
||||
{
|
||||
if (!foundNTCP2)
|
||||
{
|
||||
bool ntcp2Published; i2p::config::GetOption("ntcp2.published", ntcp2Published);
|
||||
if (ntcp2Published)
|
||||
@ -797,11 +802,13 @@ namespace i2p
|
||||
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, boost::asio::ip::address(), 0, i2p::data::RouterInfo::eV4);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_RouterInfo.RemoveNTCP2Address (false);
|
||||
// SSU2
|
||||
if (!foundSSU2)
|
||||
{
|
||||
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
|
||||
if (ssu2)
|
||||
{
|
||||
if (!foundSSU2)
|
||||
{
|
||||
bool ssu2Published; i2p::config::GetOption("ssu2.published", ssu2Published);
|
||||
if (ssu2Published)
|
||||
@ -814,6 +821,9 @@ namespace i2p
|
||||
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, i2p::data::RouterInfo::eV4);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_RouterInfo.RemoveSSU2Address (false);
|
||||
if (ntcp2 || ssu2)
|
||||
m_RouterInfo.EnableV4 ();
|
||||
}
|
||||
else
|
||||
|
@ -655,6 +655,23 @@ namespace data
|
||||
}
|
||||
}
|
||||
|
||||
void RouterInfo::RemoveNTCP2Address (bool v4)
|
||||
{
|
||||
if (v4)
|
||||
{
|
||||
if ((*m_Addresses)[eNTCP2V6Idx])
|
||||
(*m_Addresses)[eNTCP2V6Idx]->caps &= ~AddressCaps::eV4;
|
||||
(*m_Addresses)[eNTCP2V4Idx].reset ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((*m_Addresses)[eNTCP2V4Idx])
|
||||
(*m_Addresses)[eNTCP2V4Idx]->caps &= ~AddressCaps::eV6;
|
||||
(*m_Addresses)[eNTCP2V6Idx].reset ();
|
||||
}
|
||||
UpdateSupportedTransports ();
|
||||
}
|
||||
|
||||
void RouterInfo::AddSSU2Address (const uint8_t * staticKey, const uint8_t * introKey, uint8_t caps)
|
||||
{
|
||||
auto addr = std::make_shared<Address>();
|
||||
@ -706,6 +723,23 @@ namespace data
|
||||
}
|
||||
}
|
||||
|
||||
void RouterInfo::RemoveSSU2Address (bool v4)
|
||||
{
|
||||
if (v4)
|
||||
{
|
||||
if ((*m_Addresses)[eSSU2V6Idx])
|
||||
(*m_Addresses)[eSSU2V6Idx]->caps &= ~AddressCaps::eV4;
|
||||
(*m_Addresses)[eSSU2V4Idx].reset ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((*m_Addresses)[eSSU2V4Idx])
|
||||
(*m_Addresses)[eSSU2V4Idx]->caps &= ~AddressCaps::eV6;
|
||||
(*m_Addresses)[eSSU2V6Idx].reset ();
|
||||
}
|
||||
UpdateSupportedTransports ();
|
||||
}
|
||||
|
||||
bool RouterInfo::IsNTCP2 (bool v4only) const
|
||||
{
|
||||
if (v4only)
|
||||
@ -744,14 +778,14 @@ namespace data
|
||||
{
|
||||
if ((*m_Addresses)[eNTCP2V6Idx])
|
||||
{
|
||||
if ((*m_Addresses)[eNTCP2V6Idx]->IsV4 ())
|
||||
(*m_Addresses)[eNTCP2V6Idx]->caps &= ~AddressCaps::eV6;
|
||||
if ((*m_Addresses)[eNTCP2V6Idx]->IsV4 () && (*m_Addresses)[eNTCP2V4Idx])
|
||||
(*m_Addresses)[eNTCP2V4Idx]->caps &= ~AddressCaps::eV6;
|
||||
(*m_Addresses)[eNTCP2V6Idx].reset ();
|
||||
}
|
||||
if ((*m_Addresses)[eSSU2V6Idx])
|
||||
{
|
||||
if ((*m_Addresses)[eSSU2V6Idx]->IsV4 ())
|
||||
(*m_Addresses)[eSSU2V6Idx]->caps &= ~AddressCaps::eV6;
|
||||
if ((*m_Addresses)[eSSU2V6Idx]->IsV4 () && (*m_Addresses)[eSSU2V4Idx])
|
||||
(*m_Addresses)[eSSU2V4Idx]->caps &= ~AddressCaps::eV6;
|
||||
(*m_Addresses)[eSSU2V6Idx].reset ();
|
||||
}
|
||||
UpdateSupportedTransports ();
|
||||
@ -764,14 +798,14 @@ namespace data
|
||||
{
|
||||
if ((*m_Addresses)[eNTCP2V4Idx])
|
||||
{
|
||||
if ((*m_Addresses)[eNTCP2V4Idx]->IsV6 ())
|
||||
(*m_Addresses)[eNTCP2V4Idx]->caps &= ~AddressCaps::eV4;
|
||||
if ((*m_Addresses)[eNTCP2V4Idx]->IsV6 () && (*m_Addresses)[eNTCP2V6Idx])
|
||||
(*m_Addresses)[eNTCP2V6Idx]->caps &= ~AddressCaps::eV4;
|
||||
(*m_Addresses)[eNTCP2V4Idx].reset ();
|
||||
}
|
||||
if ((*m_Addresses)[eSSU2V4Idx])
|
||||
{
|
||||
if ((*m_Addresses)[eSSU2V4Idx]->IsV6 ())
|
||||
(*m_Addresses)[eSSU2V4Idx]->caps &= ~AddressCaps::eV4;
|
||||
if ((*m_Addresses)[eSSU2V4Idx]->IsV6 () && (*m_Addresses)[eSSU2V6Idx])
|
||||
(*m_Addresses)[eSSU2V6Idx]->caps &= ~AddressCaps::eV4;
|
||||
(*m_Addresses)[eSSU2V4Idx].reset ();
|
||||
}
|
||||
UpdateSupportedTransports ();
|
||||
|
@ -200,9 +200,11 @@ namespace data
|
||||
|
||||
void AddNTCP2Address (const uint8_t * staticKey, const uint8_t * iv,
|
||||
const boost::asio::ip::address& host = boost::asio::ip::address(), int port = 0, uint8_t caps = 0);
|
||||
void RemoveNTCP2Address (bool v4);
|
||||
void AddSSU2Address (const uint8_t * staticKey, const uint8_t * introKey, uint8_t caps = 0); // non published
|
||||
void AddSSU2Address (const uint8_t * staticKey, const uint8_t * introKey,
|
||||
const boost::asio::ip::address& host, int port); // published
|
||||
void RemoveSSU2Address (bool v4);
|
||||
void SetUnreachableAddressesTransportCaps (uint8_t transports); // bitmask of AddressCaps
|
||||
void UpdateSupportedTransports ();
|
||||
bool IsFloodfill () const { return m_Caps & Caps::eFloodfill; };
|
||||
|
Loading…
Reference in New Issue
Block a user