mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-23 23:02:23 +00:00
Try +1 and +2 existing surfaces for symmetric NATs.
This commit is contained in:
parent
0c951b6e56
commit
772551c45d
@ -150,14 +150,24 @@ std::vector<InetAddress> SelfAwareness::getSymmetricNatPredictions()
|
|||||||
// More than one global IPv4 surface means this is a symmetric NAT
|
// More than one global IPv4 surface means this is a symmetric NAT
|
||||||
std::vector<InetAddress> r;
|
std::vector<InetAddress> r;
|
||||||
for(std::set<InetAddress>::iterator i(surfaces.begin());i!=surfaces.end();++i) {
|
for(std::set<InetAddress>::iterator i(surfaces.begin());i!=surfaces.end();++i) {
|
||||||
InetAddress nextPort(*i);
|
InetAddress ipp(*i);
|
||||||
unsigned int p = nextPort.port();
|
unsigned int p = ipp.port();
|
||||||
if (p >= 65535)
|
|
||||||
|
// Try 1+ surface ports
|
||||||
|
if (p >= 0xffff)
|
||||||
p = 1025;
|
p = 1025;
|
||||||
else ++p;
|
else ++p;
|
||||||
nextPort.setPort(p);
|
ipp.setPort(p);
|
||||||
if (surfaces.count(nextPort) == 0)
|
if ((surfaces.count(ipp) == 0)&&(std::find(r.begin(),r.end(),ipp) == r.end()))
|
||||||
r.push_back(nextPort);
|
r.push_back(ipp);
|
||||||
|
|
||||||
|
// Try 2+ 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);
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user