diff options
-rw-r--r-- | include/m_netlib.h | 5 | ||||
-rw-r--r-- | libs/win32/mir_app.lib | bin | 193122 -> 193362 bytes | |||
-rw-r--r-- | libs/win64/mir_app.lib | bin | 188896 -> 189116 bytes | |||
-rw-r--r-- | plugins/PluginUpdater/src/Utils.cpp | 6 | ||||
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/main.cpp | 5 | ||||
-rw-r--r-- | protocols/FacebookRM/src/stdafx.h | 1 | ||||
-rw-r--r-- | protocols/Omegle/src/communication.cpp | 2 | ||||
-rw-r--r-- | protocols/Omegle/src/main.cpp | 22 | ||||
-rw-r--r-- | protocols/Omegle/src/stdafx.h | 1 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/netlib.cpp | 13 |
13 files changed, 26 insertions, 33 deletions
diff --git a/include/m_netlib.h b/include/m_netlib.h index 5225186f85..21b6389c5a 100644 --- a/include/m_netlib.h +++ b/include/m_netlib.h @@ -374,6 +374,11 @@ EXTERN_C MIR_APP_DLL(UINT_PTR) Netlib_GetSocket(HNETLIBCONN hConnection); EXTERN_C MIR_APP_DLL(HNETLIBUSER) Netlib_GetConnNlu(HNETLIBCONN hConn);
/////////////////////////////////////////////////////////////////////////////////////////
+// Gets the fake User-Agent header field to make some sites happy
+
+EXTERN_C MIR_APP_DLL(char*) Netlib_GetUserAgent();
+
+/////////////////////////////////////////////////////////////////////////////////////////
// Converts numerical representation of IP in SOCKADDR_INET into string representation with IP and port
// IPv4 will be supplied in formats address:port or address
// IPv6 will be supplied in formats [address]:port or [address]
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 2a12a5df85..c98945bac0 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex b191c493f2..b8572e7c40 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 335a85b5f6..9c991c3462 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -228,10 +228,12 @@ bool DownloadFile(FILEURL *pFileURL, HNETLIBCONN &nlc) *p = 0;
rtrim(szMirVer);
- int osVer = LOWORD(GetVersion());
+ char szOsVer[100];
+ OS_GetShortString(szOsVer, _countof(szOsVer));
+
CMStringA szUserAgent("Miranda NG/");
szUserAgent.Append(szMirVer);
- szUserAgent.AppendFormat(" (Windows NT %d.%d", LOBYTE(osVer), HIBYTE(osVer));
+ szUserAgent.AppendFormat(" (%s", szOsVer);
#ifdef _WIN64
szUserAgent.Append("; Win64; x64");
#endif
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 7d0dfaa86f..3b9f97d235 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -47,7 +47,7 @@ http::response facebook_client::sendRequest(HttpRequest *request) request->AddHeader("Accept-Language", "en,en-US;q=0.9"); request->AddHeader("Accept", "*/*"); - request->AddHeader("User-Agent", g_strUserAgent.c_str()); + request->AddHeader("User-Agent", Netlib_GetUserAgent()); request->AddHeader("Cookie", ptrA(load_cookies())); // FIXME: Rework load_cookies to not do strdup if (request->requestType == REQUEST_POST) diff --git a/protocols/FacebookRM/src/main.cpp b/protocols/FacebookRM/src/main.cpp index b309767406..bf80befe1c 100644 --- a/protocols/FacebookRM/src/main.cpp +++ b/protocols/FacebookRM/src/main.cpp @@ -24,7 +24,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. CMPlugin g_plugin;
-std::string g_strUserAgent;
DWORD g_mirandaVersion;
bool g_bMessageState;
HWND g_hwndHeartbeat;
@@ -75,12 +74,8 @@ int CMPlugin::Load() InitIcons();
InitContactMenus();
- // Init native User-Agent
- g_strUserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Firefox/52.0";
-
// Initialize random generator (used only as fallback in utils)
srand(::time(0));
-
return 0;
}
diff --git a/protocols/FacebookRM/src/stdafx.h b/protocols/FacebookRM/src/stdafx.h index 3a96f387de..75241dfa99 100644 --- a/protocols/FacebookRM/src/stdafx.h +++ b/protocols/FacebookRM/src/stdafx.h @@ -79,7 +79,6 @@ class FacebookProto; #include "resource.h"
#include "version.h"
-extern std::string g_strUserAgent;
extern DWORD g_mirandaVersion;
extern bool g_bMessageState;
extern HWND g_hwndHeartbeat;
diff --git a/protocols/Omegle/src/communication.cpp b/protocols/Omegle/src/communication.cpp index d8100fbabe..4a78b38615 100644 --- a/protocols/Omegle/src/communication.cpp +++ b/protocols/Omegle/src/communication.cpp @@ -267,7 +267,7 @@ NETLIBHTTPHEADER* Omegle_client::get_request_headers(int request_type, int* head } headers[2].szName = "User-Agent"; - headers[2].szValue = (char *)g_strUserAgent.c_str(); + headers[2].szValue = Netlib_GetUserAgent(); headers[1].szName = "Accept"; headers[1].szValue = "*/*"; headers[0].szName = "Accept-Language"; diff --git a/protocols/Omegle/src/main.cpp b/protocols/Omegle/src/main.cpp index 197a932188..1a520f222c 100644 --- a/protocols/Omegle/src/main.cpp +++ b/protocols/Omegle/src/main.cpp @@ -26,7 +26,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. CMPlugin g_plugin;
-std::string g_strUserAgent;
DWORD g_mirandaVersion;
/////////////////////////////////////////////////////////////////////////////////////////
@@ -61,26 +60,5 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC int CMPlugin::Load()
{
InitIcons();
-
- // Init native User-Agent
- {
- std::stringstream agent;
- agent << "Miranda NG/";
- agent << ((g_mirandaVersion >> 24) & 0xFF);
- agent << ".";
- agent << ((g_mirandaVersion >> 16) & 0xFF);
- agent << ".";
- agent << ((g_mirandaVersion >> 8) & 0xFF);
- agent << ".";
- agent << ((g_mirandaVersion)& 0xFF);
-#ifdef _WIN64
- agent << " Omegle Protocol x64/";
-#else
- agent << " Omegle Protocol/";
-#endif
- agent << __VERSION_STRING_DOTS;
- g_strUserAgent = agent.str();
- }
-
return 0;
}
diff --git a/protocols/Omegle/src/stdafx.h b/protocols/Omegle/src/stdafx.h index 4ce85fe8a5..a768ac0efa 100644 --- a/protocols/Omegle/src/stdafx.h +++ b/protocols/Omegle/src/stdafx.h @@ -74,7 +74,6 @@ class OmegleProto; #include "theme.h"
#include "resource.h"
-extern std::string g_strUserAgent;
extern DWORD g_mirandaVersion;
class ScopedLock
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();
|