mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 11:04:00 +01:00
remove session after HolePunch received
This commit is contained in:
parent
83bd3b6f0b
commit
6ca9a599ff
|
@ -242,17 +242,6 @@ namespace transport
|
||||||
m_Sessions.erase (it);
|
m_Sessions.erase (it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSU2Server::UpdateSessionConnID (uint64_t oldConnID)
|
|
||||||
{
|
|
||||||
auto it = m_Sessions.find (oldConnID);
|
|
||||||
if (it != m_Sessions.end ())
|
|
||||||
{
|
|
||||||
auto session = it->second;
|
|
||||||
m_Sessions.erase (it);
|
|
||||||
m_Sessions.emplace (session->GetConnID (), session);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SSU2Server::AddSessionByRouterHash (std::shared_ptr<SSU2Session> session)
|
void SSU2Server::AddSessionByRouterHash (std::shared_ptr<SSU2Session> session)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,6 @@ namespace transport
|
||||||
|
|
||||||
void AddSession (std::shared_ptr<SSU2Session> session);
|
void AddSession (std::shared_ptr<SSU2Session> session);
|
||||||
void RemoveSession (uint64_t connID);
|
void RemoveSession (uint64_t connID);
|
||||||
void UpdateSessionConnID (uint64_t oldConnID); // session has new connID
|
|
||||||
void AddSessionByRouterHash (std::shared_ptr<SSU2Session> session);
|
void AddSessionByRouterHash (std::shared_ptr<SSU2Session> session);
|
||||||
bool AddPendingOutgoingSession (std::shared_ptr<SSU2Session> session);
|
bool AddPendingOutgoingSession (std::shared_ptr<SSU2Session> session);
|
||||||
void RemovePendingOutgoingSession (const boost::asio::ip::udp::endpoint& ep);
|
void RemovePendingOutgoingSession (const boost::asio::ip::udp::endpoint& ep);
|
||||||
|
|
|
@ -51,14 +51,17 @@ namespace transport
|
||||||
|
|
||||||
void SSU2Session::Connect ()
|
void SSU2Session::Connect ()
|
||||||
{
|
{
|
||||||
if (m_State == eSSU2SessionStateUnknown)
|
if (m_State == eSSU2SessionStateUnknown || m_State == eSSU2SessionStateTokenReceived)
|
||||||
{
|
{
|
||||||
ScheduleConnectTimer ();
|
ScheduleConnectTimer ();
|
||||||
auto token = m_Server.FindOutgoingToken (m_RemoteEndpoint);
|
auto token = m_Server.FindOutgoingToken (m_RemoteEndpoint);
|
||||||
if (token)
|
if (token)
|
||||||
SendSessionRequest (token);
|
SendSessionRequest (token);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
m_State = eSSU2SessionStateUnknown;
|
||||||
SendTokenRequest ();
|
SendTokenRequest ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -959,9 +962,10 @@ namespace transport
|
||||||
uint64_t oldConnID = GetConnID ();
|
uint64_t oldConnID = GetConnID ();
|
||||||
RAND_bytes ((uint8_t *)&m_DestConnID, 8);
|
RAND_bytes ((uint8_t *)&m_DestConnID, 8);
|
||||||
RAND_bytes ((uint8_t *)&m_SourceConnID, 8);
|
RAND_bytes ((uint8_t *)&m_SourceConnID, 8);
|
||||||
m_Server.UpdateSessionConnID (oldConnID);
|
|
||||||
// connect
|
// connect
|
||||||
m_State = eSSU2SessionStateUnknown;
|
m_State = eSSU2SessionStateTokenReceived;
|
||||||
|
m_Server.AddPendingOutgoingSession (shared_from_this ());
|
||||||
|
m_Server.RemoveSession (oldConnID);
|
||||||
Connect ();
|
Connect ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue