mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-09 07:18:34 -04:00
Add option to use custom login server
This commit is contained in:
parent
bf76e58e5d
commit
8faf15855a
@ -693,6 +693,7 @@ cc_result Png_Encode(struct Bitmap* bmp, struct Stream* stream,
|
||||
if ((res = Stream_Write(stream, tmp, 16))) return res;
|
||||
|
||||
/* Come back to fixup size of data in data chunk */
|
||||
/* TODO: Position instead of Length */
|
||||
if ((res = stream->Length(stream, &stream_end))) return res;
|
||||
if ((res = stream->Seek(stream, stream_beg + 33))) return res;
|
||||
|
||||
|
@ -71,7 +71,7 @@ enum SKIN_TYPE { SKIN_64x32, SKIN_64x64, SKIN_64x64_SLIM, SKIN_INVALID = 0xF0 };
|
||||
#define Int32_MaxValue ((cc_int32)2147483647L)
|
||||
|
||||
/* Skins were moved to use Amazon S3, so link directly to avoid a pointless redirect */
|
||||
#define SKINS_SERVER "http://classicube.s3.amazonaws.com/skin/"
|
||||
#define SKINS_SERVER "http://classicube.s3.amazonaws.com/skin"
|
||||
#define UPDATES_SERVER "http://cs.classicube.net/client"
|
||||
#define SERVICES_SERVER "https://www.classicube.net/api"
|
||||
#define RESOURCE_SERVER "http://static.classicube.net"
|
||||
|
@ -1041,7 +1041,7 @@ int Http_AsyncGetSkin(const cc_string* skinName) {
|
||||
if (Utils_IsUrlPrefix(skinName)) {
|
||||
String_Copy(&url, skinName);
|
||||
} else {
|
||||
String_Format1(&url, SKINS_SERVER "%s.png", skinName);
|
||||
String_Format1(&url, SKINS_SERVER "/%s.png", skinName);
|
||||
}
|
||||
return Http_AsyncGetData(&url, false);
|
||||
}
|
||||
|
24
src/LWeb.c
24
src/LWeb.c
@ -200,6 +200,9 @@ static void Json_Handle(cc_uint8* data, cc_uint32 len,
|
||||
/*########################################################################################################################*
|
||||
*--------------------------------------------------------Web task---------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static char servicesBuffer[FILENAME_SIZE];
|
||||
static cc_string servicesServer = String_FromArray(servicesBuffer);
|
||||
|
||||
static void LWebTask_Reset(struct LWebTask* task) {
|
||||
task->completed = false;
|
||||
task->working = true;
|
||||
@ -229,6 +232,10 @@ void LWebTask_DisplayError(struct LWebTask* task, const char* action, cc_string*
|
||||
Launcher_DisplayHttpError(task->res, task->status, action, dst);
|
||||
}
|
||||
|
||||
void LWebTasks_Init(void) {
|
||||
Options_Get(SOPT_SERVICES, &servicesServer, SERVICES_SERVER);
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------GetTokenTask------------------------------------------------------*
|
||||
@ -251,12 +258,15 @@ static void GetTokenTask_Handle(cc_uint8* data, cc_uint32 len) {
|
||||
}
|
||||
|
||||
void GetTokenTask_Run(void) {
|
||||
static const cc_string url = String_FromConst(SERVICES_SERVER "/login");
|
||||
cc_string url; char urlBuffer[URL_MAX_SIZE];
|
||||
static char tokenBuffer[STRING_SIZE];
|
||||
static char userBuffer[STRING_SIZE];
|
||||
if (GetTokenTask.Base.working) return;
|
||||
|
||||
LWebTask_Reset(&GetTokenTask.Base);
|
||||
String_InitArray(url, urlBuffer);
|
||||
String_Format1(&url, "%s/login", &servicesServer);
|
||||
|
||||
String_InitArray(GetTokenTask.token, tokenBuffer);
|
||||
String_InitArray(GetTokenTask.username, userBuffer);
|
||||
GetTokenTask.error = false;
|
||||
@ -309,12 +319,15 @@ static void SignInTask_Append(cc_string* dst, const char* key, const cc_string*
|
||||
}
|
||||
|
||||
void SignInTask_Run(const cc_string* user, const cc_string* pass, const cc_string* mfaCode) {
|
||||
static const cc_string url = String_FromConst(SERVICES_SERVER "/login");
|
||||
cc_string url; char urlBuffer[URL_MAX_SIZE];
|
||||
static char userBuffer[STRING_SIZE];
|
||||
cc_string args; char argsBuffer[1024];
|
||||
if (SignInTask.Base.working) return;
|
||||
|
||||
LWebTask_Reset(&SignInTask.Base);
|
||||
String_InitArray(url, urlBuffer);
|
||||
String_Format1(&url, "%s/login", &servicesServer);
|
||||
|
||||
String_InitArray(SignInTask.username, userBuffer);
|
||||
SignInTask.error = NULL;
|
||||
SignInTask.needMFA = false;
|
||||
@ -396,7 +409,7 @@ void FetchServerTask_Run(const cc_string* hash) {
|
||||
LWebTask_Reset(&FetchServerTask.Base);
|
||||
ServerInfo_Init(&FetchServerTask.server);
|
||||
String_InitArray(url, urlBuffer);
|
||||
String_Format1(&url, SERVICES_SERVER "/server/%s", hash);
|
||||
String_Format2(&url, "%s/server/%s", &servicesServer, hash);
|
||||
|
||||
FetchServerTask.Base.Handle = FetchServerTask_Handle;
|
||||
FetchServerTask.Base.reqID = Http_AsyncGetDataEx(&url, false, NULL, NULL, &ccCookies);
|
||||
@ -442,9 +455,12 @@ static void FetchServersTask_Handle(cc_uint8* data, cc_uint32 len) {
|
||||
}
|
||||
|
||||
void FetchServersTask_Run(void) {
|
||||
static const cc_string url = String_FromConst(SERVICES_SERVER "/servers");
|
||||
cc_string url; char urlBuffer[URL_MAX_SIZE];
|
||||
if (FetchServersTask.Base.working) return;
|
||||
|
||||
LWebTask_Reset(&FetchServersTask.Base);
|
||||
String_InitArray(url, urlBuffer);
|
||||
String_Format1(&url, "%s/servers", &servicesServer);
|
||||
|
||||
FetchServersTask.Base.Handle = FetchServersTask_Handle;
|
||||
FetchServersTask.Base.reqID = Http_AsyncGetDataEx(&url, false, NULL, NULL, &ccCookies);
|
||||
|
@ -53,6 +53,7 @@ struct LWebTask {
|
||||
};
|
||||
void LWebTask_Tick(struct LWebTask* task);
|
||||
void LWebTask_DisplayError(struct LWebTask* task, const char* action, cc_string* dst);
|
||||
void LWebTasks_Init(void);
|
||||
|
||||
|
||||
extern struct GetTokenTaskData {
|
||||
|
@ -296,6 +296,7 @@ void Launcher_Run(void) {
|
||||
InitFramebuffer();
|
||||
|
||||
Options_Get(LOPT_USERNAME, &Game_Username, "");
|
||||
LWebTasks_Init();
|
||||
Session_Load();
|
||||
Launcher_LoadSkin();
|
||||
Launcher_Init();
|
||||
|
@ -83,6 +83,8 @@
|
||||
#define ROPT_PORT "launcher-port"
|
||||
#define ROPT_MPPASS "launcher-mppass"
|
||||
|
||||
#define SOPT_SERVICES "server-services"
|
||||
|
||||
struct StringsBuffer;
|
||||
extern struct StringsBuffer Options;
|
||||
/* Frees any memory allocated in storing options. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user