summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2017-03-10 19:52:08 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2017-03-10 19:52:08 -0800
commite3b1fc2ac060408b1c0ec61aa3215bc03ef18848 (patch)
treefc1c03fd0314263948e7b440626841c4813db46f
parent6194d2af3d22c9208998fba490126a2f1416df67 (diff)
downloadinfinitytier-e3b1fc2ac060408b1c0ec61aa3215bc03ef18848.tar.gz
infinitytier-e3b1fc2ac060408b1c0ec61aa3215bc03ef18848.zip
Tweak WHOIS path for federation.
-rw-r--r--node/Constants.hpp7
-rw-r--r--node/Peer.hpp2
-rw-r--r--node/Switch.cpp4
3 files changed, 9 insertions, 4 deletions
diff --git a/node/Constants.hpp b/node/Constants.hpp
index 3bda3805..c2961f12 100644
--- a/node/Constants.hpp
+++ b/node/Constants.hpp
@@ -202,7 +202,7 @@
/**
* Maximum identity WHOIS retries (each attempt tries consulting a different peer)
*/
-#define ZT_MAX_WHOIS_RETRIES 3
+#define ZT_MAX_WHOIS_RETRIES 4
/**
* Transmit queue entry timeout
@@ -391,6 +391,11 @@
#define ZT_PEER_CREDEITIALS_CUTOFF_LIMIT 15
/**
+ * WHOIS rate limit (we allow these to be pretty fast)
+ */
+#define ZT_PEER_WHOIS_RATE_LIMIT 50
+
+/**
* General rate limit for other kinds of rate-limited packets (HELLO, credential request, etc.) both inbound and outbound
*/
#define ZT_PEER_GENERAL_RATE_LIMIT 1000
diff --git a/node/Peer.hpp b/node/Peer.hpp
index 783f48b8..72040b1d 100644
--- a/node/Peer.hpp
+++ b/node/Peer.hpp
@@ -370,7 +370,7 @@ public:
*/
inline bool rateGateInboundWhoisRequest(const uint64_t now)
{
- if ((now - _lastWhoisRequestReceived) >= ZT_PEER_GENERAL_RATE_LIMIT) {
+ if ((now - _lastWhoisRequestReceived) >= ZT_PEER_WHOIS_RATE_LIMIT) {
_lastWhoisRequestReceived = now;
return true;
}
diff --git a/node/Switch.cpp b/node/Switch.cpp
index 0392aec1..85103aa5 100644
--- a/node/Switch.cpp
+++ b/node/Switch.cpp
@@ -688,9 +688,9 @@ unsigned long Switch::doTimerTasks(uint64_t now)
_outstandingWhoisRequests.erase(*a);
} else {
r->lastSent = now;
- r->peersConsulted[r->retries] = _sendWhoisRequest(*a,r->peersConsulted,r->retries);
- ++r->retries;
+ r->peersConsulted[r->retries] = _sendWhoisRequest(*a,r->peersConsulted,(r->retries > 1) ? r->retries : 0);
TRACE("WHOIS %s (retry %u)",a->toString().c_str(),r->retries);
+ ++r->retries;
nextDelay = std::min(nextDelay,(unsigned long)ZT_WHOIS_RETRY_DELAY);
}
} else {