summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog.txt4
-rw-r--r--conf-tmpl/login_athena.conf7
-rw-r--r--src/login/login.c26
-rw-r--r--src/login/login.h1
-rw-r--r--src/login_sql/login.c39
-rw-r--r--src/login_sql/login.h4
6 files changed, 73 insertions, 8 deletions
diff --git a/Changelog.txt b/Changelog.txt
index a4fefba07..c9af29156 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,6 +1,10 @@
Date Added
02/06
+ * Login server uses login_db_userid and login_db_user_pass for
+ queries now [Credit to Sirius] [1059: Ajarn]
+ * Login server can now check clientversion in clientinfo
+ [Credit to Sirius] [1059: Ajarn]
* Fixed txt build compile problems[1057: MouseJstr]
* Corrected end-of-line issues in source code [1056: MouseJstr]
* Coded new command: @MOBINFO <monster name|monster N> [Lupus]
diff --git a/conf-tmpl/login_athena.conf b/conf-tmpl/login_athena.conf
index b4dabade4..ade701d23 100644
--- a/conf-tmpl/login_athena.conf
+++ b/conf-tmpl/login_athena.conf
@@ -52,6 +52,7 @@ gm_pass: gm
level_new_gm: 60
// Can you make new accounts on the server? (1 for Yes, 0 for no)
+// (1 = _M/_F enabled, 0 = not enabled)
new_account: 1
// Account flatfile database, stores account information.
@@ -137,6 +138,12 @@ check_ip_flag: yes
//deny: 123.123.123.123
//deny: 234.234.234.234
+//Check The clientversion set in the clientinfo ?
+check_client_version: no
+
+//What version we would allow to connect? (if the options above is enabled..)
+client_version_to_connect: 20
+
//Passwords in Login DB are MD5 - <passwordencrypt> cannot b used on client with this on
use_MD5_passwords: no
diff --git a/src/login/login.c b/src/login/login.c
index 698aae0b8..ff729d97d 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -114,6 +114,11 @@ int add_to_unlimited_account = 0; // Give possibility or not to adjust (ladmin c
int start_limited_time = -1; // Starting additional sec from now for the limited time at creation of accounts (-1: unlimited time, 0 or more: additional sec from now)
int check_ip_flag = 1; // It's to check IP of a player between login-server and char-server (part of anti-hacking system)
+int check_client_version = 0; //Client version check ON/OFF .. (sirius)
+int client_version_to_connect = 20; //Client version needed to connect ..(sirius)
+
+
+
struct login_session_data {
int md5keylen;
char md5key[20];
@@ -1115,7 +1120,14 @@ int mmo_auth(struct mmo_account* account, int fd) {
newaccount = 1;
account->userid[len] = '\0';
}
-
+
+ //EXE Version check [Sirius]
+ if(check_client_version == 1){
+ if(account->version != client_version_to_connect){
+ return 5;
+ }
+ }
+
// Strict account search
for(i = 0; i < auth_num; i++) {
if (strcmp(account->userid, auth_dat[i].userid) == 0)
@@ -2880,7 +2892,8 @@ int parse_login(int fd) {
case 0x01dd: // Ask connection of a client (encryption mode)
if (RFIFOREST(fd) < ((RFIFOW(fd,0) == 0x64) ? 55 : 47))
return 0;
-
+
+ account.version = RFIFOL(fd, 2); //for exe version check [Sirius]
account.userid = (char*)RFIFOP(fd,6);
account.userid[23] = '\0';
remove_control_chars(account.userid);
@@ -3569,6 +3582,15 @@ int login_config_read(const char *cfgName) {
flush_on = atoi(w2); //Added by Mugendai for GUI
} else if(strcmpi(w1,"flush_time")==0) { //Added by Mugendai for GUI
flush_time = atoi(w2); //Added by Mugendai for GUI
+ } else if(strcmpi(w1, "check_client_version") == 0){ //Added by Sirius for client version check
+ if(strcmpi(w2,"on") == 0 || strcmpi(w2,"yes") == 0 ){
+ check_client_version = 1;
+ }
+ if(strcmpi(w2,"off") == 0 || strcmpi(w2,"no") == 0 ){
+ check_client_version = 0;
+ }
+ }else if(strcmpi(w1, "client_version_to_connect") == 0){ //Added by Sirius for client version check
+ client_version_to_connect = atoi(w2); //Added by Sirius for client version check
} else if (strcmpi(w1, "console") == 0) {
if(strcmpi(w2,"on") == 0 || strcmpi(w2,"yes") == 0 )
console = 1;
diff --git a/src/login/login.h b/src/login/login.h
index 4a5b5be0c..c08952383 100644
--- a/src/login/login.h
+++ b/src/login/login.h
@@ -15,6 +15,7 @@
extern int login_port;
struct mmo_account {
+ int version; //Added for version check [Sirius]
char* userid;
char passwd[33];
int passwdenc;
diff --git a/src/login_sql/login.c b/src/login_sql/login.c
index 809445d87..79d25bfba 100644
--- a/src/login_sql/login.c
+++ b/src/login_sql/login.c
@@ -108,6 +108,8 @@ int auth_num = 0, auth_max = 0;
int min_level_to_connect = 0; // minimum level of player/GM (0: player, 1-99: gm) to connect on the server
int check_ip_flag = 1; // It's to check IP of a player between login-server and char-server (part of anti-hacking system)
+int check_client_version = 0; //Client version check ON/OFF .. (sirius)
+int client_version_to_connect = 20; //Client version needed to connect ..(sirius)
MYSQL mysql_handle;
@@ -406,7 +408,7 @@ int mmo_auth( struct mmo_account* account , int fd){
account_id_count <= END_ACCOUNT_NUM && len >= 4 && strlen(account->passwd) >= 4) {
if (new_account_flag == 1)
account->userid[len] = '\0';
- sprintf(tmp_sql, "SELECT `userid` FROM `%s` WHERE `userid` = '%s'", login_db, account->userid);
+ sprintf(tmp_sql, "SELECT `%s` FROM `%s` WHERE `userid` = '%s'", login_db_userid, login_db, account->userid);
if(mysql_query(&mysql_handle, tmp_sql)){
printf("SQL error (_M/_F reg): %s", mysql_error(&mysql_handle));
}else{
@@ -414,7 +416,7 @@ int mmo_auth( struct mmo_account* account , int fd){
if(mysql_num_rows(sql_res) == 0){
//ok no existing acc,
printf("Adding a new account user: %s with passwd: %s sex: %c (ip: %s)\n", account->userid, account->passwd, account->userid[len+1], ip);
- sprintf(tmp_sql, "INSERT INTO `%s` (`userid`, `user_pass`, `sex`, `email`) VALUES ('%s', '%s', '%c', '%s')", login_db, account->userid, account->passwd, account->userid[len+1], "a@a.com");
+ sprintf(tmp_sql, "INSERT INTO `%s` (`%s`, `%s`, `sex`, `email`) VALUES ('%s', '%s', '%c', '%s')", login_db, login_db_userid, login_db_user_pass, account->userid, account->passwd, account->userid[len+1], "a@a.com");
if(mysql_query(&mysql_handle, tmp_sql)){
//Failed to insert new acc :/
printf("SQL Error (_M/_F reg) .. insert ..: %s", mysql_error(&mysql_handle));
@@ -425,6 +427,7 @@ int mmo_auth( struct mmo_account* account , int fd){
}//all values for NEWaccount ok ?
+
// auth start : time seed
gettimeofday(&tv, NULL);
strftime(tmpstr, 24, "%Y-%m-%d %H:%M:%S",localtime((const time_t*)&(tv.tv_sec)));
@@ -433,6 +436,15 @@ int mmo_auth( struct mmo_account* account , int fd){
jstrescapecpy(t_uid,account->userid);
jstrescapecpy(t_pass, account->passwd);
+
+ //check for lasted version (exe version check) [Sirius]
+ if(check_client_version == 1){
+ if(account->version != client_version_to_connect){
+ return 6;
+ }
+ }
+
+
// make query
sprintf(tmpsql, "SELECT `%s`,`%s`,`%s`,`lastlogin`,`logincount`,`sex`,`connect_until`,`last_ip`,`ban_until`,`state`,`%s`"
" FROM `%s` WHERE %s `%s`='%s'", login_db_account_id, login_db_userid, login_db_user_pass, login_db_level, login_db, case_sensitive ? "BINARY" : "", login_db_userid, t_uid);
@@ -455,6 +467,7 @@ int mmo_auth( struct mmo_account* account , int fd){
printf("mmo_auth DB result error ! \n");
return 0;
}
+
// Documented by CLOWNISIUS || LLRO || Gunstar lead this one with me
// IF changed to diferent returns~ you get diferent responses from your msgstringtable.txt
//Ireturn 2 == line 9
@@ -617,6 +630,7 @@ int mmo_auth( struct mmo_account* account , int fd){
#endif
}
+
account->account_id = atoi(sql_row[0]);
account->login_id1 = rand();
account->login_id2 = rand();
@@ -1209,7 +1223,7 @@ int parse_login(int fd) {
return 0;
printf("client connection request %s from %d.%d.%d.%d\n", RFIFOP(fd, 6), p[0], p[1], p[2], p[3]);
-
+ account.version = RFIFOL(fd, 2);
account.userid = (char*)RFIFOP(fd, 6);
account.passwd = (char*)RFIFOP(fd, 30);
#ifdef PASSWORDENC
@@ -1218,15 +1232,18 @@ int parse_login(int fd) {
account.passwdenc=0;
#endif
result=mmo_auth(&account, fd);
+
jstrescapecpy(t_uid,(char*)RFIFOP(fd, 6));
if(result==-1){
int gm_level = isGM(account.account_id);
- if (min_level_to_connect > gm_level) {
+
+ if (min_level_to_connect > gm_level) {
WFIFOW(fd,0) = 0x81;
WFIFOL(fd,2) = 1; // 01 = Server closed
WFIFOSET(fd,3);
} else {
+
if (p[0] != 127) {
sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%d.%d.%d.%d', '%s','100', 'login ok')", loginlog_db, p[0], p[1], p[2], p[3], t_uid);
//query
@@ -1366,6 +1383,8 @@ int parse_login(int fd) {
printf("DB server Error - %s\n", mysql_error(&mysql_handle));
}
result = -3;
+ }else if(result == 6){ //not lastet version ..
+ result = 5;
}
sprintf(tmpsql,"SELECT `ban_until` FROM `%s` WHERE %s `%s` = '%s'",login_db, case_sensitive ? "BINARY" : "",login_db_userid, t_uid);
@@ -1667,7 +1686,7 @@ int login_config_read(const char *cfgName){
else if(strcmpi(w1,"dynamic_pass_failure_ban_how_long")==0){
dynamic_pass_failure_ban_how_long=atoi(w2);
printf ("set dynamic_pass_failure_ban_how_long : %d\n",dynamic_pass_failure_ban_how_long);
- }
+ }
else if(strcmpi(w1,"anti_freeze_enable")==0){
anti_freeze_enable = config_switch(w2);
}
@@ -1688,6 +1707,16 @@ int login_config_read(const char *cfgName){
flush_time = atoi(w2); //Added by Mugendai for GUI
} else if(strcmpi(w1, "new_account") == 0){ //Added by Sirius for new account _M/_F
new_account_flag = atoi(w2); //Added by Sirius for new account _M/_F
+ } else if(strcmpi(w1, "check_client_version") == 0){ //Added by Sirius for client version check
+ //check_client_version = config_switch(w2); //Added by Sirius for client version check
+ if(strcmpi(w2,"on") == 0 || strcmpi(w2,"yes") == 0 ){
+ check_client_version = 1;
+ }
+ if(strcmpi(w2,"off") == 0 || strcmpi(w2,"no") == 0 ){
+ check_client_version = 0;
+ }
+ } else if(strcmpi(w1, "client_version_to_connect") == 0){ //Added by Sirius for client version check
+ client_version_to_connect = atoi(w2); //Added by SIrius for client version check
} else if(strcmpi(w1,"use_MD5_passwords")==0){
if (!strcmpi(w2,"yes")) {
use_md5_passwds=1;
diff --git a/src/login_sql/login.h b/src/login_sql/login.h
index 73892f4ef..725c02ada 100644
--- a/src/login_sql/login.h
+++ b/src/login_sql/login.h
@@ -16,10 +16,12 @@
#define END_ACCOUNT_NUM 100000000
struct mmo_account {
+ int version; //Added by sirius for versioncheck
char* userid;
char* passwd;
int passwdenc;
-
+
+
long account_id;
long login_id1;
long login_id2;