_M/_F changes, and clientinfo thingys... all credit to sirius

git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@1059 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
(no author) 2005-02-06 22:37:16 +00:00
parent 3515beeed1
commit 485ed35302
6 changed files with 73 additions and 8 deletions

View File

@ -1,6 +1,10 @@
Date Added Date Added
02/06 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] * Fixed txt build compile problems[1057: MouseJstr]
* Corrected end-of-line issues in source code [1056: MouseJstr] * Corrected end-of-line issues in source code [1056: MouseJstr]
* Coded new command: @MOBINFO <monster name|monster N> [Lupus] * Coded new command: @MOBINFO <monster name|monster N> [Lupus]

View File

@ -52,6 +52,7 @@ gm_pass: gm
level_new_gm: 60 level_new_gm: 60
// Can you make new accounts on the server? (1 for Yes, 0 for no) // Can you make new accounts on the server? (1 for Yes, 0 for no)
// (1 = _M/_F enabled, 0 = not enabled)
new_account: 1 new_account: 1
// Account flatfile database, stores account information. // Account flatfile database, stores account information.
@ -137,6 +138,12 @@ check_ip_flag: yes
//deny: 123.123.123.123 //deny: 123.123.123.123
//deny: 234.234.234.234 //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 //Passwords in Login DB are MD5 - <passwordencrypt> cannot b used on client with this on
use_MD5_passwords: no use_MD5_passwords: no

View File

@ -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 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_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 { struct login_session_data {
int md5keylen; int md5keylen;
char md5key[20]; char md5key[20];
@ -1116,6 +1121,13 @@ int mmo_auth(struct mmo_account* account, int fd) {
account->userid[len] = '\0'; 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 // Strict account search
for(i = 0; i < auth_num; i++) { for(i = 0; i < auth_num; i++) {
if (strcmp(account->userid, auth_dat[i].userid) == 0) if (strcmp(account->userid, auth_dat[i].userid) == 0)
@ -2881,6 +2893,7 @@ int parse_login(int fd) {
if (RFIFOREST(fd) < ((RFIFOW(fd,0) == 0x64) ? 55 : 47)) if (RFIFOREST(fd) < ((RFIFOW(fd,0) == 0x64) ? 55 : 47))
return 0; return 0;
account.version = RFIFOL(fd, 2); //for exe version check [Sirius]
account.userid = (char*)RFIFOP(fd,6); account.userid = (char*)RFIFOP(fd,6);
account.userid[23] = '\0'; account.userid[23] = '\0';
remove_control_chars(account.userid); 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 flush_on = atoi(w2); //Added by Mugendai for GUI
} else if(strcmpi(w1,"flush_time")==0) { //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 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) { } else if (strcmpi(w1, "console") == 0) {
if(strcmpi(w2,"on") == 0 || strcmpi(w2,"yes") == 0 ) if(strcmpi(w2,"on") == 0 || strcmpi(w2,"yes") == 0 )
console = 1; console = 1;

View File

@ -15,6 +15,7 @@
extern int login_port; extern int login_port;
struct mmo_account { struct mmo_account {
int version; //Added for version check [Sirius]
char* userid; char* userid;
char passwd[33]; char passwd[33];
int passwdenc; int passwdenc;

View File

@ -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 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_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; 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) { account_id_count <= END_ACCOUNT_NUM && len >= 4 && strlen(account->passwd) >= 4) {
if (new_account_flag == 1) if (new_account_flag == 1)
account->userid[len] = '\0'; 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)){ if(mysql_query(&mysql_handle, tmp_sql)){
printf("SQL error (_M/_F reg): %s", mysql_error(&mysql_handle)); printf("SQL error (_M/_F reg): %s", mysql_error(&mysql_handle));
}else{ }else{
@ -414,7 +416,7 @@ int mmo_auth( struct mmo_account* account , int fd){
if(mysql_num_rows(sql_res) == 0){ if(mysql_num_rows(sql_res) == 0){
//ok no existing acc, //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); 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)){ if(mysql_query(&mysql_handle, tmp_sql)){
//Failed to insert new acc :/ //Failed to insert new acc :/
printf("SQL Error (_M/_F reg) .. insert ..: %s", mysql_error(&mysql_handle)); 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 ? }//all values for NEWaccount ok ?
// auth start : time seed // auth start : time seed
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
strftime(tmpstr, 24, "%Y-%m-%d %H:%M:%S",localtime((const time_t*)&(tv.tv_sec))); 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_uid,account->userid);
jstrescapecpy(t_pass, account->passwd); 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 // make query
sprintf(tmpsql, "SELECT `%s`,`%s`,`%s`,`lastlogin`,`logincount`,`sex`,`connect_until`,`last_ip`,`ban_until`,`state`,`%s`" 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); " 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"); printf("mmo_auth DB result error ! \n");
return 0; return 0;
} }
// Documented by CLOWNISIUS || LLRO || Gunstar lead this one with me // Documented by CLOWNISIUS || LLRO || Gunstar lead this one with me
// IF changed to diferent returns~ you get diferent responses from your msgstringtable.txt // IF changed to diferent returns~ you get diferent responses from your msgstringtable.txt
//Ireturn 2 == line 9 //Ireturn 2 == line 9
@ -617,6 +630,7 @@ int mmo_auth( struct mmo_account* account , int fd){
#endif #endif
} }
account->account_id = atoi(sql_row[0]); account->account_id = atoi(sql_row[0]);
account->login_id1 = rand(); account->login_id1 = rand();
account->login_id2 = rand(); account->login_id2 = rand();
@ -1209,7 +1223,7 @@ int parse_login(int fd) {
return 0; return 0;
printf("client connection request %s from %d.%d.%d.%d\n", RFIFOP(fd, 6), p[0], p[1], p[2], p[3]); 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.userid = (char*)RFIFOP(fd, 6);
account.passwd = (char*)RFIFOP(fd, 30); account.passwd = (char*)RFIFOP(fd, 30);
#ifdef PASSWORDENC #ifdef PASSWORDENC
@ -1219,14 +1233,17 @@ int parse_login(int fd) {
#endif #endif
result=mmo_auth(&account, fd); result=mmo_auth(&account, fd);
jstrescapecpy(t_uid,(char*)RFIFOP(fd, 6)); jstrescapecpy(t_uid,(char*)RFIFOP(fd, 6));
if(result==-1){ if(result==-1){
int gm_level = isGM(account.account_id); 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; WFIFOW(fd,0) = 0x81;
WFIFOL(fd,2) = 1; // 01 = Server closed WFIFOL(fd,2) = 1; // 01 = Server closed
WFIFOSET(fd,3); WFIFOSET(fd,3);
} else { } else {
if (p[0] != 127) { 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); 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 //query
@ -1366,6 +1383,8 @@ int parse_login(int fd) {
printf("DB server Error - %s\n", mysql_error(&mysql_handle)); printf("DB server Error - %s\n", mysql_error(&mysql_handle));
} }
result = -3; 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); sprintf(tmpsql,"SELECT `ban_until` FROM `%s` WHERE %s `%s` = '%s'",login_db, case_sensitive ? "BINARY" : "",login_db_userid, t_uid);
@ -1688,6 +1707,16 @@ int login_config_read(const char *cfgName){
flush_time = atoi(w2); //Added by Mugendai for GUI flush_time = atoi(w2); //Added by Mugendai for GUI
} else if(strcmpi(w1, "new_account") == 0){ //Added by Sirius for new account _M/_F } 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 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){ } else if(strcmpi(w1,"use_MD5_passwords")==0){
if (!strcmpi(w2,"yes")) { if (!strcmpi(w2,"yes")) {
use_md5_passwds=1; use_md5_passwds=1;

View File

@ -16,10 +16,12 @@
#define END_ACCOUNT_NUM 100000000 #define END_ACCOUNT_NUM 100000000
struct mmo_account { struct mmo_account {
int version; //Added by sirius for versioncheck
char* userid; char* userid;
char* passwd; char* passwd;
int passwdenc; int passwdenc;
long account_id; long account_id;
long login_id1; long login_id1;
long login_id2; long login_id2;