mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 12:24:19 +00: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 ();
|
if (!port) port = SelectRandomPort ();
|
||||||
}
|
}
|
||||||
// NTCP2
|
// NTCP2
|
||||||
if (!foundNTCP2)
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||||
|
if (ntcp2)
|
||||||
{
|
{
|
||||||
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
if (!foundNTCP2)
|
||||||
bool ntcp2Published; i2p::config::GetOption("ntcp2.published", ntcp2Published);
|
|
||||||
if (ntcp2)
|
|
||||||
{
|
{
|
||||||
|
bool ntcp2Published; i2p::config::GetOption("ntcp2.published", ntcp2Published);
|
||||||
if (ntcp2Published)
|
if (ntcp2Published)
|
||||||
{
|
{
|
||||||
std::string ntcp2Host;
|
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);
|
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, boost::asio::ip::address(), 0, i2p::data::RouterInfo::eV6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
m_RouterInfo.RemoveNTCP2Address (false);
|
||||||
// SSU2
|
// SSU2
|
||||||
if (!foundSSU2)
|
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
|
||||||
|
if (ssu2)
|
||||||
{
|
{
|
||||||
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
|
if (!foundSSU2)
|
||||||
if (ssu2)
|
|
||||||
{
|
{
|
||||||
bool ssu2Published; i2p::config::GetOption("ssu2.published", ssu2Published);
|
bool ssu2Published; i2p::config::GetOption("ssu2.published", ssu2Published);
|
||||||
if (ssu2Published)
|
if (ssu2Published)
|
||||||
@ -740,7 +742,10 @@ namespace i2p
|
|||||||
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, i2p::data::RouterInfo::eV6);
|
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, i2p::data::RouterInfo::eV6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_RouterInfo.EnableV6 ();
|
else
|
||||||
|
m_RouterInfo.RemoveSSU2Address (false);
|
||||||
|
if (ntcp2 || ssu2)
|
||||||
|
m_RouterInfo.EnableV6 ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_RouterInfo.DisableV6 ();
|
m_RouterInfo.DisableV6 ();
|
||||||
@ -781,10 +786,10 @@ namespace i2p
|
|||||||
if (!port) port = SelectRandomPort ();
|
if (!port) port = SelectRandomPort ();
|
||||||
}
|
}
|
||||||
// NTCP2
|
// NTCP2
|
||||||
if (!foundNTCP2)
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||||
|
if (ntcp2)
|
||||||
{
|
{
|
||||||
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
if (!foundNTCP2)
|
||||||
if (ntcp2)
|
|
||||||
{
|
{
|
||||||
bool ntcp2Published; i2p::config::GetOption("ntcp2.published", ntcp2Published);
|
bool ntcp2Published; i2p::config::GetOption("ntcp2.published", ntcp2Published);
|
||||||
if (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);
|
m_RouterInfo.AddNTCP2Address (m_NTCP2Keys->staticPublicKey, m_NTCP2Keys->iv, boost::asio::ip::address(), 0, i2p::data::RouterInfo::eV4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
m_RouterInfo.RemoveNTCP2Address (false);
|
||||||
// SSU2
|
// SSU2
|
||||||
if (!foundSSU2)
|
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
|
||||||
|
if (ssu2)
|
||||||
{
|
{
|
||||||
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
|
if (!foundSSU2)
|
||||||
if (ssu2)
|
|
||||||
{
|
{
|
||||||
bool ssu2Published; i2p::config::GetOption("ssu2.published", ssu2Published);
|
bool ssu2Published; i2p::config::GetOption("ssu2.published", ssu2Published);
|
||||||
if (ssu2Published)
|
if (ssu2Published)
|
||||||
@ -814,7 +821,10 @@ namespace i2p
|
|||||||
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, i2p::data::RouterInfo::eV4);
|
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, i2p::data::RouterInfo::eV4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_RouterInfo.EnableV4 ();
|
else
|
||||||
|
m_RouterInfo.RemoveSSU2Address (false);
|
||||||
|
if (ntcp2 || ssu2)
|
||||||
|
m_RouterInfo.EnableV4 ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_RouterInfo.DisableV4 ();
|
m_RouterInfo.DisableV4 ();
|
||||||
|
@ -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)
|
void RouterInfo::AddSSU2Address (const uint8_t * staticKey, const uint8_t * introKey, uint8_t caps)
|
||||||
{
|
{
|
||||||
auto addr = std::make_shared<Address>();
|
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
|
bool RouterInfo::IsNTCP2 (bool v4only) const
|
||||||
{
|
{
|
||||||
if (v4only)
|
if (v4only)
|
||||||
@ -744,14 +778,14 @@ namespace data
|
|||||||
{
|
{
|
||||||
if ((*m_Addresses)[eNTCP2V6Idx])
|
if ((*m_Addresses)[eNTCP2V6Idx])
|
||||||
{
|
{
|
||||||
if ((*m_Addresses)[eNTCP2V6Idx]->IsV4 ())
|
if ((*m_Addresses)[eNTCP2V6Idx]->IsV4 () && (*m_Addresses)[eNTCP2V4Idx])
|
||||||
(*m_Addresses)[eNTCP2V6Idx]->caps &= ~AddressCaps::eV6;
|
(*m_Addresses)[eNTCP2V4Idx]->caps &= ~AddressCaps::eV6;
|
||||||
(*m_Addresses)[eNTCP2V6Idx].reset ();
|
(*m_Addresses)[eNTCP2V6Idx].reset ();
|
||||||
}
|
}
|
||||||
if ((*m_Addresses)[eSSU2V6Idx])
|
if ((*m_Addresses)[eSSU2V6Idx])
|
||||||
{
|
{
|
||||||
if ((*m_Addresses)[eSSU2V6Idx]->IsV4 ())
|
if ((*m_Addresses)[eSSU2V6Idx]->IsV4 () && (*m_Addresses)[eSSU2V4Idx])
|
||||||
(*m_Addresses)[eSSU2V6Idx]->caps &= ~AddressCaps::eV6;
|
(*m_Addresses)[eSSU2V4Idx]->caps &= ~AddressCaps::eV6;
|
||||||
(*m_Addresses)[eSSU2V6Idx].reset ();
|
(*m_Addresses)[eSSU2V6Idx].reset ();
|
||||||
}
|
}
|
||||||
UpdateSupportedTransports ();
|
UpdateSupportedTransports ();
|
||||||
@ -764,14 +798,14 @@ namespace data
|
|||||||
{
|
{
|
||||||
if ((*m_Addresses)[eNTCP2V4Idx])
|
if ((*m_Addresses)[eNTCP2V4Idx])
|
||||||
{
|
{
|
||||||
if ((*m_Addresses)[eNTCP2V4Idx]->IsV6 ())
|
if ((*m_Addresses)[eNTCP2V4Idx]->IsV6 () && (*m_Addresses)[eNTCP2V6Idx])
|
||||||
(*m_Addresses)[eNTCP2V4Idx]->caps &= ~AddressCaps::eV4;
|
(*m_Addresses)[eNTCP2V6Idx]->caps &= ~AddressCaps::eV4;
|
||||||
(*m_Addresses)[eNTCP2V4Idx].reset ();
|
(*m_Addresses)[eNTCP2V4Idx].reset ();
|
||||||
}
|
}
|
||||||
if ((*m_Addresses)[eSSU2V4Idx])
|
if ((*m_Addresses)[eSSU2V4Idx])
|
||||||
{
|
{
|
||||||
if ((*m_Addresses)[eSSU2V4Idx]->IsV6 ())
|
if ((*m_Addresses)[eSSU2V4Idx]->IsV6 () && (*m_Addresses)[eSSU2V6Idx])
|
||||||
(*m_Addresses)[eSSU2V4Idx]->caps &= ~AddressCaps::eV4;
|
(*m_Addresses)[eSSU2V6Idx]->caps &= ~AddressCaps::eV4;
|
||||||
(*m_Addresses)[eSSU2V4Idx].reset ();
|
(*m_Addresses)[eSSU2V4Idx].reset ();
|
||||||
}
|
}
|
||||||
UpdateSupportedTransports ();
|
UpdateSupportedTransports ();
|
||||||
|
@ -200,9 +200,11 @@ namespace data
|
|||||||
|
|
||||||
void AddNTCP2Address (const uint8_t * staticKey, const uint8_t * iv,
|
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);
|
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, uint8_t caps = 0); // non published
|
||||||
void AddSSU2Address (const uint8_t * staticKey, const uint8_t * introKey,
|
void AddSSU2Address (const uint8_t * staticKey, const uint8_t * introKey,
|
||||||
const boost::asio::ip::address& host, int port); // published
|
const boost::asio::ip::address& host, int port); // published
|
||||||
|
void RemoveSSU2Address (bool v4);
|
||||||
void SetUnreachableAddressesTransportCaps (uint8_t transports); // bitmask of AddressCaps
|
void SetUnreachableAddressesTransportCaps (uint8_t transports); // bitmask of AddressCaps
|
||||||
void UpdateSupportedTransports ();
|
void UpdateSupportedTransports ();
|
||||||
bool IsFloodfill () const { return m_Caps & Caps::eFloodfill; };
|
bool IsFloodfill () const { return m_Caps & Caps::eFloodfill; };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user