1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-22 08:14:15 +00:00

cleanup introducers if router is not longer firewalled

This commit is contained in:
orignal 2022-08-05 21:23:23 -04:00
parent 3e40852999
commit f43e860998
3 changed files with 18 additions and 0 deletions

View File

@ -481,6 +481,21 @@ namespace i2p
UpdateRouterInfo (); UpdateRouterInfo ();
} }
void RouterContext::ClearSSU2Introducers (bool v4)
{
bool updated = false;
auto& addresses = m_RouterInfo.GetAddresses ();
for (auto& addr : addresses)
if (addr->IsSSU2 () && ((v4 && addr->IsV4 ()) || (!v4 && addr->IsV6 ())) &&
addr->ssu && !addr->ssu->introducers.empty ())
{
addr->ssu->introducers.clear ();
updated = true;
}
if (updated)
UpdateRouterInfo ();
}
void RouterContext::SetFloodfill (bool floodfill) void RouterContext::SetFloodfill (bool floodfill)
{ {
m_IsFloodfill = floodfill; m_IsFloodfill = floodfill;

View File

@ -127,6 +127,7 @@ namespace garlic
void RemoveIntroducer (const boost::asio::ip::udp::endpoint& e); void RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
bool AddSSU2Introducer (const i2p::data::RouterInfo::Introducer& introducer, bool v4); bool AddSSU2Introducer (const i2p::data::RouterInfo::Introducer& introducer, bool v4);
void RemoveSSU2Introducer (const i2p::data::IdentHash& h, bool v4); void RemoveSSU2Introducer (const i2p::data::IdentHash& h, bool v4);
void ClearSSU2Introducers (bool v4);
bool IsUnreachable () const; bool IsUnreachable () const;
void SetUnreachable (bool v4, bool v6); void SetUnreachable (bool v4, bool v6);
void SetUnreachableSSU2 (bool v4, bool v6); void SetUnreachableSSU2 (bool v4, bool v6);

View File

@ -981,6 +981,7 @@ namespace transport
if (i2p::context.GetStatus () != eRouterStatusFirewalled) if (i2p::context.GetStatus () != eRouterStatusFirewalled)
{ {
// we don't need introducers // we don't need introducers
i2p::context.ClearSSU2Introducers (true);
m_Introducers.clear (); m_Introducers.clear ();
return; return;
} }
@ -1003,6 +1004,7 @@ namespace transport
if (i2p::context.GetStatusV6 () != eRouterStatusFirewalled) if (i2p::context.GetStatusV6 () != eRouterStatusFirewalled)
{ {
// we don't need introducers // we don't need introducers
i2p::context.ClearSSU2Introducers (false);
m_IntroducersV6.clear (); m_IntroducersV6.clear ();
return; return;
} }