From 0ed9db05d2af718014f4a6c6098ef0017d8816c7 Mon Sep 17 00:00:00 2001 From: Joseph Henry Date: Tue, 20 Jul 2021 19:06:47 -0700 Subject: [PATCH] Restore original ECHO rate limiting (changed for multipath) --- node/Peer.hpp | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/node/Peer.hpp b/node/Peer.hpp index a064bf697..9d012cdbe 100644 --- a/node/Peer.hpp +++ b/node/Peer.hpp @@ -419,35 +419,15 @@ public: } /** - * Rate limit gate for inbound ECHO requests. This rate limiter works - * by draining a certain number of requests per unit time. Each peer may - * theoretically receive up to ZT_ECHO_CUTOFF_LIMIT requests per second. + * Rate limit gate for inbound ECHO requests */ inline bool rateGateEchoRequest(const int64_t now) { - /* - // TODO: Rethink this - if (_canUseMultipath) { - _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; + if ((now - _lastEchoRequestReceived) >= ZT_PEER_GENERAL_RATE_LIMIT) { + _lastEchoRequestReceived = now; + return true; } - */ - return true; + return false; } /**