2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 10:37:41 -04:00

Make UruLauncher use curl as well

--HG--
rename : Sources/example_server.ini => example_server.ini
This commit is contained in:
2011-04-17 11:53:32 -07:00
parent 31ac8baf9f
commit c8cf53df80
5 changed files with 40 additions and 105 deletions

View File

@ -1196,7 +1196,7 @@ static void LoadUserPass (const wchar *accountName, char *username, ShaDigest *p
}
}
size_t CurlCallback(void *buffer, size_t size, size_t nmemb, void *param)
static size_t CurlCallback(void *buffer, size_t size, size_t nmemb, void *param)
{
static char status[256];

View File

@ -5,6 +5,7 @@ include_directories("../../NucleusLib")
include_directories("../../PubUtilLib")
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${CURL_INCLUDE_DIR})
set(plUruLauncher_HEADERS
Intern.h
@ -56,8 +57,8 @@ target_link_libraries(plUruLauncher ${DirectX_LIBRARIES})
target_link_libraries(plUruLauncher ${OPENSSL_LIBRARIES})
target_link_libraries(plUruLauncher ${Ogg_LIBRARIES})
target_link_libraries(plUruLauncher ${Vorbis_LIBRARIES})
target_link_libraries(plUruLauncher ${CURL_LIBRARY})
target_link_libraries(plUruLauncher ws2_32)
target_link_libraries(plUruLauncher winhttp)
target_link_libraries(plUruLauncher rpcrt4)
target_link_libraries(plUruLauncher comctl32)

View File

@ -150,6 +150,7 @@ static LISTDECL(WndEvent, link) s_eventQ;
static CEvent s_shutdownEvent(kEventManualReset);
static wchar s_workingDir[MAX_PATH];
static CEvent s_statusEvent(kEventManualReset);
static char s_curlError[CURL_ERROR_SIZE];
/*****************************************************************************
@ -591,122 +592,51 @@ static bool TGCheckForFrameworkUpdate ()
}
//============================================================================
static void HttpRequestPost(HINTERNET hConnect)
static size_t CurlCallback(void *buffer, size_t size, size_t nmemb, void *)
{
const wchar *path = BuildTypeServerStatusPath();
HINTERNET hRequest = 0;
char data[256] = {0};
DWORD bytesRead;
static char status[256];
hRequest = WinHttpOpenRequest(
hConnect,
L"POST",
path,
NULL,
WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
0
);
if(hRequest)
{
BOOL b = WinHttpSendRequest(
hRequest,
L"Content-Type: application/x-www-form-urlencoded\r\n",
0,
(void *)s_postKey,
sizeof(s_postKey),
sizeof(s_postKey),
0
);
DWORD err = GetLastError();
WinHttpReceiveResponse(hRequest, 0);
WinHttpReadData(hRequest, data, arrsize(data)-1, &bytesRead);
data[bytesRead] = 0;
}
if(bytesRead)
SetStatusText(data);
WinHttpCloseHandle(hRequest);
}
//============================================================================
static void HttpRequestGet(HINTERNET hConnect)
{
const wchar *path = BuildTypeServerStatusPath();
HINTERNET hRequest = 0;
char data[256] = {0};
DWORD bytesRead;
hRequest = WinHttpOpenRequest(
hConnect,
L"GET",
path,
NULL,
WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
0
);
if(hRequest)
{
BOOL b = WinHttpSendRequest(
hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS,
0,
WINHTTP_NO_REQUEST_DATA,
0,
0,
0
);
if(b)
{
DWORD err = GetLastError();
WinHttpReceiveResponse(hRequest, 0);
WinHttpReadData(hRequest, data, arrsize(data)-1, &bytesRead);
data[bytesRead] = 0;
}
}
if(bytesRead)
SetStatusText(data);
WinHttpCloseHandle(hRequest);
strncpy(status, (const char *)buffer, std::min<size_t>(size * nmemb, 256));
status[255] = 0;
SetStatusText(status);
return size * nmemb;
}
//============================================================================
static void StatusCallback(void *)
{
HINTERNET hSession = 0;
HINTERNET hConnect = 0;
CURL *hCurl;
char *serverStatus = hsWStringToString(BuildTypeServerStatusPath());
char serverUrl[256];
snprintf(serverUrl, 256, "http://support.cyanworlds.com%s", serverStatus);
delete [] serverStatus;
hCurl = curl_easy_init();
curl_easy_setopt(hCurl, CURLOPT_ERRORBUFFER, s_curlError);
// update while we are running
while(!s_shutdown)
{
if(BuildTypeServerStatusPath())
{
hSession = WinHttpOpen(
L"UruClient/1.0",
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS,
0
);
//TODO: Get a server status path from the server.ini, without
// pulling in all the annoying pfConsole dependencies.
// Alternatively, make a better launcher...
if(hSession)
curl_easy_setopt(hCurl, CURLOPT_USERAGENT, "UruClient/1.0");
curl_easy_setopt(hCurl, CURLOPT_URL, serverUrl);
if(StrLen(s_postKey))
{
hConnect = WinHttpConnect(
hSession,
STATUS_PATH,
INTERNET_DEFAULT_HTTP_PORT,
0
);
if(hConnect)
{
if(StrLen(s_postKey))
HttpRequestPost(hConnect);
else
HttpRequestGet(hConnect);
}
char *safeData = curl_easy_escape(hCurl, s_postKey, strlen(s_postKey));
curl_easy_setopt(hCurl, CURLOPT_POST, 1);
curl_easy_setopt(hCurl, CURLOPT_POSTFIELDS, safeData);
curl_free(safeData);
}
WinHttpCloseHandle(hConnect);
WinHttpCloseHandle(hSession);
if (curl_easy_perform(hCurl) != 0)
SetStatusText(s_curlError);
}
for(unsigned i = 0; i < UPDATE_STATUSMSG_SECONDS && !s_shutdown; ++i)
@ -715,6 +645,8 @@ static void StatusCallback(void *)
}
}
curl_easy_cleanup(hCurl);
s_statusEvent.Signal();
}
@ -856,6 +788,8 @@ int __stdcall WinMain (
StrPrintf(s_launcherInfo.cmdLine, arrsize(s_launcherInfo.cmdLine), appCmdLine);
s_launcherInfo.returnCode = 0;
curl_global_init(CURL_GLOBAL_ALL);
if(!isTempPatcher)
{
// create window thread
@ -1032,6 +966,8 @@ int __stdcall WinMain (
pTGApp = NULL;
}
curl_global_cleanup();
return s_launcherInfo.returnCode;
}

View File

@ -37,9 +37,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <process.h>
#include <time.h>
#include <winsock2.h>
#include <windows.h>
#include <WinHttp.h>
#include <curl/curl.h>
#include "pnUtils/pnUtils.h"
#include "pnNetBase/pnNetBase.h"

View File

@ -1,21 +0,0 @@
# Keys are Base64-encoded 512 bit RC4 keys, as generated by DirtSand's keygen
# command. Note that they MUST be quoted in the commands below, or the client
# won't parse them correctly! Also note that the decoded keys are in OpenSSL
# byte order, which is opposite from the byte order stored in the pnNetBase
# .hpp files in Cyan's original source.
# The following keys and addresses represent the official MOULagain server
Server.Game.N "kEso0EnSJNkgyQtVyUO8IGAzy9cVgtEZG3Dy/s0urdYgu+omUP0/3sQihN5EOJqqXQl2ahI7cifHptdDafekOA=="
Server.Game.X "Pds9j7NYWE9o6WV6o88EhGczzxR/NpNimHn9yLq2X9xoAdiEH1x2R1w/O5nwWv3CPmVEPgm9IalIcr0CvZOy+Q=="
Server.Gate.N "tSNEa6OAIdfDby8p+lW8YOxqDZL1VUwVHPHbx01MuNxQ1Un8tlWYFi5mqzQPIZqjI3rX0YFLJatQUHr45jX6jQ=="
Server.Gate.X "GvO3GWDQaWnK+ZSJxTKCaEfOjWwJxMt85H9vvqC+nA84mw9hpqlezfyz86k5Nfo5BQ+dg5hivAcuK3CQC/+Isw=="
Server.Gate.Host "184.73.198.22"
Server.Auth.N "j1amo5e+ID/FhzgSEm2razSbZjhXEWEKGlTCZstbMU3kt3gMyANeR7mOw0MbRf5y7uV1Q4hhfCmRj3HrQhkXLQ=="
Server.Auth.X "G+nYVfMDb/q8zT1qs7uy2j91jLmesUPq72TVLlUB7OXrWyP77ponIPlZDfSPu8EFVbndJWHONlOtI8AIxh3PIQ=="
Server.Auth.Host "184.73.198.22"
Server.DispName "Cyan Worlds' MOULagain"
Server.Status "http://support.cyanworlds.com/serverstatus/moullive.php"
Server.Signup "http://www.mystonline.com/signup.html"