mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-05-16 20:31:47 +02:00
drop second incoming connection with same identity
This commit is contained in:
parent
8e75d8c39a
commit
0518b08ca6
4 changed files with 19 additions and 4 deletions
|
@ -405,9 +405,17 @@ namespace transport
|
|||
auto it = m_Peers.find (ident);
|
||||
if (it != m_Peers.end ())
|
||||
{
|
||||
it->second.session = session;
|
||||
session->SendI2NPMessages (it->second.delayedMessages);
|
||||
it->second.delayedMessages.clear ();
|
||||
if (!it->second.session)
|
||||
{
|
||||
it->second.session = session;
|
||||
session->SendI2NPMessages (it->second.delayedMessages);
|
||||
it->second.delayedMessages.clear ();
|
||||
}
|
||||
else
|
||||
{
|
||||
LogPrint (eLogError, "Session for ", ident.ToBase64 ().substr (0, 4), " already exists");
|
||||
session->Terminate ();
|
||||
}
|
||||
}
|
||||
else // incoming connection
|
||||
m_Peers[ident] = { 0, nullptr, session };
|
||||
|
@ -420,7 +428,7 @@ namespace transport
|
|||
{
|
||||
auto ident = session->GetRemoteIdentity ().GetIdentHash ();
|
||||
auto it = m_Peers.find (ident);
|
||||
if (it != m_Peers.end ())
|
||||
if (it != m_Peers.end () && it->second.session == session)
|
||||
{
|
||||
if (it->second.delayedMessages.size () > 0)
|
||||
ConnectToPeer (ident, it->second);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue