mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Minimize data sent in the default user agent (#14851)
This commit is contained in:
parent
eba0806d77
commit
a7a719261e
3 changed files with 37 additions and 6 deletions
|
@ -50,6 +50,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#endif
|
||||
#if defined(__ANDROID__)
|
||||
#include "porting_android.h"
|
||||
#include <android/api-level.h>
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
#include <mach-o/dyld.h>
|
||||
|
@ -205,7 +206,10 @@ bool detectMSVCBuildDir(const std::string &path)
|
|||
return (!removeStringEnd(path, ends).empty());
|
||||
}
|
||||
|
||||
std::string get_sysinfo()
|
||||
// Note that the system info is sent in every HTTP request, so keep it reasonably
|
||||
// privacy-conserving while ideally still being meaningful.
|
||||
|
||||
static std::string detectSystemInfo()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::ostringstream oss;
|
||||
|
@ -251,14 +255,34 @@ std::string get_sysinfo()
|
|||
delete[] filePath;
|
||||
|
||||
return oss.str();
|
||||
#else
|
||||
#elif defined(__ANDROID__)
|
||||
std::ostringstream oss;
|
||||
struct utsname osinfo;
|
||||
uname(&osinfo);
|
||||
return std::string(osinfo.sysname) + "/"
|
||||
+ osinfo.release + " " + osinfo.machine;
|
||||
int api = android_get_device_api_level();
|
||||
|
||||
oss << "Android/" << api << " " << osinfo.machine;
|
||||
return oss.str();
|
||||
#else /* POSIX */
|
||||
struct utsname osinfo;
|
||||
uname(&osinfo);
|
||||
|
||||
std::string_view release(osinfo.release);
|
||||
// cut off anything but the primary version number
|
||||
release = release.substr(0, release.find_first_not_of("0123456789."));
|
||||
|
||||
std::string ret = osinfo.sysname;
|
||||
ret.append("/").append(release).append(" ").append(osinfo.machine);
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
const std::string &get_sysinfo()
|
||||
{
|
||||
static std::string ret = detectSystemInfo();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool getCurrentWorkingDir(char *buf, size_t len)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue