summaryrefslogtreecommitdiff
path: root/node/Path.hpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-07-07 08:54:48 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-07-07 08:54:48 -0700
commitc863ff3f02e9d68eb9bea32160d252eaddb7f1f5 (patch)
treefee1fd7b40123e7f9b015f803cc3b523b8e0aa9a /node/Path.hpp
parentf398952a6c03574e5947f6dfe5ea0f7b0f0b5224 (diff)
downloadinfinitytier-c863ff3f02e9d68eb9bea32160d252eaddb7f1f5.tar.gz
infinitytier-c863ff3f02e9d68eb9bea32160d252eaddb7f1f5.zip
A bunch of comments and cleanup, including some to yesterday's direct path pushing changes. Move path viability check to one place, and stop trying to use link-local addresses since they are not reliable.
Diffstat (limited to 'node/Path.hpp')
-rw-r--r--node/Path.hpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/node/Path.hpp b/node/Path.hpp
index 80b9a3c0..cd21444b 100644
--- a/node/Path.hpp
+++ b/node/Path.hpp
@@ -94,6 +94,39 @@ public:
inline bool operator<=(const Path &p) const throw() { return (_addr <= p._addr); }
inline bool operator>=(const Path &p) const throw() { return (_addr >= p._addr); }
+ /**
+ * Check whether this address is valid for a ZeroTier path
+ *
+ * This checks the address type and scope against address types and scopes
+ * that we currently support for ZeroTier communication.
+ *
+ * @param a Address to check
+ * @return True if address is good for ZeroTier path use
+ */
+ static inline bool isAddressValidForPath(const InetAddress &a)
+ throw()
+ {
+ if ((a.ss_family == AF_INET)||(a.ss_family == AF_INET6)) {
+ switch(a.ipScope()) {
+ /* Note: we don't do link-local at the moment. Unfortunately these
+ * cause several issues. The first is that they usually require a
+ * device qualifier, which we don't handle yet and can't portably
+ * push in PUSH_DIRECT_PATHS. The second is that some OSes assign
+ * these very ephemerally or otherwise strangely. So we'll use
+ * private, pseudo-private, shared (e.g. carrier grade NAT), or
+ * global IP addresses. */
+ case InetAddress::IP_SCOPE_PRIVATE:
+ case InetAddress::IP_SCOPE_PSEUDOPRIVATE:
+ case InetAddress::IP_SCOPE_SHARED:
+ case InetAddress::IP_SCOPE_GLOBAL:
+ return true;
+ default:
+ return false;
+ }
+ }
+ return false;
+ }
+
protected:
InetAddress _addr;
int _metric; // negative == blacklisted