mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-10 07:12:03 +00:00
masterserver_token is back
This commit is contained in:
parent
9b3456a860
commit
e7d949aeb2
3 changed files with 26 additions and 2 deletions
|
@ -44,6 +44,11 @@ consvar_t cv_masterserver_debug = {
|
||||||
MasterServer_Debug_OnChange, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
|
MasterServer_Debug_OnChange, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
consvar_t cv_masterserver_token = {
|
||||||
|
"masterserver_token", "", CV_SAVE, NULL,
|
||||||
|
NULL, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
|
||||||
|
};
|
||||||
|
|
||||||
static int hms_started;
|
static int hms_started;
|
||||||
|
|
||||||
static char *hms_api;
|
static char *hms_api;
|
||||||
|
@ -100,7 +105,9 @@ HMS_connect (const char *format, ...)
|
||||||
va_list ap;
|
va_list ap;
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
char *url;
|
char *url;
|
||||||
|
char *quack_token;
|
||||||
size_t seek;
|
size_t seek;
|
||||||
|
size_t token_length;
|
||||||
struct HMS_buffer *buffer;
|
struct HMS_buffer *buffer;
|
||||||
|
|
||||||
if (! hms_started)
|
if (! hms_started)
|
||||||
|
@ -127,6 +134,17 @@ HMS_connect (const char *format, ...)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cv_masterserver_token.string[0])
|
||||||
|
{
|
||||||
|
quack_token = curl_easy_escape(curl, cv_masterserver_token.string, 0);
|
||||||
|
token_length = ( sizeof "?token="-1 )+ strlen(quack_token);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
quack_token = NULL;
|
||||||
|
token_length = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
I_lock_mutex(&hms_api_mutex);
|
I_lock_mutex(&hms_api_mutex);
|
||||||
#endif
|
#endif
|
||||||
|
@ -134,7 +152,7 @@ HMS_connect (const char *format, ...)
|
||||||
seek = strlen(hms_api) + 1;/* + '/' */
|
seek = strlen(hms_api) + 1;/* + '/' */
|
||||||
|
|
||||||
va_start (ap, format);
|
va_start (ap, format);
|
||||||
url = malloc(seek + vsnprintf(0, 0, format, ap) + 1);
|
url = malloc(seek + vsnprintf(0, 0, format, ap) + token_length + 1);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
sprintf(url, "%s/", hms_api);
|
sprintf(url, "%s/", hms_api);
|
||||||
|
@ -144,9 +162,12 @@ HMS_connect (const char *format, ...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
va_start (ap, format);
|
va_start (ap, format);
|
||||||
vsprintf(&url[seek], format, ap);
|
seek += vsprintf(&url[seek], format, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
|
if (quack_token)
|
||||||
|
sprintf(&url[seek], "?token=%s", quack_token);
|
||||||
|
|
||||||
CONS_Printf("HMS: connecting '%s'...\n", url);
|
CONS_Printf("HMS: connecting '%s'...\n", url);
|
||||||
|
|
||||||
buffer = malloc(sizeof *buffer);
|
buffer = malloc(sizeof *buffer);
|
||||||
|
@ -174,6 +195,7 @@ HMS_connect (const char *format, ...)
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HMS_on_read);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HMS_on_read);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, buffer);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, buffer);
|
||||||
|
|
||||||
|
curl_free(quack_token);
|
||||||
free(url);
|
free(url);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|
|
@ -89,6 +89,7 @@ void AddMServCommands(void)
|
||||||
CV_RegisterVar(&cv_masterserver_update_rate);
|
CV_RegisterVar(&cv_masterserver_update_rate);
|
||||||
CV_RegisterVar(&cv_masterserver_timeout);
|
CV_RegisterVar(&cv_masterserver_timeout);
|
||||||
CV_RegisterVar(&cv_masterserver_debug);
|
CV_RegisterVar(&cv_masterserver_debug);
|
||||||
|
CV_RegisterVar(&cv_masterserver_token);
|
||||||
CV_RegisterVar(&cv_servername);
|
CV_RegisterVar(&cv_servername);
|
||||||
COM_AddCommand("listserv", Command_Listserv_f);
|
COM_AddCommand("listserv", Command_Listserv_f);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -68,6 +68,7 @@ extern consvar_t cv_masterserver, cv_servername;
|
||||||
extern consvar_t cv_masterserver_update_rate;
|
extern consvar_t cv_masterserver_update_rate;
|
||||||
extern consvar_t cv_masterserver_timeout;
|
extern consvar_t cv_masterserver_timeout;
|
||||||
extern consvar_t cv_masterserver_debug;
|
extern consvar_t cv_masterserver_debug;
|
||||||
|
extern consvar_t cv_masterserver_token;
|
||||||
|
|
||||||
// < 0 to not connect (usually -1) (offline mode)
|
// < 0 to not connect (usually -1) (offline mode)
|
||||||
// == 0 to show all rooms, not a valid hosting room
|
// == 0 to show all rooms, not a valid hosting room
|
||||||
|
|
Loading…
Reference in a new issue