mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
try to create new sessions with introducers if existing are about to expire
This commit is contained in:
parent
7f3a04a72f
commit
bce9630ff8
|
@ -1284,6 +1284,7 @@ namespace transport
|
||||||
if (!session)
|
if (!session)
|
||||||
i2p::context.RemoveSSU2Introducer (ident, v4);
|
i2p::context.RemoveSSU2Introducer (ident, v4);
|
||||||
}
|
}
|
||||||
|
int numOldSessions = 0;
|
||||||
if (newList.size () < SSU2_MAX_NUM_INTRODUCERS)
|
if (newList.size () < SSU2_MAX_NUM_INTRODUCERS)
|
||||||
{
|
{
|
||||||
auto sessions = FindIntroducers (SSU2_MAX_NUM_INTRODUCERS - newList.size (), v4, excluded);
|
auto sessions = FindIntroducers (SSU2_MAX_NUM_INTRODUCERS - newList.size (), v4, excluded);
|
||||||
|
@ -1297,7 +1298,10 @@ namespace transport
|
||||||
{
|
{
|
||||||
if (std::find_if (newList.begin (), newList.end (),
|
if (std::find_if (newList.begin (), newList.end (),
|
||||||
[&ident = it.first](const auto& s){ return ident == s.first; }) == newList.end ())
|
[&ident = it.first](const auto& s){ return ident == s.first; }) == newList.end ())
|
||||||
|
{
|
||||||
sessions.push_back (session);
|
sessions.push_back (session);
|
||||||
|
numOldSessions++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impliedList.clear ();
|
impliedList.clear ();
|
||||||
|
@ -1326,9 +1330,17 @@ namespace transport
|
||||||
}
|
}
|
||||||
introducers = newList;
|
introducers = newList;
|
||||||
|
|
||||||
if (introducers.size () < SSU2_MAX_NUM_INTRODUCERS)
|
if (introducers.size () < SSU2_MAX_NUM_INTRODUCERS || numOldSessions)
|
||||||
{
|
{
|
||||||
for (auto i = introducers.size (); i < SSU2_MAX_NUM_INTRODUCERS; i++)
|
// we need to create more sessions with relay tag
|
||||||
|
|
||||||
|
// exclude all existing sessions
|
||||||
|
excluded.clear ();
|
||||||
|
for (const auto& [ident, s] : m_SessionsByRouterHash)
|
||||||
|
excluded.insert (ident);
|
||||||
|
|
||||||
|
// sesssion about to expire are not counted
|
||||||
|
for (auto i = introducers.size (); i < SSU2_MAX_NUM_INTRODUCERS + numOldSessions; i++)
|
||||||
{
|
{
|
||||||
auto introducer = i2p::data::netdb.GetRandomSSU2Introducer (v4, excluded);
|
auto introducer = i2p::data::netdb.GetRandomSSU2Introducer (v4, excluded);
|
||||||
if (introducer)
|
if (introducer)
|
||||||
|
|
Loading…
Reference in a new issue