recreate session after 90 seconds incativity

This commit is contained in:
orignal 2020-05-23 15:58:11 -04:00
parent 45aa78d953
commit 5a32082624
3 changed files with 16 additions and 3 deletions

View file

@ -719,7 +719,14 @@ namespace garlic
destination->Encrypt (nullptr, staticKey, nullptr); // we are supposed to get static key
auto it = m_ECIESx25519Sessions.find (staticKey);
if (it != m_ECIESx25519Sessions.end ())
{
session = it->second;
if (session->IsInactive (i2p::util::GetSecondsSinceEpoch ()))
{
LogPrint (eLogDebug, "Garlic: session restarted");
session = nullptr;
}
}
if (!session)
{
session = std::make_shared<ECIESX25519AEADRatchetSession> (this, true);
@ -1011,7 +1018,10 @@ namespace garlic
if (it != m_ECIESx25519Sessions.end ())
{
if (it->second->CanBeRestarted (i2p::util::GetSecondsSinceEpoch ()))
{
it->second->SetOwner (nullptr); // detach
m_ECIESx25519Sessions.erase (it);
}
else
{
LogPrint (eLogInfo, "Garlic: ECIESx25519 session with static key ", staticKeyTag.ToBase64 (), " already exists");