From 5e331d673388f4fdc2eded418f63208dcaec63af Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 10 Apr 2015 10:13:50 -0700 Subject: Restrict unite() to desperation==0 since NAT-t only works right now with direct links. --- node/Peer.cpp | 4 ++-- node/Peer.hpp | 12 +++++++----- node/Switch.cpp | 3 ++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/node/Peer.cpp b/node/Peer.cpp index 8639da8f..1926f2e5 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 caeb3e3a..3710158d 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; -- cgit v1.2.3