From 2756a5d2dd6e9363c65a504354fe5784a74b7d8c Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 8 Jun 2019 21:53:31 +0200 Subject: [PATCH] Fixed bootstrap file, VERIFY if bootstrap file is broken --- .../share/shared/bootstrap/bootstrap.json | 92 ++++++++++++------- src/blackcore/data/globalsetup.cpp | 21 ++++- src/blackcore/data/globalsetup.h | 1 + src/blackcore/setupreader.cpp | 18 +++- 4 files changed, 91 insertions(+), 41 deletions(-) diff --git a/resources/share/shared/bootstrap/bootstrap.json b/resources/share/shared/bootstrap/bootstrap.json index 6c63e5929..37629293b 100644 --- a/resources/share/shared/bootstrap/bootstrap.json +++ b/resources/share/shared/bootstrap/bootstrap.json @@ -6,61 +6,83 @@ "dbHttpPort": 80, "dbHttpsPort": 443, "dbRootDirectoryUrl": { - "url": "https://datastore.swift-project.net" + "url": "https://datastore.swift-project.org/" }, "development": false, - "mappingMinimumVersion" : "0.8.7", - "fsdTestServers": { - "containerbase": [] + "mapUrls": { + "containerbase": [ + { + "url": "http://map.swift-project.org" + } + ] + }, + "mappingMinimumVersion": "0.9.0", + "ncepGlobalForecastSystemUrl": { + "url": "http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p50.pl" + }, + "ncepGlobalForecastSystemUrl25": { + "url": "http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p25.pl" }, "newsUrls": { "containerbase": [ - { "url": "https://blog.swift-project.net/?__print__=1" }, - { "url": "https://dev.swift-project.org/phame/blog/view/1/?__print__=1" }] + { "url": "https://blog.swift-project.net/?__print__=1" }, + { "url": "https://dev.swift-project.org/phame/blog/view/1/?__print__=1" }] }, "onlineHelpUrls": { "containerbase": [ - { "url": "https://datastore.swift-project.net/page/swifthelpdispatcher.html" }, - { "url": "https://datastore.swift-project.org/page/swifthelpdispatcher.html" }] + { + "url": "https://datastore.swift-project.org/page/swifthelpdispatcher.html" + }, + { + "url": "https://datastore.swift-project.net/page/swifthelpdispatcher.html" + } + ] }, - "mapUrls": { - "containerbase": [{ - "url": "http://map.swift-project.org" - }] + "predefinedServers": { + "containerbase": [ + ] }, "sharedUrls": { "containerbase": [ - { "url": "https://datastore.swift-project.net/shared" }, - { "url": "https://datastore.swift-project.org/shared" }, - { "url": "http://www.siliconmind.de/datastore/shared" }, - { "url": "https://swift.fir-berlin.de/shared" }, - { "url": "https://swift.jarvum.de/shared" }, - { "url": "http://swift-project.org/datastore/shared" }] + { + "url": "https://datastore.swift-project.net/shared/" + }, + { + "url": "http://www.siliconmind.de/datastore/shared/" + }, + { + "url": "http://download.swift-project.org/shared/" + }, + { + "url": "https://swift.fir-berlin.de/shared" + } + ] }, - "timestampMSecsSinceEpoch": 1476907647000, + "timestampMSecsSinceEpoch": 1559602257000, "vatsimBookingsUrl": { "url": "http://vatbook.euroutepro.com/xml2.php" }, "vatsimDataFileUrls": { - "containerbase": [{ - "url": "http://info.vroute.net/vatsim-data.txt" - }] + "containerbase": [ + { + "url": "http://info.vroute.net/vatsim-data.txt" + } + ] }, "vatsimMetarsUrls": { - "containerbase": [{ - "url": "http://metar.vatsim.net/metar.php" - }] + "containerbase": [ + { + "url": "http://metar.vatsim.net/metar.php" + } + ] }, "vatsimStatusFileUrls": { - "containerbase": [{ - "url": "https://status.vatsim.net" - }] + "containerbase": [ + { + "url": "https://status.vatsim.net" + } + ] }, - "wasLoaded": true, - "ncepGlobalForecastSystemUrl": { - "url": "https://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p50.pl" - }, - "ncepGlobalForecastSystemUrl25": { - "url": "https://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p25.pl" - } + "wasLoadedFromFile": false, + "wasLoadedFromWeb": false } diff --git a/src/blackcore/data/globalsetup.cpp b/src/blackcore/data/globalsetup.cpp index 27b593760..58db9b8c5 100644 --- a/src/blackcore/data/globalsetup.cpp +++ b/src/blackcore/data/globalsetup.cpp @@ -54,14 +54,27 @@ namespace BlackCore { "https://datastore.swift-project.net/shared/", "http://www.siliconmind.de/datastore/shared/", - "http://download.swift-project.org/shared/" + "http://download.swift-project.org/shared/", + "https://swift.fir-berlin.de/shared" }); - m_newsUrls = CUrlList({ "http://swift-project.org/" }); - m_onlineHelpUrls = CUrlList({ "https://datastore.swift-project.org/page/swifthelpdispatcher.html" }); + m_newsUrls = CUrlList( + { + "https://blog.swift-project.net/?__print__=1", + "https://dev.swift-project.org/phame/blog/view/1/?__print__=1" + }); + m_onlineHelpUrls = CUrlList( + { + "https://datastore.swift-project.org/page/swifthelpdispatcher.html", + "https://datastore.swift-project.net/page/swifthelpdispatcher.html" + }); m_mapUrls = CUrlList({ "map.swift-project.org/" }); - m_ncepGlobalForecastSystemUrl = CUrl("http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p50.pl"); + m_ncepGlobalForecastSystemUrl = CUrl("http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p50.pl"); m_ncepGlobalForecastSystemUrl25 = CUrl("http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p25.pl"); + + // hardcoded based on RR's information + // https://discordapp.com/channels/539048679160676382/539925070550794240/586879411002015756 + m_crashReportServerUrl = CUrl(); } CUrl CGlobalSetup::getDbIcaoReaderUrl() const diff --git a/src/blackcore/data/globalsetup.h b/src/blackcore/data/globalsetup.h index c915119f0..5b6d3590d 100644 --- a/src/blackcore/data/globalsetup.h +++ b/src/blackcore/data/globalsetup.h @@ -109,6 +109,7 @@ namespace BlackCore bool hasSameType(const CGlobalSetup &otherSetup) const; //! Crash report server url + //! \deprecated NOT used anymore as by RR's info: https://discordapp.com/channels/539048679160676382/539925070550794240/586879411002015756 BlackMisc::Network::CUrl getCrashReportServerUrl() const { return m_crashReportServerUrl; } //! Root directory of DB diff --git a/src/blackcore/setupreader.cpp b/src/blackcore/setupreader.cpp index 0dddeb728..ab5a1eb13 100644 --- a/src/blackcore/setupreader.cpp +++ b/src/blackcore/setupreader.cpp @@ -18,6 +18,7 @@ #include "blackmisc/network/networkutils.h" #include "blackmisc/network/url.h" #include "blackmisc/statusmessage.h" +#include "blackconfig/buildconfig.h" #include #include @@ -29,6 +30,7 @@ #include #include +using namespace BlackConfig; using namespace BlackMisc; using namespace BlackMisc::Db; using namespace BlackMisc::Network; @@ -357,6 +359,7 @@ namespace BlackCore { CGlobalSetup s; s.convertFromJson(content); + s.markAsLoadedFromWeb(false); s.markAsLoadedFromFile(true); const CStatusMessage setMsg = m_setup.set(s); const CStatusMessage setInfo = CStatusMessage(this).info(u"Setup cache updated from local file '%1'") << fn; @@ -394,8 +397,19 @@ namespace BlackCore { const CGlobalSetup currentSetup = m_setup.get(); CGlobalSetup loadedSetup; - loadedSetup.convertFromJson(setupJson); - loadedSetup.markAsLoadedFromWeb(true); + loadedSetup.convertFromJson(setupJson, false); + loadedSetup.markAsLoadedFromFile(false); + + // make sure the file is not broken + const bool loadedFileBroken = (loadedSetup.getMappingMinimumVersionString() == CBuildConfig::getVersionString()) || loadedSetup.getMappingMinimumVersionString().isEmpty(); + loadedSetup.markAsLoadedFromWeb(!loadedFileBroken); + BLACK_VERIFY_X(!loadedFileBroken, Q_FUNC_INFO, "Appears that the bootstrap file is not really parsed"); + if (loadedFileBroken) + { + CLogMessage(this).warning(u"Setup file downloaded from '%1' seems to be broken! Ignoring it.") << urlString; + return; + } + const CUrl sharedUrl(loadedSetup.getCorrespondingSharedUrl(url)); if (!sharedUrl.isEmpty()) { emit this->successfullyReadSharedUrl(sharedUrl); }