summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Bingner <sam@bingner.com>2020-02-21 23:34:30 -1000
committerSam Bingner <sam@bingner.com>2020-07-17 00:22:23 -1000
commitbafc29f02ad6397c42b19ab7f97c5bf8072b6d7a (patch)
tree949c7d6f43b90be7afc777ecdfb387fe362b6909
parentc0c15a15b076daa2dda326fa3d0c99bedab353aa (diff)
Update User-Agent string
-rw-r--r--methods/http.cc32
1 files changed, 27 insertions, 5 deletions
diff --git a/methods/http.cc b/methods/http.cc
index 508cf5727..e52318055 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -59,9 +59,12 @@ using namespace std;
#define _(str) str
-CFStringRef Firmware_;
-const char *Machine_;
-CFStringRef UniqueID_;
+CFStringRef Firmware_ = NULL;
+CFStringRef Product_ = NULL;
+CFStringRef Arch_ = NULL;
+const char *Machine_ = NULL;
+CFStringRef UniqueID_ = NULL;
+CFStringRef UserAgent_ = NULL;
void CfrsError(const char *name, CFReadStreamRef rs) {
CFStreamError se = CFReadStreamGetError(rs);
@@ -341,7 +344,7 @@ int HttpMethod::Loop()
if (UniqueID_ != NULL)
CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Unique-ID"), UniqueID_);
- CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("User-Agent"), CFSTR("Telesphoreo APT-HTTP/1.0.592"));
+ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("User-Agent"), UserAgent_);
#if TARGET_OS_TV
if (isNito) {
@@ -646,13 +649,16 @@ int main(int, const char *argv[])
if (plist != NULL) {
Firmware_ = (CFStringRef) CFRetain(CFDictionaryGetValue((CFDictionaryRef) plist, CFSTR("ProductVersion")));
+ Product_ = (CFStringRef) CFRetain(CFDictionaryGetValue((CFDictionaryRef) plist, CFSTR("ProductName")));
CFRelease(plist);
}
if (UniqueID_ == NULL)
if (void *libMobileGestalt = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY))
- if (CFStringRef (*$MGCopyAnswer)(CFStringRef) = (CFStringRef (*)(CFStringRef)) dlsym(libMobileGestalt, "MGCopyAnswer"))
+ if (CFStringRef (*$MGCopyAnswer)(CFStringRef) = (CFStringRef (*)(CFStringRef)) dlsym(libMobileGestalt, "MGCopyAnswer")) {
UniqueID_ = $MGCopyAnswer(CFSTR("UniqueDeviceID"));
+ Arch_ = $MGCopyAnswer(CFSTR("CPUArchitecture"));
+ }
if (UniqueID_ == NULL)
if (void *lockdown = lockdown_connect()) {
@@ -660,6 +666,22 @@ int main(int, const char *argv[])
lockdown_disconnect(lockdown);
}
+ if (Arch_ == NULL)
+ Arch_ = CFSTR("Unknown");
+
+ if (Firmware_ == NULL)
+ Firmware_ = CFSTR("Unknown");
+
+ if (Product_ == NULL)
+ Product_ = CFSTR("Unknown");
+
+ if (UniqueID_ == NULL)
+ UniqueID_ = CFSTR("Unknown");
+
+ UserAgent_ = CFStringCreateWithFormat(NULL, NULL, CFSTR("Telesphoreo APT/%s (Darwin; %@ %@; %@; Elucubratus)"), PACKAGE_VERSION, Product_, Firmware_, Arch_);
+ if (UserAgent_ == NULL)
+ UserAgent_ = CFSTR("Telesphoreo APT/" PACKAGE_VERSION " (Darwin; Unknown Unknown; Unknown; Elucubratus)");
+
std::string Binary = flNotDir(argv[0]);
if (Binary.find('+') == std::string::npos && Binary != "https" && Binary != "http")
Binary.append("+http");