Browse Source

don't save received IV

pull/93/head
orignal 11 years ago
parent
commit
6dbf8d1457
  1. 4
      SSU.cpp
  2. 4
      SSU.h
  3. 28
      SSUData.cpp

4
SSU.cpp

@ -87,10 +87,6 @@ namespace ssu @@ -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);

4
SSU.h

@ -115,8 +115,7 @@ namespace ssu @@ -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 @@ -132,7 +131,6 @@ namespace ssu
i2p::crypto::CBCDecryption m_SessionKeyDecryption;
uint8_t m_SessionKey[32], m_MacKey[32];
std::list<i2p::I2NPMessage *> m_DelayedMessages;
std::set<IV> m_ReceivedIVs;
SSUData m_Data;
size_t m_NumSentBytes, m_NumReceivedBytes;
};

28
SSUData.cpp

@ -354,32 +354,18 @@ namespace ssu @@ -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 ();
}
}
}

Loading…
Cancel
Save