@@ -31,10 +31,27 @@ CurrentVersionFetcher::CurrentVersionFetcher(QObject* parent) : QObject(parent),
3131 connect (manager_.get (), SIGNAL (finished (QNetworkReply*)), this , SLOT (reply (QNetworkReply*)));
3232}
3333
34- void CurrentVersionFetcher::fetchCurrentVersion (QString url)
34+ static const QString versionMirrors[] = {
35+ " https://cdn.unvanquished.net/" ,
36+ " https://cdn.illwieckz.net/unvanquished/" ,
37+ " https://webseed.unv.kangz.net/" ,
38+ nullptr ,
39+ };
40+
41+ static const QString *versionMirror = &versionMirrors[0 ];
42+
43+ void CurrentVersionFetcher::fetchCurrentVersion ()
3544{
36- QNetworkRequest request = QNetworkRequest (QUrl (url));
37- manager_->get (request);
45+ static const QString versionFile = " current.json" ;
46+
47+ if (versionMirror)
48+ {
49+ QString versionURL = versionMirror + versionFile;
50+ qDebug () << " Fetching" << versionURL;
51+ QNetworkRequest request = QNetworkRequest (QUrl (versionURL));
52+ manager_->get (request);
53+ versionMirror++;
54+ }
3855}
3956
4057void ComponentVersionFetcher (QJsonObject jsonObject, QString componentSlug, QString componentSystem, QString *componentVersion, QString *componentUrl)
@@ -117,7 +134,12 @@ void CurrentVersionFetcher::reply(QNetworkReply* reply)
117134
118135 if (reply->error () != QNetworkReply::NoError) {
119136 qDebug () << " CurrentVersionFetcher: network error" ;
120- emit onCurrentVersions (updaterVersion, updaterUrl, gameVersion, gameUrl, newsUrl);
137+
138+ if (versionMirror) {
139+ fetchCurrentVersion ();
140+ } else {
141+ emit onCurrentVersions (updaterVersion, updaterUrl, gameVersion, gameUrl, newsUrl);
142+ }
121143 return ;
122144 }
123145
0 commit comments