From 93a09024ab433c866e87c5a6e33f982d7e8e32ab Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 26 Aug 2019 14:57:51 +0300 Subject: unified fake User-Agent field generation for all http-related protocols --- src/mir_app/src/mir_app.def | 1 + src/mir_app/src/mir_app64.def | 1 + src/mir_app/src/netlib.cpp | 13 +++++++++++++ 3 files changed, 15 insertions(+) (limited to 'src/mir_app') diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index b44be34fa0..7f11bd20b9 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -273,6 +273,7 @@ Miranda_OkToExit @344 Miranda_GetVersion @345 Miranda_GetFileVersion @346 Miranda_GetVersionText @347 +Netlib_GetUserAgent @348 Netlib_CloseHandle @349 Netlib_Recv @350 Netlib_Send @351 diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index a41e448502..375f32fc0c 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -273,6 +273,7 @@ Miranda_OkToExit @344 Miranda_GetVersion @345 Miranda_GetFileVersion @346 Miranda_GetVersionText @347 +Netlib_GetUserAgent @348 Netlib_CloseHandle @349 Netlib_Recv @350 Netlib_Send @351 diff --git a/src/mir_app/src/netlib.cpp b/src/mir_app/src/netlib.cpp index 287bd4f194..8dee6ff88f 100644 --- a/src/mir_app/src/netlib.cpp +++ b/src/mir_app/src/netlib.cpp @@ -31,6 +31,7 @@ HANDLE hConnectionHeaderMutex, hConnectionOpenMutex, hEventConnected = NULL, hEv DWORD g_LastConnectionTick; int connectionTimeout; HANDLE hSendEvent = nullptr, hRecvEvent = nullptr; +static char szUserAgent[100]; typedef BOOL(WINAPI *tGetProductInfo)(DWORD, DWORD, DWORD, DWORD, PDWORD); @@ -388,6 +389,13 @@ MIR_APP_DLL(HNETLIBUSER) Netlib_GetConnNlu(HANDLE hConn) ///////////////////////////////////////////////////////////////////////////////////////// +MIR_APP_DLL(char*) Netlib_GetUserAgent() +{ + return szUserAgent; +} + +///////////////////////////////////////////////////////////////////////////////////////// + MIR_APP_DLL(void) Netlib_Shutdown(HNETLIBCONN h) { if (h) { @@ -491,6 +499,11 @@ int LoadNetlibModule(void) } } + #define FAKE_VER "68.0.1" + char osVer[100]; + OS_GetShortString(osVer, _countof(osVer)); + mir_snprintf(szUserAgent, "Mozilla/5.0 (%s; rv:%s) Gecko/20100101 Firefox/%s", osVer, FAKE_VER, FAKE_VER); + hConnectionOpenMutex = connectionTimeout ? CreateMutex(nullptr, FALSE, nullptr) : nullptr; g_LastConnectionTick = GetTickCount(); -- cgit v1.2.3