summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorJoseph Henry <josephjah@gmail.com>2019-07-09 10:31:03 -0700
committerJoseph Henry <josephjah@gmail.com>2019-07-09 10:31:03 -0700
commit389331ca2954d2fb602e8369349047adefbadd66 (patch)
treea85386deb7e628d16c49e3c71e7222b17c7fdf6c /service
parentb2c4b7e99fbb9cf7ea3e88813b22d73d4d799661 (diff)
downloadinfinitytier-389331ca2954d2fb602e8369349047adefbadd66.tar.gz
infinitytier-389331ca2954d2fb602e8369349047adefbadd66.zip
Ticket #915, added allowSecondaryPort to optionally force ZT to use a single port
Diffstat (limited to 'service')
-rw-r--r--service/OneService.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/service/OneService.cpp b/service/OneService.cpp
index 63ee3373..40ffce2f 100644
--- a/service/OneService.cpp
+++ b/service/OneService.cpp
@@ -475,6 +475,7 @@ public:
PhySocket *_localControlSocket6;
bool _updateAutoApply;
bool _allowTcpFallbackRelay;
+ bool _allowSecondaryPort;
unsigned int _multipathMode;
unsigned int _primaryPort;
unsigned int _secondaryPort;
@@ -722,16 +723,18 @@ public:
// This exists because there are buggy NATs out there that fail if more
// than one device behind the same NAT tries to use the same internal
// private address port number. Buggy NATs are a running theme.
- _ports[1] = (_secondaryPort == 0) ? 20000 + ((unsigned int)_node->address() % 45500) : _secondaryPort;
- for(int i=0;;++i) {
- if (i > 1000) {
- _ports[1] = 0;
- break;
- } else if (++_ports[1] >= 65536) {
- _ports[1] = 20000;
+ if (_allowSecondaryPort) {
+ _ports[1] = (_secondaryPort == 0) ? 20000 + ((unsigned int)_node->address() % 45500) : _secondaryPort;
+ for(int i=0;;++i) {
+ if (i > 1000) {
+ _ports[1] = 0;
+ break;
+ } else if (++_ports[1] >= 65536) {
+ _ports[1] = 20000;
+ }
+ if (_trialBind(_ports[1]))
+ break;
}
- if (_trialBind(_ports[1]))
- break;
}
#ifdef ZT_USE_MINIUPNPC
@@ -1603,6 +1606,7 @@ public:
_primaryPort = (unsigned int)OSUtils::jsonInt(settings["primaryPort"],(uint64_t)_primaryPort) & 0xffff;
_allowTcpFallbackRelay = OSUtils::jsonBool(settings["allowTcpFallbackRelay"],true);
+ _allowSecondaryPort = OSUtils::jsonBool(settings["allowSecondaryPort"],true);
_secondaryPort = (unsigned int)OSUtils::jsonInt(settings["secondaryPort"],0);
_tertiaryPort = (unsigned int)OSUtils::jsonInt(settings["tertiaryPort"],0);
if (_secondaryPort != 0 || _tertiaryPort != 0) {