Browse Source

remove session after HolePunch received

pull/1771/head
orignal 2 years ago
parent
commit
6ca9a599ff
  1. 11
      libi2pd/SSU2.cpp
  2. 1
      libi2pd/SSU2.h
  3. 10
      libi2pd/SSU2Session.cpp

11
libi2pd/SSU2.cpp

@ -243,17 +243,6 @@ namespace transport @@ -243,17 +243,6 @@ namespace transport
}
}
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)
{
if (session)

1
libi2pd/SSU2.h

@ -53,7 +53,6 @@ namespace transport @@ -53,7 +53,6 @@ namespace transport
void AddSession (std::shared_ptr<SSU2Session> session);
void RemoveSession (uint64_t connID);
void UpdateSessionConnID (uint64_t oldConnID); // session has new connID
void AddSessionByRouterHash (std::shared_ptr<SSU2Session> session);
bool AddPendingOutgoingSession (std::shared_ptr<SSU2Session> session);
void RemovePendingOutgoingSession (const boost::asio::ip::udp::endpoint& ep);

10
libi2pd/SSU2Session.cpp

@ -51,14 +51,17 @@ namespace transport @@ -51,14 +51,17 @@ namespace transport
void SSU2Session::Connect ()
{
if (m_State == eSSU2SessionStateUnknown)
if (m_State == eSSU2SessionStateUnknown || m_State == eSSU2SessionStateTokenReceived)
{
ScheduleConnectTimer ();
auto token = m_Server.FindOutgoingToken (m_RemoteEndpoint);
if (token)
SendSessionRequest (token);
else
{
m_State = eSSU2SessionStateUnknown;
SendTokenRequest ();
}
}
}
@ -959,9 +962,10 @@ namespace transport @@ -959,9 +962,10 @@ namespace transport
uint64_t oldConnID = GetConnID ();
RAND_bytes ((uint8_t *)&m_DestConnID, 8);
RAND_bytes ((uint8_t *)&m_SourceConnID, 8);
m_Server.UpdateSessionConnID (oldConnID);
// connect
m_State = eSSU2SessionStateUnknown;
m_State = eSSU2SessionStateTokenReceived;
m_Server.AddPendingOutgoingSession (shared_from_this ());
m_Server.RemoveSession (oldConnID);
Connect ();
}

Loading…
Cancel
Save