summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-02-11 10:39:39 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-02-11 10:39:39 -0800
commit772551c45da254c221ae9237423c7adb3978190e (patch)
tree43d3a8bb0836f05b5f80f3493978cfc81f01e389 /node
parent0c951b6e56db47f2be4850343ae3908d0ea83099 (diff)
downloadinfinitytier-772551c45da254c221ae9237423c7adb3978190e.tar.gz
infinitytier-772551c45da254c221ae9237423c7adb3978190e.zip
Try +1 and +2 existing surfaces for symmetric NATs.
Diffstat (limited to 'node')
-rw-r--r--node/SelfAwareness.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/node/SelfAwareness.cpp b/node/SelfAwareness.cpp
index cf43a644..dde77ee5 100644
--- a/node/SelfAwareness.cpp
+++ b/node/SelfAwareness.cpp
@@ -150,14 +150,24 @@ std::vector<InetAddress> SelfAwareness::getSymmetricNatPredictions()
// More than one global IPv4 surface means this is a symmetric NAT
std::vector<InetAddress> r;
for(std::set<InetAddress>::iterator i(surfaces.begin());i!=surfaces.end();++i) {
- InetAddress nextPort(*i);
- unsigned int p = nextPort.port();
- if (p >= 65535)
+ InetAddress ipp(*i);
+ unsigned int p = ipp.port();
+
+ // Try 1+ surface ports
+ if (p >= 0xffff)
+ p = 1025;
+ else ++p;
+ ipp.setPort(p);
+ if ((surfaces.count(ipp) == 0)&&(std::find(r.begin(),r.end(),ipp) == r.end()))
+ r.push_back(ipp);
+
+ // Try 2+ surface ports
+ if (p >= 0xffff)
p = 1025;
else ++p;
- nextPort.setPort(p);
- if (surfaces.count(nextPort) == 0)
- r.push_back(nextPort);
+ ipp.setPort(p);
+ if ((surfaces.count(ipp) == 0)&&(std::find(r.begin(),r.end(),ipp) == r.end()))
+ r.push_back(ipp);
}
return r;
}