diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-01-13 12:13:14 -0800 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-01-13 12:13:14 -0800 |
commit | f81c67c0f0f0d1dae38fffd053bbbca90aabc2b2 (patch) | |
tree | e4a63f4c9cefb77c59a1c897143da2724ea6f97d | |
parent | 3a730c4a5ca68fdceb0acc9152b7e51812d656e7 (diff) | |
download | infinitytier-f81c67c0f0f0d1dae38fffd053bbbca90aabc2b2.tar.gz infinitytier-f81c67c0f0f0d1dae38fffd053bbbca90aabc2b2.zip |
Make sure to respond to GET_LATEST with the actual latest.
-rw-r--r-- | service/SoftwareUpdater.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/service/SoftwareUpdater.cpp b/service/SoftwareUpdater.cpp index 017e4f00..4be671c7 100644 --- a/service/SoftwareUpdater.cpp +++ b/service/SoftwareUpdater.cpp @@ -145,6 +145,9 @@ void SoftwareUpdater::handleSoftwareUpdateUserMessage(uint64_t origin,const void if (_dist.size() > 0) { const nlohmann::json *latest = (const nlohmann::json *)0; const std::string expectedSigner = OSUtils::jsonString(req[ZT_SOFTWARE_UPDATE_JSON_EXPECT_SIGNED_BY],""); + unsigned int bestVMaj = rvMaj; + unsigned int bestVMin = rvMin; + unsigned int bestVRev = rvRev; for(std::map< Array<uint8_t,16>,_D >::const_iterator d(_dist.begin());d!=_dist.end();++d) { if ((OSUtils::jsonInt(d->second.meta[ZT_SOFTWARE_UPDATE_JSON_PLATFORM],0) == rvPlatform)&& (OSUtils::jsonInt(d->second.meta[ZT_SOFTWARE_UPDATE_JSON_ARCHITECTURE],0) == rvArch)&& @@ -154,8 +157,11 @@ void SoftwareUpdater::handleSoftwareUpdateUserMessage(uint64_t origin,const void const unsigned int dvMaj = (unsigned int)OSUtils::jsonInt(d->second.meta[ZT_SOFTWARE_UPDATE_JSON_VERSION_MAJOR],0); const unsigned int dvMin = (unsigned int)OSUtils::jsonInt(d->second.meta[ZT_SOFTWARE_UPDATE_JSON_VERSION_MINOR],0); const unsigned int dvRev = (unsigned int)OSUtils::jsonInt(d->second.meta[ZT_SOFTWARE_UPDATE_JSON_VERSION_REVISION],0); - if (Utils::compareVersion(dvMaj,dvMin,dvRev,rvMaj,rvMin,rvRev) > 0) { + if (Utils::compareVersion(dvMaj,dvMin,dvRev,bestVMaj,bestVMin,bestVRev) > 0) { latest = &(d->second.meta); + bestVMaj = dvMaj; + bestVMin = dvMin; + bestVRev = dvRev; } } } |