Browse Source

use pool's rng for random tunnel/remote lease selection

pull/2095/head
orignal 2 months ago
parent
commit
a69eade1f4
  1. 18
      libi2pd/Datagram.cpp

18
libi2pd/Datagram.cpp

@ -417,7 +417,14 @@ namespace datagram
auto sz = ls.size(); auto sz = ls.size();
if (sz) if (sz)
{ {
auto idx = rand() % sz; int idx = -1;
if (m_LocalDestination)
{
auto pool = m_LocalDestination->GetTunnelPool ();
if (pool)
idx = m_LocalDestination->GetTunnelPool ()->GetRng ()() % sz;
}
if (idx < 0) idx = rand () % sz;
path->remoteLease = ls[idx]; path->remoteLease = ls[idx];
} }
else else
@ -443,7 +450,14 @@ namespace datagram
auto sz = ls.size(); auto sz = ls.size();
if (sz) if (sz)
{ {
auto idx = rand() % sz; int idx = -1;
if (m_LocalDestination)
{
auto pool = m_LocalDestination->GetTunnelPool ();
if (pool)
idx = m_LocalDestination->GetTunnelPool ()->GetRng ()() % sz;
}
if (idx < 0) idx = rand () % sz;
path->remoteLease = ls[idx]; path->remoteLease = ls[idx];
} }
else else

Loading…
Cancel
Save