summaryrefslogtreecommitdiff
path: root/node/Cluster.hpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-10-27 09:36:48 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-10-27 09:36:48 -0700
commit69857b4ba8bb6ce341ca6dcdc03759fb901a831a (patch)
treef6d0ad35f5cee86d98b8d255c32c6f58c7bcc59e /node/Cluster.hpp
parente713f7a54c02915120ac3c32e0f28bd1dd744a80 (diff)
downloadinfinitytier-69857b4ba8bb6ce341ca6dcdc03759fb901a831a.tar.gz
infinitytier-69857b4ba8bb6ce341ca6dcdc03759fb901a831a.zip
Refactor cluster redirects to move code to push peers out of the actual Cluster function that checks for redirect, and clean up Peer::received() to be a bit more logical.
Diffstat (limited to 'node/Cluster.hpp')
-rw-r--r--node/Cluster.hpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/node/Cluster.hpp b/node/Cluster.hpp
index b1266f27..080c9310 100644
--- a/node/Cluster.hpp
+++ b/node/Cluster.hpp
@@ -245,15 +245,22 @@ public:
void removeMember(uint16_t memberId);
/**
- * Redirect this peer to a better cluster member if needed
+ * Find a better cluster endpoint for this peer
*
- * @param peer Peer to (possibly) redirect
- * @param localAddress Local address for path or NULL for none/any
+ * If this endpoint appears to be the best, a NULL/0 InetAddres is returned.
+ * Otherwise the InetAddress of a better endpoint is returned and the peer
+ * can then then be told to contact us there.
+ *
+ * Redirection is only done within the same address family, so the returned
+ * endpoint will always be the same ss_family as the supplied physical
+ * address.
+ *
+ * @param peerAddress Address of peer to (possibly) redirect
* @param peerPhysicalAddress Physical address of peer's current best path (where packet was most recently received or getBestPath()->address())
* @param offload Always redirect if possible -- can be used to offload peers during shutdown
- * @return True if peer was redirected
+ * @return InetAddress or NULL if there does not seem to be a better endpoint
*/
- bool redirectPeer(const SharedPtr<Peer> &peer,const InetAddress &localAddress,const InetAddress &peerPhysicalAddress,bool offload);
+ InetAddress findBetterEndpoint(const Address &peerAddress,const InetAddress &peerPhysicalAddress,bool offload);
/**
* Fill out ZT_ClusterStatus structure (from core API)