mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
check if session is established before sending peer test
This commit is contained in:
parent
87a434c377
commit
d3a9cc8fde
|
@ -1590,7 +1590,7 @@ namespace transport
|
||||||
size_t SSU2Session::CreatePeerTestBlock (uint8_t * buf, size_t len)
|
size_t SSU2Session::CreatePeerTestBlock (uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
auto localAddress = FindLocalAddress ();
|
auto localAddress = FindLocalAddress ();
|
||||||
if (localAddress) return 0;
|
if (!localAddress) return 0;
|
||||||
// signed data
|
// signed data
|
||||||
uint32_t nonce;
|
uint32_t nonce;
|
||||||
RAND_bytes ((uint8_t *)&nonce, 4);
|
RAND_bytes ((uint8_t *)&nonce, 4);
|
||||||
|
@ -2150,14 +2150,17 @@ namespace transport
|
||||||
auto it = m_SessionsByRouterHash.find (router->GetIdentHash ());
|
auto it = m_SessionsByRouterHash.find (router->GetIdentHash ());
|
||||||
if (it != m_SessionsByRouterHash.end ())
|
if (it != m_SessionsByRouterHash.end ())
|
||||||
{
|
{
|
||||||
it->second->SendPeerTest ();
|
if (it->second->IsEstablished ())
|
||||||
return true;
|
it->second->SendPeerTest ();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto s = it->second;
|
||||||
|
s->SetOnEstablished ([s]() { s->SendPeerTest (); });
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
auto s = std::make_shared<SSU2Session> (*this, router, addr);
|
auto s = std::make_shared<SSU2Session> (*this, router, addr);
|
||||||
s->SetOnEstablished ([s]()
|
s->SetOnEstablished ([s]() {s->SendPeerTest (); });
|
||||||
{
|
|
||||||
s->SendPeerTest ();
|
|
||||||
});
|
|
||||||
s->Connect ();
|
s->Connect ();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue