mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-09 11:27:53 +00:00
don't pick same session for PeerTest msg 2
This commit is contained in:
parent
baf74cb582
commit
463ed12ce8
@ -291,7 +291,8 @@ namespace transport
|
|||||||
m_PendingOutgoingSessions.erase (ep);
|
m_PendingOutgoingSessions.erase (ep);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<SSU2Session> SSU2Server::GetRandomSession (i2p::data::RouterInfo::CompatibleTransports remoteTransports) const
|
std::shared_ptr<SSU2Session> SSU2Server::GetRandomSession (
|
||||||
|
i2p::data::RouterInfo::CompatibleTransports remoteTransports, const i2p::data::IdentHash& excluded) const
|
||||||
{
|
{
|
||||||
if (m_Sessions.empty ()) return nullptr;
|
if (m_Sessions.empty ()) return nullptr;
|
||||||
uint16_t ind;
|
uint16_t ind;
|
||||||
@ -301,7 +302,8 @@ namespace transport
|
|||||||
std::advance (it, ind);
|
std::advance (it, ind);
|
||||||
while (it != m_Sessions.end ())
|
while (it != m_Sessions.end ())
|
||||||
{
|
{
|
||||||
if (it->second->GetRemoteTransports () & remoteTransports)
|
if ((it->second->GetRemoteTransports () & remoteTransports) &&
|
||||||
|
it->second->GetRemoteIdentity ()->GetIdentHash () != excluded)
|
||||||
return it->second;
|
return it->second;
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
@ -309,7 +311,8 @@ namespace transport
|
|||||||
it = m_Sessions.begin ();
|
it = m_Sessions.begin ();
|
||||||
while (it != m_Sessions.end () && ind)
|
while (it != m_Sessions.end () && ind)
|
||||||
{
|
{
|
||||||
if (it->second->GetRemoteTransports () & remoteTransports)
|
if ((it->second->GetRemoteTransports () & remoteTransports) &&
|
||||||
|
it->second->GetRemoteIdentity ()->GetIdentHash () != excluded)
|
||||||
return it->second;
|
return it->second;
|
||||||
it++; ind--;
|
it++; ind--;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,8 @@ namespace transport
|
|||||||
void RemovePendingOutgoingSession (const boost::asio::ip::udp::endpoint& ep);
|
void RemovePendingOutgoingSession (const boost::asio::ip::udp::endpoint& ep);
|
||||||
std::shared_ptr<SSU2Session> FindSession (const i2p::data::IdentHash& ident) const;
|
std::shared_ptr<SSU2Session> FindSession (const i2p::data::IdentHash& ident) const;
|
||||||
std::shared_ptr<SSU2Session> FindPendingOutgoingSession (const boost::asio::ip::udp::endpoint& ep) const;
|
std::shared_ptr<SSU2Session> FindPendingOutgoingSession (const boost::asio::ip::udp::endpoint& ep) const;
|
||||||
std::shared_ptr<SSU2Session> GetRandomSession (i2p::data::RouterInfo::CompatibleTransports remoteTransports) const;
|
std::shared_ptr<SSU2Session> GetRandomSession (i2p::data::RouterInfo::CompatibleTransports remoteTransports,
|
||||||
|
const i2p::data::IdentHash& excluded) const;
|
||||||
|
|
||||||
void AddRelay (uint32_t tag, std::shared_ptr<SSU2Session> relay);
|
void AddRelay (uint32_t tag, std::shared_ptr<SSU2Session> relay);
|
||||||
void RemoveRelay (uint32_t tag);
|
void RemoveRelay (uint32_t tag);
|
||||||
|
@ -1495,7 +1495,8 @@ namespace transport
|
|||||||
{
|
{
|
||||||
case 1: // Bob from Alice
|
case 1: // Bob from Alice
|
||||||
{
|
{
|
||||||
auto session = m_Server.GetRandomSession ((buf[12] == 6) ? i2p::data::RouterInfo::eSSU2V4 : i2p::data::RouterInfo::eSSU2V6);
|
auto session = m_Server.GetRandomSession ((buf[12] == 6) ? i2p::data::RouterInfo::eSSU2V4 : i2p::data::RouterInfo::eSSU2V6,
|
||||||
|
GetRemoteIdentity ()->GetIdentHash ());
|
||||||
if (session) // session with Charlie
|
if (session) // session with Charlie
|
||||||
{
|
{
|
||||||
session->m_PeerTests.emplace (nonce, std::make_pair (shared_from_this (), i2p::util::GetSecondsSinceEpoch ()));
|
session->m_PeerTests.emplace (nonce, std::make_pair (shared_from_this (), i2p::util::GetSecondsSinceEpoch ()));
|
||||||
|
Loading…
Reference in New Issue
Block a user