Merge branch 'main' into filemonitor-cleanup

This commit is contained in:
d1str4ught
2025-09-25 23:59:38 +02:00
committed by GitHub
6 changed files with 1 additions and 229 deletions

View File

@@ -1,178 +0,0 @@
/* vi: set sw=4 ts=8 cino=g0,\:0 : */
/*********************************************************************
* date : 2010.4.7
* file : auth_brazil.c
* author : mhh
* description :
*/
#include "stdafx.h"
#ifndef OS_WINDOWS
#include <unistd.h>
#include <stdint.h>
#endif
#include <stdio.h>
#include <string.h>
#include "libthecore/xmd5.h"
#include "auth_brazil.h"
static const char* FN_md5(const char *src)
{
static char s_buffer[512];
memset(s_buffer, 0x00, sizeof(s_buffer));
unsigned char digest[16] = {0};
MD5_CTX md5;
MD5Init(&md5);
MD5Update(&md5, (const unsigned char*) src, strlen(src));
MD5Final(digest, &md5);
int offset = 0;
for (int i=0; i<16; ++i) {
offset += sprintf(s_buffer + offset, "%02x", digest[i]);
}
return s_buffer;
}
static int FN_make_request(const char *login, const char *password, /*out*/ char *dst, int dst_size)
{
int len = snprintf(dst, dst_size,
// "GET /metin2/game_auth.php?ID=%s&PW=%s HTTP/1.1\r\n"
"GET /metin2/?ID=%s&PW=%s HTTP/1.1\r\n"
"Host: auth.ongame.com.br\r\n"
"Connection: Close\r\n\r\n",
login, FN_md5(password));
return len;
}
static int FN_parse_reply(char *reply)
{
char buffer[2048];
strlcpy(buffer, reply, sizeof(buffer));
const char *delim = "\r\n";
char *last = 0;
char *v = strtok_r(buffer, delim, &last);
char *result = 0;
while (v)
{
result = v;
v = strtok_r(NULL, delim, &last);
}
if (result)
{
if (0 == strcasecmp("true", result))
return AUTH_BRAZIL_SUCC;
else if (0 == strcasecmp("false", result))
return AUTH_BRAZIL_WRONGPWD;
else if (0 == strcasecmp("unknown", result))
return AUTH_BRAZIL_NOID;
else if (0 == strcasecmp("flash", result))
return AUTH_BRAZIL_FLASHUSER;
}
return AUTH_BRAZIL_SERVER_ERR;
}
extern void socket_timeout(socket_t s, long sec, long usec);
int auth_brazil(const char *login, const char *pwd)
{
const char *host = "auth.ongame.com.br";
int port = 80;
socket_t fd = socket_connect(host, port);
if (fd < 0)
{
sys_err("[AUTH_BRAZIL] : could not connect to gsp server(%s)", host);
return AUTH_BRAZIL_SERVER_ERR;
}
socket_block(fd);
socket_timeout(fd, 3, 0);
// send request
{
char request[512];
int len = FN_make_request(login, pwd, request, sizeof(request));
#ifndef OS_WINDOWS
if (write(fd, request, len) < 0)
#else
if (_write(fd, request, len) < 0)
#endif
{
sys_err("[AUTH_BRAZIL] : could not send auth-request (%s)", login);
close(fd);
return AUTH_BRAZIL_SERVER_ERR;
}
}
// read reply
{
char reply[1024] = {0};
int len = read(fd, reply, sizeof(reply));
close(fd);
if (len <= 0)
{
sys_err("[AUTH_BRAZIL] : could not recv auth-reply (%s)", login);
return AUTH_BRAZIL_SERVER_ERR;
}
// 응답받은 경우에만 query count를 늘린다.
auth_brazil_inc_query_count();
return FN_parse_reply(reply);
}
}
static int s_query_count = 0;
int auth_brazil_inc_query_count()
{
return ++s_query_count;
}
void auth_brazil_log()
{
FILE *fp = 0;
// open and try backup
{
fp = fopen("AUTH_COUNT.log", "a");
if (0 == fp)
return;
struct stat sb;
fstat(fileno(fp), &sb);
if (sb.st_size > 1024 * 1024)
{
fclose(fp);
rename("AUTH_COUNT.log", "AUTH_COUNT.log.old");
fp = fopen("AUTH_COUNT.log", "a");
}
}
// write log
{
fprintf(fp, "%d\n", s_query_count);
fclose(fp);
}
// reset query count
s_query_count = 0;
}

View File

@@ -1,23 +0,0 @@
/* vi: set sw=4 ts=8 cino=g0,\:0 : */
/*********************************************************************
* date : 2010.4.7
* file : auth_brazil.h
* author : mhh
* description :
*/
#ifndef __auth_brazil_h_1270647899__
#define __auth_brazil_h_1270647899__
#define AUTH_BRAZIL_SERVER_ERR 0
#define AUTH_BRAZIL_SUCC 1
#define AUTH_BRAZIL_NOID 2
#define AUTH_BRAZIL_WRONGPWD 3
#define AUTH_BRAZIL_FLASHUSER 4
int auth_brazil(const char *login, const char *pwd);
int auth_brazil_inc_query_count();
void auth_brazil_log();
#endif // __auth_brazil_h_1270647899__

View File

@@ -17,7 +17,6 @@
#include "login_data.h" #include "login_data.h"
#include "locale_service.h" #include "locale_service.h"
#include "spam.h" #include "spam.h"
#include "auth_brazil.h"
extern std::string g_stBlockDate; extern std::string g_stBlockDate;

View File

@@ -7,7 +7,6 @@
#include "protocol.h" #include "protocol.h"
#include "matrix_card.h" #include "matrix_card.h"
#include "locale_service.h" #include "locale_service.h"
#include "auth_brazil.h"
#include "db.h" #include "db.h"
extern time_t get_global_time(); extern time_t get_global_time();
@@ -155,26 +154,6 @@ void CInputAuth::Login(LPDESC d, const char * c_pData)
sys_log(0, "InputAuth::Login : key %u:0x%x login %s", dwKey, dwPanamaKey, login); sys_log(0, "InputAuth::Login : key %u:0x%x login %s", dwKey, dwPanamaKey, login);
// BRAZIL_AUTH
if (LC_IsBrazil() && !test_server)
{
int result = auth_brazil(login, passwd);
switch (result)
{
case AUTH_BRAZIL_SERVER_ERR:
case AUTH_BRAZIL_NOID:
LoginFailure(d, "NOID");
return;
case AUTH_BRAZIL_WRONGPWD:
LoginFailure(d, "WRONGPWD");
return;
case AUTH_BRAZIL_FLASHUSER:
LoginFailure(d, "FLASH");
return;
}
}
TPacketCGLogin3 * p = M2_NEW TPacketCGLogin3; TPacketCGLogin3 * p = M2_NEW TPacketCGLogin3;
thecore_memcpy(p, pinfo, sizeof(TPacketCGLogin3)); thecore_memcpy(p, pinfo, sizeof(TPacketCGLogin3));

View File

@@ -428,8 +428,7 @@ void CInputDB::PlayerLoad(LPDESC d, const char * data)
if (LC_IsYMIR() || LC_IsKorea() || LC_IsBrazil() || LC_IsJapan()) if (LC_IsYMIR() || LC_IsKorea() || LC_IsBrazil() || LC_IsJapan())
{ {
LogManager::instance().LoginLog(true, LogManager::instance().LoginLog(true, ch->GetDesc()->GetAccountTable().id, ch->GetPlayerID(), ch->GetLevel(), ch->GetJob(), ch->GetRealPoint(POINT_PLAYTIME));
ch->GetDesc()->GetAccountTable().id, ch->GetPlayerID(), ch->GetLevel(), ch->GetJob(), ch->GetRealPoint(POINT_PLAYTIME));
} }
} }

View File

@@ -54,7 +54,6 @@
#include "spam.h" #include "spam.h"
#include "panama.h" #include "panama.h"
#include "threeway_war.h" #include "threeway_war.h"
#include "auth_brazil.h"
#include "DragonLair.h" #include "DragonLair.h"
#include "skill_power.h" #include "skill_power.h"
#include "SpeedServer.h" #include "SpeedServer.h"
@@ -223,9 +222,6 @@ void heartbeat(LPHEART ht, int pulse)
// 1초마다 // 1초마다
if (!(pulse % ht->passes_per_sec)) if (!(pulse % ht->passes_per_sec))
{ {
if (g_bAuthServer && LC_IsBrazil() && !test_server)
auth_brazil_log();
if (!g_bAuthServer) if (!g_bAuthServer)
{ {
TPlayerCountPacket pack; TPlayerCountPacket pack;