Browse Source

fixed #1373. Limit number of tunnels by 16

pull/1634/head
orignal 4 years ago
parent
commit
aa206d034d
  1. 4
      libi2pd/TunnelPool.cpp
  2. 2
      libi2pd/TunnelPool.h

4
libi2pd/TunnelPool.cpp

@ -29,6 +29,10 @@ namespace tunnel @@ -29,6 +29,10 @@ namespace tunnel
m_NumInboundTunnels (numInboundTunnels), m_NumOutboundTunnels (numOutboundTunnels),
m_IsActive (true), m_CustomPeerSelector(nullptr)
{
if (m_NumInboundTunnels > TUNNEL_POOL_MAX_INBOUND_TUNNELS_QUANTITY)
m_NumInboundTunnels = TUNNEL_POOL_MAX_INBOUND_TUNNELS_QUANTITY;
if (m_NumOutboundTunnels > TUNNEL_POOL_MAX_OUTBOUND_TUNNELS_QUANTITY)
m_NumOutboundTunnels = TUNNEL_POOL_MAX_OUTBOUND_TUNNELS_QUANTITY;
m_NextManageTime = i2p::util::GetSecondsSinceEpoch () + rand () % TUNNEL_POOL_MANAGE_INTERVAL;
}

2
libi2pd/TunnelPool.h

@ -28,6 +28,8 @@ namespace i2p @@ -28,6 +28,8 @@ namespace i2p
namespace tunnel
{
const int TUNNEL_POOL_MANAGE_INTERVAL = 10; // in seconds
const int TUNNEL_POOL_MAX_INBOUND_TUNNELS_QUANTITY = 16;
const int TUNNEL_POOL_MAX_OUTBOUND_TUNNELS_QUANTITY = 16;
class Tunnel;
class InboundTunnel;

Loading…
Cancel
Save