From 1ff45020e2e6f8a5f77654557b724ac6b61c8e04 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 18 Sep 2020 16:27:41 -0400 Subject: [PATCH] Prefer IPv6 if all else is equal. --- node/Path.hpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/node/Path.hpp b/node/Path.hpp index caa6bbaaa..05aebb46b 100644 --- a/node/Path.hpp +++ b/node/Path.hpp @@ -311,9 +311,15 @@ public: */ inline long quality(const int64_t now) const { - const int l = (long)_latency; - const int age = (long)std::min((now - _lastIn),(int64_t)(ZT_PATH_HEARTBEAT_PERIOD * 10)); // set an upper sanity limit to avoid overflow - return (((age < (ZT_PATH_HEARTBEAT_PERIOD + 5000)) ? l : (l + 0xffff + age)) * (long)((ZT_INETADDRESS_MAX_SCOPE - _ipScope) + 1)); + const long l = (long)_latency; + const long age = (long)std::min((now - _lastIn),(int64_t)(ZT_PATH_HEARTBEAT_PERIOD * 10)); // set an upper sanity limit to avoid overflow + return ( + ( + (age < (long)(ZT_PATH_HEARTBEAT_PERIOD + 5000)) ? l : (l + 0xffff + age) + ) * ( + ((long)ZT_INETADDRESS_MAX_SCOPE - (long)_ipScope) + (_addr.isV6() ? (long)1 : (long)3) + ) + ); } /**