Skip to content

Commit

Permalink
VPN-5588 Add OS Version to balrog requests (#9688)
Browse files Browse the repository at this point in the history
* Pass OS version to balrog

* lint

* Fix win build
  • Loading branch information
strseb committed Jun 25, 2024
1 parent b3097fc commit 920492d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
9 changes: 1 addition & 8 deletions src/platforms/windows/windowsutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ namespace {
Logger logger("WindowsUtils");
} // namespace

constexpr const int WINDOWS_11_BUILD =
22000; // Build Number of the first release win 11 iso

QString WindowsUtils::getErrorMessage(quint32 code) {
LPSTR messageBuffer = nullptr;
size_t size = FormatMessageA(
Expand Down Expand Up @@ -49,11 +46,7 @@ QString WindowsUtils::windowsVersion() {
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
QSettings::NativeFormat);

int buildNr = regCurrentVersion.value("CurrentBuild").toInt();
if (buildNr >= WINDOWS_11_BUILD) {
return "11";
}
return QSysInfo::productVersion();
return regCurrentVersion.value("CurrentBuild").toString();
}

// static
Expand Down
17 changes: 9 additions & 8 deletions src/update/balrog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <QSslKey>

#include "constants.h"
#include "env.h"
#include "errorhandler.h"
#include "feature/feature.h"
#include "glean/generated/metrics.h"
Expand All @@ -38,9 +39,9 @@ bool verify_content_signature(const char* x5u_ptr, size_t x5u_length,
}

#if defined(MZ_WINDOWS)
constexpr const char* BALROG_WINDOWS_UA = "WINNT_x86_64";
constexpr const char* BALROG_WINDOWS_BUILD_TARGET = "WINNT_x86_64";
#elif defined(MZ_MACOS)
constexpr const char* BALROG_MACOS_UA = "Darwin_x86";
constexpr const char* BALROG_MACOS_BUILD_TARGET = "Darwin_x86";
#else
# error Platform not supported yet
#endif
Expand Down Expand Up @@ -70,13 +71,13 @@ Balrog::~Balrog() {
}

// static
QString Balrog::userAgent() {
QString Balrog::buildTarget() {
#if defined(MZ_WINDOWS)
return BALROG_WINDOWS_UA;
return BALROG_WINDOWS_BUILD_TARGET;
#elif defined(MZ_MACOS)
return BALROG_MACOS_UA;
return BALROG_MACOS_BUILD_TARGET;
#else
# error Unsupported platform
# error Balrog: Unsupported platform
#endif
}

Expand Down Expand Up @@ -502,8 +503,8 @@ QString Balrog::balrogUrl() {
channel = "release-cdntest";
}

QStringList path = {"json", "1", product, appVersion(),
userAgent(), channel, "update.json"};
QStringList path = {"json", "2", product, appVersion(),
buildTarget(), channel, Env::osVersion(), "update.json"};
QUrl url;
url.setScheme("https");
url.setHost(hostname);
Expand Down
3 changes: 1 addition & 2 deletions src/update/balrog.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class Balrog final : public Updater {
void start(Task* task) override;

private:
static QString userAgent();

bool processData(Task* task, const QByteArray& data);
bool fetchSignature(Task* task, NetworkRequest* request,
const QByteArray& data);
Expand All @@ -44,6 +42,7 @@ class Balrog final : public Updater {
QNetworkReply::NetworkError error);

private:
static QString buildTarget();
static QString balrogUrl();
static QStringList rootCertHashes();
TemporaryDir m_tmpDir;
Expand Down

0 comments on commit 920492d

Please sign in to comment.