Skip to content

Commit

Permalink
delete ECIESX25519 session without destination shortly
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Nov 11, 2024
1 parent a411fff commit 09b7d44
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions libi2pd/ECIESX25519AEADRatchetSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,7 @@ namespace garlic
bool ECIESX25519AEADRatchetSession::CheckExpired (uint64_t ts)
{
CleanupUnconfirmedLeaseSet (ts);
if (!m_Destination && ts > m_LastActivityTimestamp + ECIESX25519_SESSION_CREATE_TIMEOUT) return true; // m_LastActivityTimestamp is NS receive time
return ts > m_LastActivityTimestamp + ECIESX25519_RECEIVE_EXPIRATION_TIMEOUT && // seconds
ts*1000 > m_LastSentTimestamp + ECIESX25519_SEND_EXPIRATION_TIMEOUT*1000; // milliseconds
}
Expand Down
5 changes: 3 additions & 2 deletions libi2pd/ECIESX25519AEADRatchetSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace garlic
const int ECIESX25519_SEND_INACTIVITY_TIMEOUT = 5000; // number of milliseconds we can send empty(pyaload only) packet after
const int ECIESX25519_SEND_EXPIRATION_TIMEOUT = 480; // in seconds
const int ECIESX25519_RECEIVE_EXPIRATION_TIMEOUT = 600; // in seconds
const int ECIESX25519_SESSION_CREATE_TIMEOUT = 3; // in seconds, NSR must be send after NS received
const int ECIESX25519_PREVIOUS_TAGSET_EXPIRATION_TIMEOUT = 180; // in seconds
const int ECIESX25519_ACK_REQUEST_INTERVAL = 33000; // in milliseconds
const int ECIESX25519_ACK_REQUEST_MAX_NUM_ATTEMPTS = 3;
Expand Down Expand Up @@ -169,7 +170,7 @@ namespace garlic
void SetRemoteStaticKey (const uint8_t * key) { memcpy (m_RemoteStaticKey, key, 32); }

void Terminate () { m_IsTerminated = true; }
void SetDestination (const i2p::data::IdentHash& dest) // TODO:
void SetDestination (const i2p::data::IdentHash& dest)
{
if (!m_Destination) m_Destination.reset (new i2p::data::IdentHash (dest));
}
Expand Down Expand Up @@ -224,7 +225,7 @@ namespace garlic
uint64_t m_SessionCreatedTimestamp = 0, m_LastActivityTimestamp = 0, // incoming (in seconds)
m_LastSentTimestamp = 0; // in milliseconds
std::shared_ptr<RatchetTagSet> m_SendTagset, m_NSRSendTagset;
std::unique_ptr<i2p::data::IdentHash> m_Destination;// TODO: might not need it
std::unique_ptr<i2p::data::IdentHash> m_Destination;// must be set for NS if outgoing and NSR if incoming
std::list<std::pair<uint16_t, int> > m_AckRequests; // incoming (tagsetid, index)
bool m_SendReverseKey = false, m_SendForwardKey = false, m_IsTerminated = false;
std::unique_ptr<DHRatchet> m_NextReceiveRatchet, m_NextSendRatchet;
Expand Down
2 changes: 1 addition & 1 deletion libi2pd/Garlic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ namespace garlic
session->SetRemoteStaticKey (staticKey);
}
if (destination->IsDestination ())
session->SetDestination (destination->GetIdentHash ()); // TODO: remove
session->SetDestination (destination->GetIdentHash ()); // NS or NSR
return session;
}
else
Expand Down

0 comments on commit 09b7d44

Please sign in to comment.