mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
Bugfix for incorrect port binding of secondary and tertiary ports
This commit is contained in:
parent
088dab4f04
commit
e1e27eb19d
1 changed files with 31 additions and 25 deletions
|
@ -678,7 +678,10 @@ public:
|
||||||
// than one device behind the same NAT tries to use the same internal
|
// than one device behind the same NAT tries to use the same internal
|
||||||
// private address port number. Buggy NATs are a running theme.
|
// private address port number. Buggy NATs are a running theme.
|
||||||
if (_allowSecondaryPort) {
|
if (_allowSecondaryPort) {
|
||||||
_ports[1] = (_secondaryPort == 0) ? 20000 + ((unsigned int)_node->address() % 45500) : _secondaryPort;
|
if (_secondaryPort) {
|
||||||
|
_ports[1] = _secondaryPort;
|
||||||
|
} else {
|
||||||
|
_ports[1] = 20000 + ((unsigned int)_node->address() % 45500);
|
||||||
for(int i=0;;++i) {
|
for(int i=0;;++i) {
|
||||||
if (i > 1000) {
|
if (i > 1000) {
|
||||||
_ports[1] = 0;
|
_ports[1] = 0;
|
||||||
|
@ -690,14 +693,17 @@ public:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#ifdef ZT_USE_MINIUPNPC
|
#ifdef ZT_USE_MINIUPNPC
|
||||||
if (_portMappingEnabled) {
|
if (_portMappingEnabled) {
|
||||||
// If we're running uPnP/NAT-PMP, bind a *third* port for that. We can't
|
// If we're running uPnP/NAT-PMP, bind a *third* port for that. We can't
|
||||||
// use the other two ports for that because some NATs do really funky
|
// use the other two ports for that because some NATs do really funky
|
||||||
// stuff with ports that are explicitly mapped that breaks things.
|
// stuff with ports that are explicitly mapped that breaks things.
|
||||||
if (_ports[1]) {
|
if (_ports[1]) {
|
||||||
_ports[2] = (_tertiaryPort == 0) ? _ports[1] : _tertiaryPort;
|
if (_tertiaryPort) {
|
||||||
|
_ports[2] = _tertiaryPort;
|
||||||
|
} else {
|
||||||
|
_ports[2] = _ports[1];
|
||||||
for(int i=0;;++i) {
|
for(int i=0;;++i) {
|
||||||
if (i > 1000) {
|
if (i > 1000) {
|
||||||
_ports[2] = 0;
|
_ports[2] = 0;
|
||||||
|
@ -715,7 +721,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
|
||||||
// Delete legacy iddb.d if present (cleanup)
|
// Delete legacy iddb.d if present (cleanup)
|
||||||
OSUtils::rmDashRf((_homePath + ZT_PATH_SEPARATOR_S "iddb.d").c_str());
|
OSUtils::rmDashRf((_homePath + ZT_PATH_SEPARATOR_S "iddb.d").c_str());
|
||||||
|
|
Loading…
Add table
Reference in a new issue