diff --git a/node/IncomingPacket.cpp b/node/IncomingPacket.cpp index 6441b6ad7..347c0649d 100644 --- a/node/IncomingPacket.cpp +++ b/node/IncomingPacket.cpp @@ -860,7 +860,7 @@ bool IncomingPacket::_doEXT_FRAME(const RuntimeEnvironment *RR,void *tPtr,const bool IncomingPacket::_doECHO(const RuntimeEnvironment *RR,void *tPtr,const SharedPtr &peer) { uint64_t now = RR->node->now(); - if (!peer->rateGateEchoRequest(now)) { + if (!_path->rateGateEchoRequest(now)) { return true; } diff --git a/node/Path.hpp b/node/Path.hpp index 753bf0ab2..fa55c2f99 100644 --- a/node/Path.hpp +++ b/node/Path.hpp @@ -83,6 +83,7 @@ public: _lastOut(0), _lastIn(0), _lastTrustEstablishedPacketReceived(0), + _lastEchoRequestReceived(0), _localSocket(-1), _latency(0xffff), _addr(), @@ -93,6 +94,7 @@ public: _lastOut(0), _lastIn(0), _lastTrustEstablishedPacketReceived(0), + _lastEchoRequestReceived(0), _localSocket(localSocket), _latency(0xffff), _addr(addr), @@ -266,6 +268,18 @@ public: */ inline int64_t lastTrustEstablishedPacketReceived() const { return _lastTrustEstablishedPacketReceived; } + /** + * Rate limit gate for inbound ECHO requests + */ + inline bool rateGateEchoRequest(const int64_t now) + { + if ((now - _lastEchoRequestReceived) >= (ZT_PEER_GENERAL_RATE_LIMIT / 16)) { + _lastEchoRequestReceived = now; + return true; + } + return false; + } + void *_bondingMetricPtr; private: @@ -273,6 +287,9 @@ private: volatile int64_t _lastOut; volatile int64_t _lastIn; volatile int64_t _lastTrustEstablishedPacketReceived; + + int64_t _lastEchoRequestReceived; + int64_t _localSocket; volatile unsigned int _latency; InetAddress _addr; diff --git a/node/Peer.cpp b/node/Peer.cpp index 8ab51687d..76f83940f 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -34,7 +34,6 @@ Peer::Peer(const RuntimeEnvironment *renv,const Identity &myIdentity,const Ident _lastTriedMemorizedPath(0), _lastDirectPathPushSent(0), _lastDirectPathPushReceive(0), - _lastEchoRequestReceived(0), _lastCredentialRequestSent(0), _lastWhoisRequestReceived(0), _lastCredentialsReceived(0), diff --git a/node/Peer.hpp b/node/Peer.hpp index 3bfe31950..77e35b786 100644 --- a/node/Peer.hpp +++ b/node/Peer.hpp @@ -418,18 +418,6 @@ public: return false; } - /** - * Rate limit gate for inbound ECHO requests - */ - inline bool rateGateEchoRequest(const int64_t now) - { - if ((now - _lastEchoRequestReceived) >= ZT_PEER_GENERAL_RATE_LIMIT) { - _lastEchoRequestReceived = now; - return true; - } - return false; - } - /** * Serialize a peer for storage in local cache * @@ -546,7 +534,6 @@ private: int64_t _lastTriedMemorizedPath; int64_t _lastDirectPathPushSent; int64_t _lastDirectPathPushReceive; - int64_t _lastEchoRequestReceived; int64_t _lastCredentialRequestSent; int64_t _lastWhoisRequestReceived; int64_t _lastCredentialsReceived;