mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
Restore original ECHO rate limiting (changed for multipath)
This commit is contained in:
parent
73ddea8864
commit
0ed9db05d2
1 changed files with 5 additions and 25 deletions
|
@ -419,35 +419,15 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rate limit gate for inbound ECHO requests. This rate limiter works
|
* Rate limit gate for inbound ECHO requests
|
||||||
* by draining a certain number of requests per unit time. Each peer may
|
|
||||||
* theoretically receive up to ZT_ECHO_CUTOFF_LIMIT requests per second.
|
|
||||||
*/
|
*/
|
||||||
inline bool rateGateEchoRequest(const int64_t now)
|
inline bool rateGateEchoRequest(const int64_t now)
|
||||||
{
|
{
|
||||||
/*
|
if ((now - _lastEchoRequestReceived) >= ZT_PEER_GENERAL_RATE_LIMIT) {
|
||||||
// TODO: Rethink this
|
_lastEchoRequestReceived = now;
|
||||||
if (_canUseMultipath) {
|
return true;
|
||||||
_echoRequestCutoffCount++;
|
|
||||||
int numToDrain = (now - _lastEchoCheck) / ZT_ECHO_DRAINAGE_DIVISOR;
|
|
||||||
_lastEchoCheck = now;
|
|
||||||
fprintf(stderr, "ZT_ECHO_CUTOFF_LIMIT=%d, (now - _lastEchoCheck)=%d, numToDrain=%d, ZT_ECHO_DRAINAGE_DIVISOR=%d\n", ZT_ECHO_CUTOFF_LIMIT, (now - _lastEchoCheck), numToDrain, ZT_ECHO_DRAINAGE_DIVISOR);
|
|
||||||
if (_echoRequestCutoffCount > numToDrain) {
|
|
||||||
_echoRequestCutoffCount-=numToDrain;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_echoRequestCutoffCount = 0;
|
|
||||||
}
|
|
||||||
return (_echoRequestCutoffCount < ZT_ECHO_CUTOFF_LIMIT);
|
|
||||||
} else {
|
|
||||||
if ((now - _lastEchoRequestReceived) >= (ZT_PEER_GENERAL_RATE_LIMIT)) {
|
|
||||||
_lastEchoRequestReceived = now;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
*/
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue