mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
drop second incoming connection with same identity
This commit is contained in:
parent
8e75d8c39a
commit
0518b08ca6
@ -759,6 +759,11 @@ namespace transport
|
||||
transports.PeerDisconnected (shared_from_this ());
|
||||
}
|
||||
|
||||
void SSUSession::Terminate ()
|
||||
{
|
||||
m_Server.DeleteSession (shared_from_this ());
|
||||
}
|
||||
|
||||
void SSUSession::Established ()
|
||||
{
|
||||
m_State = eSessionStateEstablished;
|
||||
|
@ -63,6 +63,7 @@ namespace transport
|
||||
void Introduce (uint32_t iTag, const uint8_t * iKey);
|
||||
void WaitForIntroduction ();
|
||||
void Close ();
|
||||
void Terminate ();
|
||||
boost::asio::ip::udp::endpoint& GetRemoteEndpoint () { return m_RemoteEndpoint; };
|
||||
bool IsV6 () const { return m_RemoteEndpoint.address ().is_v6 (); };
|
||||
void SendI2NPMessage (I2NPMessage * msg);
|
||||
|
@ -62,6 +62,7 @@ namespace transport
|
||||
}
|
||||
|
||||
virtual ~TransportSession () { delete m_DHKeysPair; };
|
||||
virtual void Terminate () = 0;
|
||||
|
||||
std::shared_ptr<const i2p::data::RouterInfo> GetRemoteRouter () { return m_RemoteRouter; };
|
||||
const i2p::data::IdentityEx& GetRemoteIdentity () { return m_RemoteIdentity; };
|
||||
|
@ -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…
x
Reference in New Issue
Block a user