diff --git a/node/Peer.cpp b/node/Peer.cpp index 8639da8f2..1926f2e5b 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -280,11 +280,11 @@ void Peer::resetWithinScope(const RuntimeEnvironment *RR,InetAddress::IpScope sc } } -void Peer::getBestActiveAddresses(uint64_t now,InetAddress &v4,InetAddress &v6) const +void Peer::getBestActiveAddresses(uint64_t now,InetAddress &v4,InetAddress &v6,unsigned int maxDesperation) const { uint64_t bestV4 = 0,bestV6 = 0; for(unsigned int p=0,np=_numPaths;p findCommonGround(const Peer &a,const Peer &b,uint64_t now) + static inline std::pair findCommonGround(const Peer &a,const Peer &b,uint64_t now,unsigned int maxDesperation) { std::pair v4,v6; - b.getBestActiveAddresses(now,v4.first,v6.first); - a.getBestActiveAddresses(now,v4.second,v6.second); + b.getBestActiveAddresses(now,v4.first,v6.first,maxDesperation); + a.getBestActiveAddresses(now,v4.second,v6.second,maxDesperation); if ((v6.first)&&(v6.second)) // prefer IPv6 if both have it since NAT-t is (almost) unnecessary return v6; else if ((v4.first)&&(v4.second)) diff --git a/node/Switch.cpp b/node/Switch.cpp index caeb3e3a7..3710158db 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -289,7 +289,8 @@ bool Switch::unite(const Address &p1,const Address &p2,bool force) const uint64_t now = RR->node->now(); - std::pair cg(Peer::findCommonGround(*p1p,*p2p,now)); + // Right now we only unite desperation == 0 links, which will be direct + std::pair cg(Peer::findCommonGround(*p1p,*p2p,now,0)); if (!(cg.first)) return false;