Browse Source

cleanup introducers if router is not longer firewalled

pull/1786/head
orignal 2 years ago
parent
commit
f43e860998
  1. 15
      libi2pd/RouterContext.cpp
  2. 1
      libi2pd/RouterContext.h
  3. 2
      libi2pd/SSU2.cpp

15
libi2pd/RouterContext.cpp

@ -481,6 +481,21 @@ namespace i2p @@ -481,6 +481,21 @@ namespace i2p
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)
{
m_IsFloodfill = floodfill;

1
libi2pd/RouterContext.h

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

2
libi2pd/SSU2.cpp

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

Loading…
Cancel
Save