diff options
author | Joseph Henry <josephjah@gmail.com> | 2018-05-01 13:39:06 -0700 |
---|---|---|
committer | Joseph Henry <josephjah@gmail.com> | 2018-05-01 13:39:06 -0700 |
commit | 836d897aecc193ec3477e67858237a3f97819024 (patch) | |
tree | 154a6059b97ddb4a0c1005215b5cf1bf6aae0ec0 /service | |
parent | 740b0fbbf6e33caf1bd07c866bfdc4e59cb028c2 (diff) | |
download | infinitytier-836d897aecc193ec3477e67858237a3f97819024.tar.gz infinitytier-836d897aecc193ec3477e67858237a3f97819024.zip |
Re-ordered local.conf and node init logic, also split software update config into separate method to fix bad node pointer reference
Diffstat (limited to 'service')
-rw-r--r-- | service/OneService.cpp | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/service/OneService.cpp b/service/OneService.cpp index e7229717..80b42818 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -591,10 +591,9 @@ public: } // Read local configuration + std::map<InetAddress,ZT_PhysicalPathConfiguration> ppc; std::vector<InetAddress> explicitBind; { - std::map<InetAddress,ZT_PhysicalPathConfiguration> ppc; - // LEGACY: support old "trustedpaths" flat file FILE *trustpaths = fopen((_homePath + ZT_PATH_SEPARATOR_S "trustedpaths").c_str(),"r"); if (trustpaths) { @@ -673,12 +672,6 @@ public: } } } - - // Set trusted paths if there are any - if (ppc.size() > 0) { - for(std::map<InetAddress,ZT_PhysicalPathConfiguration>::iterator i(ppc.begin());i!=ppc.end();++i) - _node->setPhysicalPathConfiguration(reinterpret_cast<const struct sockaddr_storage *>(&(i->first)),&(i->second)); - } } // Apply other runtime configuration from local.conf @@ -698,6 +691,16 @@ public: _node = new Node(this, (void *)0, &cb, OSUtils::now()); } + // Apply software update specific configuration from local.conf + applySoftwareUpdateLocalConfig(); + + // Set trusted paths if there are any + if (ppc.size() > 0) { + for(std::map<InetAddress,ZT_PhysicalPathConfiguration>::iterator i(ppc.begin());i!=ppc.end();++i) + _node->setPhysicalPathConfiguration(reinterpret_cast<const struct sockaddr_storage *>(&(i->first)),&(i->second)); + } + ppc.clear(); + // Make sure we can use the primary port, and hunt for one if configured to do so const int portTrials = (_primaryPort == 0) ? 256 : 1; // if port is 0, pick random for(int k=0;k<portTrials;++k) { @@ -1517,22 +1520,6 @@ public: _allowTcpFallbackRelay = OSUtils::jsonBool(settings["allowTcpFallbackRelay"],true); _portMappingEnabled = OSUtils::jsonBool(settings["portMappingEnabled"],true); -#ifndef ZT_SDK - const std::string up(OSUtils::jsonString(settings["softwareUpdate"],ZT_SOFTWARE_UPDATE_DEFAULT)); - const bool udist = OSUtils::jsonBool(settings["softwareUpdateDist"],false); - if (((up == "apply")||(up == "download"))||(udist)) { - if (!_updater) - _updater = new SoftwareUpdater(*_node,_homePath); - _updateAutoApply = (up == "apply"); - _updater->setUpdateDistribution(udist); - _updater->setChannel(OSUtils::jsonString(settings["softwareUpdateChannel"],ZT_SOFTWARE_UPDATE_DEFAULT_CHANNEL)); - } else { - delete _updater; - _updater = (SoftwareUpdater *)0; - _updateAutoApply = false; - } -#endif - json &ignoreIfs = settings["interfacePrefixBlacklist"]; if (ignoreIfs.is_array()) { for(unsigned long i=0;i<ignoreIfs.size();++i) { @@ -1593,6 +1580,27 @@ public: #endif } + void applySoftwareUpdateLocalConfig() + { +#ifndef ZT_SDK + json lc(_localConfig); + json &settings = lc["settings"]; + const std::string up(OSUtils::jsonString(settings["softwareUpdate"],ZT_SOFTWARE_UPDATE_DEFAULT)); + const bool udist = OSUtils::jsonBool(settings["softwareUpdateDist"],false); + if (((up == "apply")||(up == "download"))||(udist)) { + if (!_updater) + _updater = new SoftwareUpdater(*_node,_homePath); + _updateAutoApply = (up == "apply"); + _updater->setUpdateDistribution(udist); + _updater->setChannel(OSUtils::jsonString(settings["softwareUpdateChannel"],ZT_SOFTWARE_UPDATE_DEFAULT_CHANNEL)); + } else { + delete _updater; + _updater = (SoftwareUpdater *)0; + _updateAutoApply = false; + } +#endif + } + // Checks if a managed IP or route target is allowed bool checkIfManagedIsAllowed(const NetworkState &n,const InetAddress &target) { |