mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-12 17:10:20 +03:00
random tunnel reject when medium congestion
This commit is contained in:
parent
ec4fe9a1e6
commit
4c66608caf
@ -396,8 +396,26 @@ namespace i2p
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uint8_t retCode = 0;
|
uint8_t retCode = 0;
|
||||||
|
// decide if we should accept tunnel
|
||||||
|
bool accept = i2p::context.AcceptsTunnels ();
|
||||||
|
if (accept)
|
||||||
|
{
|
||||||
|
auto congestionLevel = i2p::context.GetCongestionLevel (false);
|
||||||
|
if (congestionLevel >= CONGESTION_LEVEL_MEDIUM)
|
||||||
|
{
|
||||||
|
if (congestionLevel < CONGESTION_LEVEL_FULL)
|
||||||
|
{
|
||||||
|
// random reject depending on congestion level
|
||||||
|
int level = i2p::tunnel::tunnels.GetRng ()() % (CONGESTION_LEVEL_FULL - CONGESTION_LEVEL_MEDIUM) + CONGESTION_LEVEL_MEDIUM;
|
||||||
|
if (congestionLevel > level)
|
||||||
|
accept = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
accept = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
// replace record to reply
|
// replace record to reply
|
||||||
if (i2p::context.AcceptsTunnels () && i2p::context.GetCongestionLevel (false) < CONGESTION_LEVEL_FULL)
|
if (accept)
|
||||||
{
|
{
|
||||||
auto transitTunnel = i2p::tunnel::CreateTransitTunnel (
|
auto transitTunnel = i2p::tunnel::CreateTransitTunnel (
|
||||||
bufbe32toh (clearText + ECIES_BUILD_REQUEST_RECORD_RECEIVE_TUNNEL_OFFSET),
|
bufbe32toh (clearText + ECIES_BUILD_REQUEST_RECORD_RECEIVE_TUNNEL_OFFSET),
|
||||||
|
Loading…
Reference in New Issue
Block a user