mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-30 01:38:53 +00:00
Add a portMappingEnabled flag to local.conf to allow uPnP/NAT-PMP to be disabled.
This commit is contained in:
parent
56e5b34934
commit
89d74cd293
@ -344,6 +344,7 @@ public:
|
||||
Mutex _termReason_m;
|
||||
|
||||
// uPnP/NAT-PMP port mapper if enabled
|
||||
bool _portMappingEnabled; // local.conf settings
|
||||
#ifdef ZT_USE_MINIUPNPC
|
||||
PortMapper *_portMapper;
|
||||
#endif
|
||||
@ -379,6 +380,7 @@ public:
|
||||
,_nextBackgroundTaskDeadline(0)
|
||||
,_tcpFallbackTunnel((TcpConnection *)0)
|
||||
,_termReason(ONE_STILL_RUNNING)
|
||||
,_portMappingEnabled(true)
|
||||
#ifdef ZT_USE_MINIUPNPC
|
||||
,_portMapper((PortMapper *)0)
|
||||
#endif
|
||||
@ -598,6 +600,7 @@ public:
|
||||
}
|
||||
|
||||
#ifdef ZT_USE_MINIUPNPC
|
||||
if (_portMappingEnabled) {
|
||||
// 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
|
||||
// stuff with ports that are explicitly mapped that breaks things.
|
||||
@ -619,6 +622,7 @@ public:
|
||||
_portMapper = new PortMapper(_ports[2],uniqueName);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Populate ports in big-endian format for quick compare
|
||||
@ -983,6 +987,8 @@ public:
|
||||
_interfacePrefixBlacklist.clear();
|
||||
json &settings = _localConfig["settings"];
|
||||
if (settings.is_object()) {
|
||||
_portMappingEnabled = OSUtils::jsonBool(settings["portMappingEnabled"],true);
|
||||
|
||||
const std::string rp(OSUtils::jsonString(settings["relayPolicy"],""));
|
||||
if ((rp == "always")||(rp == "ALWAYS"))
|
||||
_node->setRelayPolicy(ZT_RELAY_POLICY_ALWAYS);
|
||||
|
Loading…
Reference in New Issue
Block a user