Skip to content

Commit

Permalink
create new ratchets session if previous was not replied
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Oct 27, 2020
1 parent 56f3bdd commit c400372
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions libi2pd/ECIESX25519AEADRatchetSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ namespace garlic
bool IsInactive (uint64_t ts) const { return ts > m_LastActivityTimestamp + ECIESX25519_INACTIVITY_TIMEOUT && CanBeRestarted (ts); }

bool IsRatchets () const { return true; };
bool IsReadyToSend () const { return m_State != eSessionStateNewSessionSent; };
uint64_t GetLastActivityTimestamp () const { return m_LastActivityTimestamp; };

private:
Expand Down
1 change: 1 addition & 0 deletions libi2pd/Garlic.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ namespace garlic
virtual bool CleanupUnconfirmedTags () { return false; }; // for I2CP, override in ElGamalAESSession
virtual bool MessageConfirmed (uint32_t msgID);
virtual bool IsRatchets () const { return false; };
virtual bool IsReadyToSend () const { return true; };
virtual uint64_t GetLastActivityTimestamp () const { return 0; }; // non-zero for rathets only

void SetLeaseSetUpdated ()
Expand Down
2 changes: 1 addition & 1 deletion libi2pd/Streaming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ namespace stream
return;
}
}
if (!m_RoutingSession || !m_RoutingSession->GetOwner ()) // expired and detached
if (!m_RoutingSession || !m_RoutingSession->GetOwner () || !m_RoutingSession->IsReadyToSend ()) // expired and detached or new session sent
m_RoutingSession = m_LocalDestination.GetOwner ()->GetRoutingSession (m_RemoteLeaseSet, true);
if (!m_CurrentOutboundTunnel && m_RoutingSession) // first message to send
{
Expand Down

0 comments on commit c400372

Please sign in to comment.