Skip to content

Commit

Permalink
setup: add OS version to user agent (#23656)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh committed Jan 28, 2022
1 parent 95caa5f commit e9cd0a0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions selfdrive/ui/qt/setup/setup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@

#include <curl/curl.h>

#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) {
Expand All @@ -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");

Expand All @@ -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);

Expand Down

0 comments on commit e9cd0a0

Please sign in to comment.