mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
recreate SSU session again if session key is invalid
This commit is contained in:
parent
60ed43c11b
commit
92fc736cfa
@ -48,6 +48,9 @@ namespace transport
|
|||||||
{
|
{
|
||||||
m_ResendTimer.cancel ();
|
m_ResendTimer.cancel ();
|
||||||
m_IncompleteMessagesCleanupTimer.cancel ();
|
m_IncompleteMessagesCleanupTimer.cancel ();
|
||||||
|
m_IncompleteMessages.clear ();
|
||||||
|
m_SentMessages.clear ();
|
||||||
|
m_ReceivedMessages.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSUData::AdjustPacketSize (std::shared_ptr<const i2p::data::RouterInfo> remoteRouter)
|
void SSUData::AdjustPacketSize (std::shared_ptr<const i2p::data::RouterInfo> remoteRouter)
|
||||||
|
@ -104,6 +104,7 @@ namespace transport
|
|||||||
DecryptSessionKey (buf, len);
|
DecryptSessionKey (buf, len);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (m_State == eSessionStateEstablished) Reset (); // new session key required
|
||||||
// try intro key depending on side
|
// try intro key depending on side
|
||||||
if (Validate (buf, len, m_IntroKey))
|
if (Validate (buf, len, m_IntroKey))
|
||||||
Decrypt (buf, len, m_IntroKey);
|
Decrypt (buf, len, m_IntroKey);
|
||||||
@ -869,13 +870,25 @@ namespace transport
|
|||||||
|
|
||||||
void SSUSession::Close ()
|
void SSUSession::Close ()
|
||||||
{
|
{
|
||||||
|
SendSessionDestroyed ();
|
||||||
|
Reset ();
|
||||||
m_State = eSessionStateClosed;
|
m_State = eSessionStateClosed;
|
||||||
SendSesionDestroyed ();
|
}
|
||||||
|
|
||||||
|
void SSUSession::Reset ()
|
||||||
|
{
|
||||||
|
m_State = eSessionStateUnknown;
|
||||||
transports.PeerDisconnected (shared_from_this ());
|
transports.PeerDisconnected (shared_from_this ());
|
||||||
m_Data.Stop ();
|
m_Data.Stop ();
|
||||||
m_ConnectTimer.cancel ();
|
m_ConnectTimer.cancel ();
|
||||||
if (m_SentRelayTag)
|
if (m_SentRelayTag)
|
||||||
|
{
|
||||||
m_Server.RemoveRelay (m_SentRelayTag); // relay tag is not valid anymore
|
m_Server.RemoveRelay (m_SentRelayTag); // relay tag is not valid anymore
|
||||||
|
m_SentRelayTag = 0;
|
||||||
|
}
|
||||||
|
m_DHKeysPair = nullptr;
|
||||||
|
m_SignedData = nullptr;
|
||||||
|
m_IsSessionKey = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSUSession::Done ()
|
void SSUSession::Done ()
|
||||||
@ -1140,7 +1153,7 @@ namespace transport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSUSession::SendSesionDestroyed ()
|
void SSUSession::SendSessionDestroyed ()
|
||||||
{
|
{
|
||||||
if (m_IsSessionKey)
|
if (m_IsSessionKey)
|
||||||
{
|
{
|
||||||
|
@ -121,7 +121,7 @@ namespace transport
|
|||||||
void ProcessPeerTest (const uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint);
|
void ProcessPeerTest (const uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint);
|
||||||
void SendPeerTest (uint32_t nonce, const boost::asio::ip::address& address, uint16_t port, const uint8_t * introKey, bool toAddress = true, bool sendAddress = true);
|
void SendPeerTest (uint32_t nonce, const boost::asio::ip::address& address, uint16_t port, const uint8_t * introKey, bool toAddress = true, bool sendAddress = true);
|
||||||
void ProcessData (uint8_t * buf, size_t len);
|
void ProcessData (uint8_t * buf, size_t len);
|
||||||
void SendSesionDestroyed ();
|
void SendSessionDestroyed ();
|
||||||
void Send (uint8_t type, const uint8_t * payload, size_t len); // with session key
|
void Send (uint8_t type, const uint8_t * payload, size_t len); // with session key
|
||||||
void Send (const uint8_t * buf, size_t size);
|
void Send (const uint8_t * buf, size_t size);
|
||||||
|
|
||||||
@ -132,6 +132,8 @@ namespace transport
|
|||||||
void DecryptSessionKey (uint8_t * buf, size_t len);
|
void DecryptSessionKey (uint8_t * buf, size_t len);
|
||||||
bool Validate (uint8_t * buf, size_t len, const i2p::crypto::MACKey& macKey);
|
bool Validate (uint8_t * buf, size_t len, const i2p::crypto::MACKey& macKey);
|
||||||
|
|
||||||
|
void Reset ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class SSUData; // TODO: change in later
|
friend class SSUData; // TODO: change in later
|
||||||
|
Loading…
Reference in New Issue
Block a user