mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-06-05 17:12:11 +00:00
select first hop from connected peers based on peer ordering key
This commit is contained in:
@@ -61,6 +61,7 @@ namespace tunnel
|
||||
if (m_OutboundVariance > 0 && m_NumOutboundHops + m_OutboundVariance > STANDARD_NUM_RECORDS)
|
||||
m_OutboundVariance = (m_NumOutboundHops < STANDARD_NUM_RECORDS) ? STANDARD_NUM_RECORDS - m_NumOutboundHops : 0;
|
||||
m_NextManageTime = i2p::util::GetSecondsSinceEpoch () + m_Rng () % TUNNEL_POOL_MANAGE_INTERVAL;
|
||||
RAND_bytes (m_PeerOrderingKey, 16);
|
||||
}
|
||||
|
||||
TunnelPool::~TunnelPool ()
|
||||
@@ -611,7 +612,8 @@ namespace tunnel
|
||||
(inbound && (i2p::transport::transports.GetNumPeers () > 25 ||
|
||||
(i2p::context.IsLimitedConnectivity () && i2p::transport::transports.GetNumPeers () > 0))))
|
||||
{
|
||||
auto r = i2p::transport::transports.GetRandomPeer (m_IsHighBandwidth && !i2p::context.IsLimitedConnectivity ());
|
||||
auto r = i2p::transport::transports.GetRandomPeer (m_IsHighBandwidth && !i2p::context.IsLimitedConnectivity (),
|
||||
&m_PeerOrderingKey);
|
||||
if (r && r->IsECIES () && (!r->HasProfile () || !r->GetProfile ()->IsBad ()) &&
|
||||
(numHops > 1 || (r->IsV4 () && (!inbound || r->IsPublished (true))))) // first inbound must be published ipv4
|
||||
{
|
||||
@@ -627,7 +629,7 @@ namespace tunnel
|
||||
if (!hop && !i) // if no suitable peer found for first hop, try already connected
|
||||
{
|
||||
LogPrint (eLogInfo, "Tunnels: Can't select first hop for a tunnel. Trying already connected");
|
||||
hop = i2p::transport::transports.GetRandomPeer (false);
|
||||
hop = i2p::transport::transports.GetRandomPeer (false, &m_PeerOrderingKey);
|
||||
if (hop && !hop->IsECIES ()) hop = nullptr;
|
||||
}
|
||||
if (!hop)
|
||||
|
||||
Reference in New Issue
Block a user