From 9ef8ae99e2e98102af0aac791218ce29634f6971 Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 16 Mar 2014 08:34:32 -0400 Subject: [PATCH] close SSU session if MAC verification fails --- SSU.cpp | 11 +++++++++++ SSU.h | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/SSU.cpp b/SSU.cpp index 196c0a72..64886e90 100644 --- a/SSU.cpp +++ b/SSU.cpp @@ -418,7 +418,10 @@ namespace ssu LogPrint ("Unexpected payload type ", (int)(header->flag >> 4)); } else + { LogPrint ("MAC verification failed"); + Failed (); + } } else LogPrint ("SSU is not supported"); @@ -511,6 +514,14 @@ namespace ssu m_DelayedMessages.clear (); } } + + void SSUSession::Failed () + { + m_State = eSessionStateFailed; + Close (); + if (m_Server) + m_Server->DeleteSession (this); // delete this + } const uint8_t * SSUSession::GetIntroKey () const { diff --git a/SSU.h b/SSU.h index c61d09bb..c0c82e3e 100644 --- a/SSU.h +++ b/SSU.h @@ -58,7 +58,8 @@ namespace ssu eSessionRelayRequestSent, eSessionRelayRequestReceived, eSessionRelayResponseReceived, - eSessionStateEstablished + eSessionStateEstablished, + eSessionStateFailed }; class SSUServer; @@ -91,6 +92,7 @@ namespace ssu void SendSessionConfirmed (const uint8_t * y, const uint8_t * ourAddress, uint32_t relayTag); void ProcessRelayResponse (uint8_t * buf, size_t len); void Established (); + void Failed (); void ProcessData (uint8_t * buf, size_t len); void SendMsgAck (uint32_t msgID); void SendSesionDestroyed ();