Browse Source

allow session restart after 2 minutes from creation

pull/1525/head
orignal 4 years ago
parent
commit
86e8614934
  1. 4
      libi2pd/ECIESX25519AEADRatchetSession.cpp
  2. 4
      libi2pd/ECIESX25519AEADRatchetSession.h

4
libi2pd/ECIESX25519AEADRatchetSession.cpp

@ -467,7 +467,8 @@ namespace garlic @@ -467,7 +467,8 @@ namespace garlic
return false;
}
m_State = eSessionStateNewSessionReplySent;
m_SessionCreatedTimestamp = i2p::util::GetSecondsSinceEpoch ();
return true;
}
@ -559,6 +560,7 @@ namespace garlic @@ -559,6 +560,7 @@ namespace garlic
if (m_State == eSessionStateNewSessionSent)
{
m_State = eSessionStateEstablished;
m_SessionCreatedTimestamp = i2p::util::GetSecondsSinceEpoch ();
GetOwner ()->AddECIESx25519Session (m_RemoteStaticKey, shared_from_this ());
}
memcpy (m_H, h, 32); // restore m_H

4
libi2pd/ECIESX25519AEADRatchetSession.h

@ -131,7 +131,7 @@ namespace garlic @@ -131,7 +131,7 @@ namespace garlic
}
bool CheckExpired (uint64_t ts); // true is expired
bool CanBeRestarted (uint64_t ts) const { return ts > m_LastActivityTimestamp + ECIESX25519_RESTART_TIMEOUT; }
bool CanBeRestarted (uint64_t ts) const { return ts > m_SessionCreatedTimestamp + ECIESX25519_RESTART_TIMEOUT; }
bool IsRatchets () const { return true; };
@ -168,7 +168,7 @@ namespace garlic @@ -168,7 +168,7 @@ namespace garlic
uint8_t m_NSREncodedKey[32], m_NSRH[32], m_NSRKey[32]; // new session reply, for incoming only
i2p::crypto::X25519Keys m_EphemeralKeys;
SessionState m_State = eSessionStateNew;
uint64_t m_LastActivityTimestamp = 0; // incoming
uint64_t m_SessionCreatedTimestamp = 0, m_LastActivityTimestamp = 0; // incoming
std::shared_ptr<RatchetTagSet> m_SendTagset, m_NSRTagset;
std::unique_ptr<i2p::data::IdentHash> m_Destination;// TODO: might not need it
std::list<std::pair<uint16_t, int> > m_AckRequests; // (tagsetid, index)

Loading…
Cancel
Save