From e9cd0a059c0985e16bdd64eeffb1791c1001088c Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 28 Jan 2022 14:21:37 -0800 Subject: [PATCH] setup: add OS version to user agent (#23656) --- selfdrive/ui/qt/setup/setup.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/qt/setup/setup.cc b/selfdrive/ui/qt/setup/setup.cc index 3117eb258d..17304665c7 100644 --- a/selfdrive/ui/qt/setup/setup.cc +++ b/selfdrive/ui/qt/setup/setup.cc @@ -10,13 +10,14 @@ #include +#include "selfdrive/common/util.h" #include "selfdrive/hardware/hw.h" #include "selfdrive/ui/qt/api.h" #include "selfdrive/ui/qt/qt_window.h" #include "selfdrive/ui/qt/offroad/networking.h" #include "selfdrive/ui/qt/widgets/input.h" -const char* USER_AGENT = "AGNOSSetup-0.1"; +const std::string USER_AGENT = "AGNOSSetup-"; const QString DASHCAM_URL = "https://dashcam.comma.ai"; void Setup::download(QString url) { @@ -26,6 +27,8 @@ void Setup::download(QString url) { return; } + auto version = util::read_file("/VERSION"); + char tmpfile[] = "/tmp/installer_XXXXXX"; FILE *fp = fdopen(mkstemp(tmpfile), "w"); @@ -34,7 +37,7 @@ void Setup::download(QString url) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); - curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT); + curl_easy_setopt(curl, CURLOPT_USERAGENT, (USER_AGENT + version).c_str()); int ret = curl_easy_perform(curl);