summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--src/login/init.c3
-rw-r--r--src/login/parse.c91
-rw-r--r--src/login/parse.h1
-rw-r--r--src/login/send.c2
5 files changed, 95 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac
index 6445cb3..417c7a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,4 +13,6 @@ AC_PROG_LIBTOOL
AC_ENABLE_SHARED
AC_DISABLE_STATIC
+AC_CHECK_FUNC([strnlen],[CFLAGS="$CFLAGS -DHAVE_STRNLEN"])
+
AC_OUTPUT(Makefile src/Makefile)
diff --git a/src/login/init.c b/src/login/init.c
index 2a2d295..03bc2e6 100644
--- a/src/login/init.c
+++ b/src/login/init.c
@@ -29,10 +29,11 @@ HPExport void plugin_init (void)
{
session = GET_SYMBOL("session");
sockt = GET_SYMBOL("sockt");
-
+ strlib = GET_SYMBOL("strlib");
login = GET_SYMBOL("login");
addPacket(0x7530, 22, login_parse_version, hpParse_Login);
+ addPacket(0x027c, 95, elogin_parse_client_login2, hpParse_Login);
addHookPre("login->parse_client_login", elogin_parse_client_login_pre);
}
diff --git a/src/login/parse.c b/src/login/parse.c
index 49f7b14..609583d 100644
--- a/src/login/parse.c
+++ b/src/login/parse.c
@@ -10,6 +10,7 @@
#include "../../../common/mmo.h"
#include "../../../common/socket.h"
#include "../../../common/strlib.h"
+#include "../../../login/account.h"
#include "../../../login/login.h"
#include "login/parse.h"
@@ -35,13 +36,99 @@ void login_parse_version(int fd)
send_server_version(fd);
}
-int elogin_parse_client_login_pre(int *fd, struct login_session_data* sd, const char *const ip)
+int elogin_parse_client_login_pre(int *fdPtr, struct login_session_data* sd, const char *const ip)
{
+ int fd = *fdPtr;
+ uint16 command = RFIFOW(fd,0);
+ if (command != 0x64)
+ {
+ login->login_error(fd, 3);
+ hookStop();
+ return 1;
+ }
+ char username[NAME_LENGTH];
+ safestrncpy(username, (const char*)RFIFOP(fd, 6), NAME_LENGTH);
+ int len = strnlen(username, NAME_LENGTH);
if (clientVersion < 2)
{
- login->login_error(*fd, 5);
+ login->login_error(fd, 5);
+ hookStop();
+ return 1;
+ }
+ else if (len >= 2 && username[len - 2] == '_' && memchr("FfMm", username[len - 1], 4))
+ {
+ login->login_error(fd, 3);
hookStop();
return 1;
}
+
+ return 0;
+}
+
+int elogin_parse_client_login2(int fd)
+{
+ char username[NAME_LENGTH];
+ char password[PASSWD_LEN];
+ char email[40];
+ uint8 clienttype;
+ int result;
+
+ safestrncpy(username, (const char*)RFIFOP(fd, 2), NAME_LENGTH);
+
+ int len = strnlen(username, NAME_LENGTH);
+ if (len < 2 || !username[len - 2] == '_' || !memchr("FfMm", username[len - 1], 4))
+ {
+ login->login_error(fd, 3);
+ return 1;
+ }
+
+ safestrncpy(password, (const char*)RFIFOP(fd, 26), NAME_LENGTH);
+ safestrncpy(email, (const char*)RFIFOP(fd, 51), 40);
+ clienttype = RFIFOB(fd, 50);
+
+ struct login_session_data* sd = (struct login_session_data*)session[fd]->session_data;
+
+ char ip[16];
+ uint32 ipl = session[fd]->client_addr;
+ ip2str(ipl, ip);
+ sd->clienttype = clienttype;
+ sd->version = clientVersion;
+ sd->passwdenc = 0;
+ safestrncpy(sd->userid, username, NAME_LENGTH);
+ ShowStatus("Request for connection of %s (ip: %s).\n", sd->userid, ip);
+ safestrncpy(sd->passwd, password, PASSWD_LEN);
+
+ if (e_mail_check(email) == 0)
+ {
+ ShowNotice("Attempt to create an e-mail REFUSED - e-mail is invalid (ip: %s)\n", ip);
+ login->login_error(fd, 11);
+ return 1;
+ }
+
+ result = login->mmo_auth(sd, false);
+
+ if (result == -1)
+ {
+ int account_id = sd->account_id;
+ struct mmo_account acc;
+ if (!login->accounts->load_num(login->accounts, &acc, account_id))
+ {
+ ShowNotice("Attempt to create an e-mail on an account REFUSED - account: %d, ip: %s).\n", account_id, ip);
+ }
+ else
+ {
+ memcpy(acc.email, email, 40);
+ ShowNotice("Create an e-mail on an account with a default e-mail (account: %d, new e-mail: %s, ip: %s).\n", account_id, email, ip);
+ // Save
+ login->accounts->save(login->accounts, &acc);
+ }
+
+ login->auth_ok(sd);
+ }
+ else
+ {
+ login->auth_failed(sd, result);
+ }
+
return 0;
}
diff --git a/src/login/parse.h b/src/login/parse.h
index 753e23c..c32426a 100644
--- a/src/login/parse.h
+++ b/src/login/parse.h
@@ -6,5 +6,6 @@
void login_parse_version(int fd);
int elogin_parse_client_login_pre(int *fd, struct login_session_data* sd, const char *const ip);
+int elogin_parse_client_login2(int fd);
#endif // EVOL_LOGIN_PARSE
diff --git a/src/login/send.c b/src/login/send.c
index ebc2e4c..001ee92 100644
--- a/src/login/send.c
+++ b/src/login/send.c
@@ -21,7 +21,7 @@ void send_server_version(int fd)
WFIFOW(fd, 0) = 0x7531;
WFIFOW(fd, 2) = 4 + 8;
WFIFOL(fd, 4) = 0; // unused
- WFIFOL(fd, 8) = 1; // server version
+ WFIFOL(fd, 8) = 2; // server version
WFIFOSET(fd, WFIFOW(fd,2));
}