From f0003ea92277039f70dd6f16920dd2db9fb2fb1e Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 27 Jul 2015 17:02:43 -0700 Subject: Push remote surface as reported by peers along with known interface direct paths to assist with (some) NAT traversal. (trying this, may back out if not effective) --- node/Peer.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'node/Peer.cpp') diff --git a/node/Peer.cpp b/node/Peer.cpp index 73c20228..804e6e39 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -33,6 +33,7 @@ #include "Switch.hpp" #include "Network.hpp" #include "AntiRecursion.hpp" +#include "SelfAwareness.hpp" #include @@ -229,6 +230,24 @@ void Peer::pushDirectPaths(const RuntimeEnvironment *RR,RemotePath *path,uint64_ _lastDirectPathPush = now; std::vector dps(RR->node->directPaths()); + + /* Also push paths reported to us by non-root-server peers. This assists + * with NAT traversal behind NATs that engage in strange or randomized + * port assignment behavior. */ + std::vector
rootAddresses(RR->topology->rootAddresses()); + std::vector< std::pair > surface(RR->sa->getReportedSurface()); + for(std::vector< std::pair >::const_iterator s(surface.begin());s!=surface.end();++s) { + bool alreadyHave = false; + for(std::vector::const_iterator p(dps.begin());p!=dps.end();++p) { + if (p->address() == s->second) { + alreadyHave = true; + break; + } + } + if ((!alreadyHave)&&(std::find(rootAddresses.begin(),rootAddresses.end(),s->first) == rootAddresses.end())) + dps.push_back(Path(s->second,0,Path::TRUST_NORMAL)); + } + #ifdef ZT_TRACE { std::string ps; -- cgit v1.2.3 From e99eda4a4a178bbdbb419791587b581431061439 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 27 Jul 2015 17:28:13 -0700 Subject: Fix IP scoping bug, and disable remotely reported surface push... not helping. :( --- node/InetAddress.cpp | 2 +- node/Peer.cpp | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'node/Peer.cpp') diff --git a/node/InetAddress.cpp b/node/InetAddress.cpp index 91bfbed6..1942c4cd 100644 --- a/node/InetAddress.cpp +++ b/node/InetAddress.cpp @@ -74,7 +74,7 @@ InetAddress::IpScope InetAddress::ipScope() const if ((ip & 0xfff00000) == 0xac100000) return IP_SCOPE_PRIVATE; // 172.16.0.0/12 break; case 0xc0: - if ((ip & 0xffff0000) == 0xc9a80000) return IP_SCOPE_PRIVATE; // 192.168.0.0/16 + if ((ip & 0xffff0000) == 0xc0a80000) return IP_SCOPE_PRIVATE; // 192.168.0.0/16 break; case 0xff: return IP_SCOPE_NONE; // 255.0.0.0/8 (broadcast, or unused/unusable) default: diff --git a/node/Peer.cpp b/node/Peer.cpp index 804e6e39..ab3d61a6 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -226,15 +226,13 @@ void Peer::doPingAndKeepalive(const RuntimeEnvironment *RR,uint64_t now) void Peer::pushDirectPaths(const RuntimeEnvironment *RR,RemotePath *path,uint64_t now,bool force) { - if ((((now - _lastDirectPathPush) >= ZT_DIRECT_PATH_PUSH_INTERVAL)||(force))) { + if ((true)||(((now - _lastDirectPathPush) >= ZT_DIRECT_PATH_PUSH_INTERVAL)||(force))) { _lastDirectPathPush = now; std::vector dps(RR->node->directPaths()); - /* Also push paths reported to us by non-root-server peers. This assists - * with NAT traversal behind NATs that engage in strange or randomized - * port assignment behavior. */ - std::vector
rootAddresses(RR->topology->rootAddresses()); + // Push peer-reported surface -- tried this and it didn't help much with difficult NATs so commenting out. + /* std::vector< std::pair > surface(RR->sa->getReportedSurface()); for(std::vector< std::pair >::const_iterator s(surface.begin());s!=surface.end();++s) { bool alreadyHave = false; @@ -244,9 +242,10 @@ void Peer::pushDirectPaths(const RuntimeEnvironment *RR,RemotePath *path,uint64_ break; } } - if ((!alreadyHave)&&(std::find(rootAddresses.begin(),rootAddresses.end(),s->first) == rootAddresses.end())) + if (!alreadyHave) dps.push_back(Path(s->second,0,Path::TRUST_NORMAL)); } + */ #ifdef ZT_TRACE { -- cgit v1.2.3 From dda376c9eb0800b824f423db30399d93e89cb162 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 28 Jul 2015 11:16:43 -0700 Subject: Nuke some abandoned code. --- node/Peer.cpp | 16 ---------------- node/SelfAwareness.hpp | 15 --------------- 2 files changed, 31 deletions(-) (limited to 'node/Peer.cpp') diff --git a/node/Peer.cpp b/node/Peer.cpp index ab3d61a6..2bfd421f 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -231,22 +231,6 @@ void Peer::pushDirectPaths(const RuntimeEnvironment *RR,RemotePath *path,uint64_ std::vector dps(RR->node->directPaths()); - // Push peer-reported surface -- tried this and it didn't help much with difficult NATs so commenting out. - /* - std::vector< std::pair > surface(RR->sa->getReportedSurface()); - for(std::vector< std::pair >::const_iterator s(surface.begin());s!=surface.end();++s) { - bool alreadyHave = false; - for(std::vector::const_iterator p(dps.begin());p!=dps.end();++p) { - if (p->address() == s->second) { - alreadyHave = true; - break; - } - } - if (!alreadyHave) - dps.push_back(Path(s->second,0,Path::TRUST_NORMAL)); - } - */ - #ifdef ZT_TRACE { std::string ps; diff --git a/node/SelfAwareness.hpp b/node/SelfAwareness.hpp index 1b160a3f..4eede592 100644 --- a/node/SelfAwareness.hpp +++ b/node/SelfAwareness.hpp @@ -66,21 +66,6 @@ public: */ void clean(uint64_t now); - /** - * @return List of external surface addresses as reported by peers - */ - inline std::vector< std::pair > getReportedSurface() const - { - std::vector< std::pair > r; - { - Mutex::Lock _l(_phy_m); - r.reserve(_phy.size()); - for(std::map< PhySurfaceKey,PhySurfaceEntry >::const_iterator p(_phy.begin());p!=_phy.end();++p) - r.push_back(std::pair(p->first.reporter,p->second.mySurface)); - } - return r; - } - private: struct PhySurfaceKey { -- cgit v1.2.3 From 708aac1ea73a01fd81997a7215824dab832ba3d3 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 28 Jul 2015 11:43:09 -0700 Subject: Remove some left over debug code, and fix attempt to send to self if we are an active bridge. --- node/Multicaster.cpp | 16 ++++++++++------ node/Peer.cpp | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'node/Peer.cpp') diff --git a/node/Multicaster.cpp b/node/Multicaster.cpp index 33424e4a..489c170b 100644 --- a/node/Multicaster.cpp +++ b/node/Multicaster.cpp @@ -211,9 +211,11 @@ void Multicaster::send( unsigned int count = 0; for(std::vector
::const_iterator ast(alwaysSendTo.begin());ast!=alwaysSendTo.end();++ast) { - out.sendOnly(RR,*ast); - if (++count >= limit) - break; + if (*ast != RR->identity.address()) { + out.sendOnly(RR,*ast); + if (++count >= limit) + break; + } } unsigned long idx = 0; @@ -264,9 +266,11 @@ void Multicaster::send( unsigned int count = 0; for(std::vector
::const_iterator ast(alwaysSendTo.begin());ast!=alwaysSendTo.end();++ast) { - out.sendAndLog(RR,*ast); - if (++count >= limit) - break; + if (*ast != RR->identity.address()) { + out.sendAndLog(RR,*ast); + if (++count >= limit) + break; + } } unsigned long idx = 0; diff --git a/node/Peer.cpp b/node/Peer.cpp index 2bfd421f..3cf0ec4e 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -226,7 +226,7 @@ void Peer::doPingAndKeepalive(const RuntimeEnvironment *RR,uint64_t now) void Peer::pushDirectPaths(const RuntimeEnvironment *RR,RemotePath *path,uint64_t now,bool force) { - if ((true)||(((now - _lastDirectPathPush) >= ZT_DIRECT_PATH_PUSH_INTERVAL)||(force))) { + if (((now - _lastDirectPathPush) >= ZT_DIRECT_PATH_PUSH_INTERVAL)||(force)) { _lastDirectPathPush = now; std::vector dps(RR->node->directPaths()); -- cgit v1.2.3