mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-23 17:36:37 +02:00
don't create and oublish duplicates
This commit is contained in:
parent
3683ec6a95
commit
6ff64352d3
1 changed files with 25 additions and 8 deletions
|
@ -479,7 +479,19 @@ namespace transport
|
||||||
{
|
{
|
||||||
if (router && address)
|
if (router && address)
|
||||||
{
|
{
|
||||||
// check is no peding session
|
// check if no session
|
||||||
|
auto it = m_SessionsByRouterHash.find (router->GetIdentHash ());
|
||||||
|
if (it != m_SessionsByRouterHash.end ())
|
||||||
|
{
|
||||||
|
// session with router found, trying to send peer test if requested
|
||||||
|
if (peerTest && it->second->IsEstablished ())
|
||||||
|
{
|
||||||
|
auto session = it->second;
|
||||||
|
GetService ().post ([session]() { session->SendPeerTest (); });
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// check is no pending session
|
||||||
bool isValidEndpoint = !address->host.is_unspecified () && address->port;
|
bool isValidEndpoint = !address->host.is_unspecified () && address->port;
|
||||||
if (isValidEndpoint)
|
if (isValidEndpoint)
|
||||||
{
|
{
|
||||||
|
@ -769,16 +781,16 @@ namespace transport
|
||||||
std::shared_ptr<SSU2Session> session;
|
std::shared_ptr<SSU2Session> session;
|
||||||
auto it1 = m_SessionsByRouterHash.find (it);
|
auto it1 = m_SessionsByRouterHash.find (it);
|
||||||
if (it1 != m_SessionsByRouterHash.end ())
|
if (it1 != m_SessionsByRouterHash.end ())
|
||||||
|
{
|
||||||
session = it1->second;
|
session = it1->second;
|
||||||
|
excluded.insert (it);
|
||||||
|
}
|
||||||
if (session && session->IsEstablished ())
|
if (session && session->IsEstablished ())
|
||||||
{
|
{
|
||||||
if (ts < session->GetCreationTime () + SSU2_TO_INTRODUCER_SESSION_EXPIRATION)
|
if (ts < session->GetCreationTime () + SSU2_TO_INTRODUCER_SESSION_EXPIRATION)
|
||||||
session->SendKeepAlive ();
|
session->SendKeepAlive ();
|
||||||
if (ts < session->GetCreationTime () + SSU2_TO_INTRODUCER_SESSION_DURATION)
|
if (ts < session->GetCreationTime () + SSU2_TO_INTRODUCER_SESSION_DURATION)
|
||||||
{
|
|
||||||
newList.push_back (it);
|
newList.push_back (it);
|
||||||
excluded.insert (it);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
session = nullptr;
|
session = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -796,11 +808,16 @@ namespace transport
|
||||||
{
|
{
|
||||||
auto it1 = m_SessionsByRouterHash.find (it);
|
auto it1 = m_SessionsByRouterHash.find (it);
|
||||||
if (it1 != m_SessionsByRouterHash.end ())
|
if (it1 != m_SessionsByRouterHash.end ())
|
||||||
it1->second->SetCreationTime (it1->second->GetCreationTime () + SSU2_TO_INTRODUCER_SESSION_DURATION);
|
{
|
||||||
|
auto session = it1->second;
|
||||||
|
if (session->IsEstablished ())
|
||||||
|
{
|
||||||
|
session->SetCreationTime (session->GetCreationTime () + SSU2_TO_INTRODUCER_SESSION_DURATION);
|
||||||
|
if (std::find (newList.begin (), newList.end (), it) == newList.end ())
|
||||||
|
newList.push_back (it);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// try again
|
|
||||||
excluded.clear ();
|
|
||||||
sessions = FindIntroducers (SSU2_MAX_NUM_INTRODUCERS - newList.size (), v4, excluded);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& it : sessions)
|
for (const auto& it : sessions)
|
||||||
|
|
Loading…
Add table
Reference in a new issue