From 6dbf8d145760273598c29b773969e59d6e2dbb99 Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 21 Jul 2014 22:13:57 -0400 Subject: [PATCH] don't save received IV --- SSU.cpp | 4 ---- SSU.h | 4 +--- SSUData.cpp | 28 +++++++--------------------- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/SSU.cpp b/SSU.cpp index 392fcf0f..0765ef24 100644 --- a/SSU.cpp +++ b/SSU.cpp @@ -87,10 +87,6 @@ namespace ssu { if (m_State == eSessionStateEstablished) ScheduleTermination (); - /* // check for duplicate - const uint8_t * iv = ((SSUHeader *)buf)->iv; - if (m_ReceivedIVs.count (iv)) return; // duplicate detected - m_ReceivedIVs.insert (iv);*/ if (m_IsSessionKey && Validate (buf, len, m_MacKey)) // try session key first DecryptSessionKey (buf, len); diff --git a/SSU.h b/SSU.h index 01870cd2..d5d4ebc3 100644 --- a/SSU.h +++ b/SSU.h @@ -115,8 +115,7 @@ namespace ssu void HandleTerminationTimer (const boost::system::error_code& ecode); private: - - typedef i2p::data::Tag<16> IV; + friend class SSUData; // TODO: change in later SSUServer& m_Server; boost::asio::ip::udp::endpoint m_RemoteEndpoint; @@ -132,7 +131,6 @@ namespace ssu i2p::crypto::CBCDecryption m_SessionKeyDecryption; uint8_t m_SessionKey[32], m_MacKey[32]; std::list m_DelayedMessages; - std::set m_ReceivedIVs; SSUData m_Data; size_t m_NumSentBytes, m_NumReceivedBytes; }; diff --git a/SSUData.cpp b/SSUData.cpp index f2236cfd..a99d8999 100644 --- a/SSUData.cpp +++ b/SSUData.cpp @@ -354,32 +354,18 @@ namespace ssu if (ecode != boost::asio::error::operation_aborted) { uint32_t ts = i2p::util::GetSecondsSinceEpoch (); - for (auto it = m_SentMessages.begin (); it != m_SentMessages.end ();) + for (auto it : m_SentMessages) { - if (ts >= it->second->nextResendTime) + if (ts >= it.second->nextResendTime && it.second->numResends < MAX_NUM_RESENDS) { - bool isEmpty = true; - for (auto f: it->second->fragments) - if (f) - { - isEmpty = false; - m_Session.Send (f->buf, f->len); // resend - } + for (auto f: it.second->fragments) + if (f) m_Session.Send (f->buf, f->len); // resend - it->second->numResends++; - if (isEmpty || it->second->numResends >= MAX_NUM_RESENDS) - { - delete it->second; - it = m_SentMessages.erase (it); - } - else - it++; + it.second->numResends++; + it.second->nextResendTime += it.second->numResends*RESEND_INTERVAL; } - else - it++; } - if (!m_SentMessages.empty ()) - ScheduleResend (); + ScheduleResend (); } } }