From 445ec92f9cef7a81dd20731656808b70868ee483 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 25 Oct 2014 20:32:14 +0300 Subject: Add prefix login_ to most functions in login.c --- src/login/login.c | 110 +++++++++++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/src/login/login.c b/src/login/login.c index 9aa2e778b..6909a1a9c 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -54,7 +54,7 @@ struct s_subnet { int subnet_count = 0; -int mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip); +int login_mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip); //----------------------------------------------------- // Auth database @@ -88,12 +88,12 @@ struct online_login_data { }; static DBMap* online_db; // int account_id -> struct online_login_data* -static int waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data); +static int login_waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data); /** * @see DBCreateData */ -static DBData create_online_user(DBKey key, va_list args) +static DBData login_create_online_user(DBKey key, va_list args) { struct online_login_data* p; CREATE(p, struct online_login_data, 1); @@ -103,37 +103,37 @@ static DBData create_online_user(DBKey key, va_list args) return DB->ptr2data(p); } -struct online_login_data* add_online_user(int char_server, int account_id) +struct online_login_data* login_add_online_user(int char_server, int account_id) { struct online_login_data* p; - p = idb_ensure(online_db, account_id, create_online_user); + p = idb_ensure(online_db, account_id, login_create_online_user); p->char_server = char_server; if( p->waiting_disconnect != INVALID_TIMER ) { - timer->delete(p->waiting_disconnect, waiting_disconnect_timer); + timer->delete(p->waiting_disconnect, login_waiting_disconnect_timer); p->waiting_disconnect = INVALID_TIMER; } return p; } -void remove_online_user(int account_id) +void login_remove_online_user(int account_id) { struct online_login_data* p; p = (struct online_login_data*)idb_get(online_db, account_id); if( p == NULL ) return; if( p->waiting_disconnect != INVALID_TIMER ) - timer->delete(p->waiting_disconnect, waiting_disconnect_timer); + timer->delete(p->waiting_disconnect, login_waiting_disconnect_timer); idb_remove(online_db, account_id); } -static int waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data) { +static int login_waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data) { struct online_login_data* p = (struct online_login_data*)idb_get(online_db, id); if( p != NULL && p->waiting_disconnect == tid && p->account_id == id ) { p->waiting_disconnect = INVALID_TIMER; - remove_online_user(id); + login_remove_online_user(id); idb_remove(auth_db, id); } return 0; @@ -142,7 +142,7 @@ static int waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data) /** * @see DBApply */ -static int online_db_setoffline(DBKey key, DBData *data, va_list ap) +static int login_online_db_setoffline(DBKey key, DBData *data, va_list ap) { struct online_login_data* p = DB->data2ptr(data); int server_id = va_arg(ap, int); @@ -151,7 +151,7 @@ static int online_db_setoffline(DBKey key, DBData *data, va_list ap) p->char_server = -1; if( p->waiting_disconnect != INVALID_TIMER ) { - timer->delete(p->waiting_disconnect, waiting_disconnect_timer); + timer->delete(p->waiting_disconnect, login_waiting_disconnect_timer); p->waiting_disconnect = INVALID_TIMER; } } @@ -163,16 +163,16 @@ static int online_db_setoffline(DBKey key, DBData *data, va_list ap) /** * @see DBApply */ -static int online_data_cleanup_sub(DBKey key, DBData *data, va_list ap) +static int login_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap) { struct online_login_data *character= DB->data2ptr(data); if (character->char_server == -2) //Unknown server.. set them offline - remove_online_user(character->account_id); + login_remove_online_user(character->account_id); return 0; } -static int online_data_cleanup(int tid, int64 tick, int id, intptr_t data) { - online_db->foreach(online_db, online_data_cleanup_sub); +static int login_online_data_cleanup(int tid, int64 tick, int id, intptr_t data) { + online_db->foreach(online_db, login_online_data_cleanup_sub); return 0; } @@ -222,7 +222,7 @@ void chrif_server_destroy(int id) /// Resets all the data related to a server. void chrif_server_reset(int id) { - online_db->foreach(online_db, online_db_setoffline, id); //Set all chars from this char server to offline. + online_db->foreach(online_db, login_online_db_setoffline, id); //Set all chars from this char server to offline. chrif_server_destroy(id); chrif_server_init(id); } @@ -239,7 +239,7 @@ void chrif_on_disconnect(int id) //----------------------------------------------------- // periodic ip address synchronization //----------------------------------------------------- -static int sync_ip_addresses(int tid, int64 tick, int id, intptr_t data) { +static int login_sync_ip_addresses(int tid, int64 tick, int id, intptr_t data) { uint8 buf[2]; ShowInfo("IP Sync in progress...\n"); WBUFW(buf,0) = 0x2735; @@ -251,7 +251,7 @@ static int sync_ip_addresses(int tid, int64 tick, int id, intptr_t data) { //----------------------------------------------------- // encrypted/unencrypted password check (from eApp) //----------------------------------------------------- -bool check_encrypted(const char* str1, const char* str2, const char* passwd) +bool login_check_encrypted(const char* str1, const char* str2, const char* passwd) { char tmpstr[64+1], md5str[32+1]; @@ -261,7 +261,7 @@ bool check_encrypted(const char* str1, const char* str2, const char* passwd) return (0==strcmp(passwd, md5str)); } -bool check_password(const char* md5key, int passwdenc, const char* passwd, const char* refpass) +bool login_check_password(const char* md5key, int passwdenc, const char* passwd, const char* refpass) { if(passwdenc == 0) { @@ -272,15 +272,15 @@ bool check_password(const char* md5key, int passwdenc, const char* passwd, const // password mode set to 1 -> md5(md5key, refpass) enable with // password mode set to 2 -> md5(refpass, md5key) enable with - return ((passwdenc&0x01) && check_encrypted(md5key, refpass, passwd)) || - ((passwdenc&0x02) && check_encrypted(refpass, md5key, passwd)); + return ((passwdenc&0x01) && login_check_encrypted(md5key, refpass, passwd)) || + ((passwdenc&0x02) && login_check_encrypted(refpass, md5key, passwd)); } } //-------------------------------------------- // Test to know if an IP come from LAN or WAN. //-------------------------------------------- -int lan_subnetcheck(uint32 ip) +int login_lan_subnetcheck(uint32 ip) { int i; ARR_FIND( 0, subnet_count, i, (subnet[i].char_ip & subnet[i].mask) == (ip & subnet[i].mask) ); @@ -338,7 +338,7 @@ int login_lan_config_read(const char *lancfgName) //-------------------------------- // Packet parsing for char-servers //-------------------------------- -int parse_fromchar(int fd) +int login_parse_fromchar(int fd) { int j, id; uint32 ipl; @@ -347,7 +347,7 @@ int parse_fromchar(int fd) ARR_FIND( 0, ARRAYLENGTH(server), id, server[id].fd == fd ); if( id == ARRAYLENGTH(server) ) {// not a char server - ShowDebug("parse_fromchar: Disconnecting invalid session #%d (is not a char-server)\n", fd); + ShowDebug("login_parse_fromchar: Disconnecting invalid session #%d (is not a char-server)\n", fd); set_eof(fd); do_close(fd); return 0; @@ -738,14 +738,14 @@ int parse_fromchar(int fd) case 0x272b: // Set account_id to online [Wizputer] if( RFIFOREST(fd) < 6 ) return 0; - add_online_user(id, RFIFOL(fd,2)); + login_add_online_user(id, RFIFOL(fd,2)); RFIFOSKIP(fd,6); break; case 0x272c: // Set account_id to offline [Wizputer] if( RFIFOREST(fd) < 6 ) return 0; - remove_online_user(RFIFOL(fd,2)); + login_remove_online_user(RFIFOL(fd,2)); RFIFOSKIP(fd,6); break; @@ -756,15 +756,15 @@ int parse_fromchar(int fd) struct online_login_data *p; int aid; uint32 i, users; - online_db->foreach(online_db, online_db_setoffline, id); //Set all chars from this char-server offline first + online_db->foreach(online_db, login_online_db_setoffline, id); //Set all chars from this char-server offline first users = RFIFOW(fd,4); for (i = 0; i < users; i++) { aid = RFIFOL(fd,6+i*4); - p = idb_ensure(online_db, aid, create_online_user); + p = idb_ensure(online_db, aid, login_create_online_user); p->char_server = id; if (p->waiting_disconnect != INVALID_TIMER) { - timer->delete(p->waiting_disconnect, waiting_disconnect_timer); + timer->delete(p->waiting_disconnect, login_waiting_disconnect_timer); p->waiting_disconnect = INVALID_TIMER; } } @@ -794,7 +794,7 @@ int parse_fromchar(int fd) case 0x2737: //Request to set all offline. ShowInfo("Setting accounts from char-server %d offline.\n", id); - online_db->foreach(online_db, online_db_setoffline, id); + online_db->foreach(online_db, login_online_db_setoffline, id); RFIFOSKIP(fd,2); break; @@ -828,7 +828,7 @@ int parse_fromchar(int fd) login_log( host2ip(acc.last_ip), acc.userid, 100, "PIN Code check failed" ); } - remove_online_user(acc.account_id); + login_remove_online_user(acc.account_id); RFIFOSKIP(fd,6); } break; @@ -876,7 +876,7 @@ int parse_fromchar(int fd) } break; default: - ShowError("parse_fromchar: Unknown packet 0x%x from a char-server! Disconnecting!\n", command); + ShowError("login_parse_fromchar: Unknown packet 0x%x from a char-server! Disconnecting!\n", command); set_eof(fd); return 0; } // switch @@ -889,7 +889,7 @@ int parse_fromchar(int fd) //------------------------------------- // Make new account //------------------------------------- -int mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip) { +int login_mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip) { static int num_regs = 0; // registration counter static int64 new_reg_tick = 0; int64 tick = timer->gettick(); @@ -947,7 +947,7 @@ int mmo_auth_new(const char* userid, const char* pass, const char sex, const cha //----------------------------------------------------- // Check/authentication of a connection //----------------------------------------------------- -int mmo_auth(struct login_session_data* sd, bool isServer) { +int login_mmo_auth(struct login_session_data* sd, bool isServer) { struct mmo_account acc; size_t len; @@ -991,7 +991,7 @@ int mmo_auth(struct login_session_data* sd, bool isServer) { len -= 2; sd->userid[len] = '\0'; - result = mmo_auth_new(sd->userid, sd->passwd, TOUPPER(sd->userid[len+1]), ip); + result = login_mmo_auth_new(sd->userid, sd->passwd, TOUPPER(sd->userid[len+1]), ip); if( result != -1 ) return result;// Failed to make account. [Skotlex]. } @@ -1007,7 +1007,7 @@ int mmo_auth(struct login_session_data* sd, bool isServer) { return 0; // 0 = Unregistered ID } - if( !check_password(sd->md5key, sd->passwdenc, sd->passwd, acc.pass) ) { + if( !login_check_password(sd->md5key, sd->passwdenc, sd->passwd, acc.pass) ) { ShowNotice("Invalid password (account: '%s', pass: '%s', received pass: '%s', ip: %s)\n", sd->userid, acc.pass, sd->passwd, ip); return 1; // 1 = Incorrect Password } @@ -1145,7 +1145,7 @@ void login_auth_ok(struct login_session_data* sd) WBUFL(buf,2) = sd->account_id; charif_sendallwos(-1, buf, 6); if( data->waiting_disconnect == INVALID_TIMER ) - data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0); + data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, login_waiting_disconnect_timer, sd->account_id, 0); WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x81; @@ -1158,7 +1158,7 @@ void login_auth_ok(struct login_session_data* sd) {// client has authed but did not access char-server yet // wipe previous session idb_remove(auth_db, sd->account_id); - remove_online_user(sd->account_id); + login_remove_online_user(sd->account_id); data = NULL; } } @@ -1183,7 +1183,7 @@ void login_auth_ok(struct login_session_data* sd) if( !session_isValid(server[i].fd) ) continue; - subnet_char_ip = lan_subnetcheck(ip); // Advanced subnet check [LuzZza] + subnet_char_ip = login_lan_subnetcheck(ip); // Advanced subnet check [LuzZza] WFIFOL(fd,47+n*32) = htonl((subnet_char_ip) ? subnet_char_ip : server[i].ip); WFIFOW(fd,47+n*32+4) = ntows(htons(server[i].port)); // [!] LE byte order here [!] memcpy(WFIFOP(fd,47+n*32+6), server[i].name, 20); @@ -1216,10 +1216,10 @@ void login_auth_ok(struct login_session_data* sd) struct online_login_data* data; // mark client as 'online' - data = add_online_user(-1, sd->account_id); + data = login_add_online_user(-1, sd->account_id); // schedule deletion of this node - data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0); + data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, login_waiting_disconnect_timer, sd->account_id, 0); } } @@ -1294,7 +1294,7 @@ void login_auth_failed(struct login_session_data* sd, int result) //---------------------------------------------------------------------------------------- // Default packet parsing (normal players or char-server connection requests) //---------------------------------------------------------------------------------------- -int parse_login(int fd) +int login_parse_login(int fd) { struct login_session_data* sd = (struct login_session_data*)session[fd]->session_data; int result; @@ -1449,7 +1449,7 @@ int parse_login(int fd) return 0; } - result = mmo_auth(sd, false); + result = login_mmo_auth(sd, false); if( result == -1 ) login_auth_ok(sd); @@ -1501,7 +1501,7 @@ int parse_login(int fd) sprintf(message, "charserver - %s@%u.%u.%u.%u:%u", server_name, CONVIP(server_ip), server_port); login_log(session[fd]->client_addr, sd->userid, 100, message); - result = mmo_auth(sd, true); + result = login_mmo_auth(sd, true); if( runflag == LOGINSERVER_ST_RUNNING && result == -1 && sd->sex == 'S' && @@ -1517,7 +1517,7 @@ int parse_login(int fd) server[sd->account_id].type = type; server[sd->account_id].new_ = new_; - session[fd]->func_parse = parse_fromchar; + session[fd]->func_parse = login_parse_fromchar; session[fd]->flag.server = 1; realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); @@ -1760,7 +1760,7 @@ void set_server_type(void) { /// Called when a terminate signal is received. -void do_shutdown(void) +void do_shutdown_login(void) { if( runflag != LOGINSERVER_ST_SHUTDOWN ) { @@ -1835,22 +1835,22 @@ int do_init(int argc, char** argv) // Online user database init online_db = idb_alloc(DB_OPT_RELEASE_DATA); - timer->add_func_list(waiting_disconnect_timer, "waiting_disconnect_timer"); + timer->add_func_list(login_waiting_disconnect_timer, "login_waiting_disconnect_timer"); // Interserver auth init auth_db = idb_alloc(DB_OPT_RELEASE_DATA); - // set default parser as parse_login function - set_defaultparse(parse_login); + // set default parser as login_parse_login function + set_defaultparse(login_parse_login); // every 10 minutes cleanup online account db. - timer->add_func_list(online_data_cleanup, "online_data_cleanup"); - timer->add_interval(timer->gettick() + 600*1000, online_data_cleanup, 0, 0, 600*1000); + timer->add_func_list(login_online_data_cleanup, "login_online_data_cleanup"); + timer->add_interval(timer->gettick() + 600*1000, login_online_data_cleanup, 0, 0, 600*1000); // add timer to detect ip address change and perform update if (login_config.ip_sync_interval) { - timer->add_func_list(sync_ip_addresses, "sync_ip_addresses"); - timer->add_interval(timer->gettick() + login_config.ip_sync_interval, sync_ip_addresses, 0, 0, login_config.ip_sync_interval); + timer->add_func_list(login_sync_ip_addresses, "login_sync_ip_addresses"); + timer->add_interval(timer->gettick() + login_config.ip_sync_interval, login_sync_ip_addresses, 0, 0, login_config.ip_sync_interval); } // Account database init @@ -1868,7 +1868,7 @@ int do_init(int argc, char** argv) } if( runflag != CORE_ST_STOP ) { - shutdown_callback = do_shutdown; + shutdown_callback = do_shutdown_login; runflag = LOGINSERVER_ST_RUNNING; } -- cgit v1.2.3-70-g09d2 From fd2c59ce655ad560b2048343c232389819245078 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 25 Oct 2014 21:44:49 +0300 Subject: Split packet handling from login_parse_fromchar to functions in login.c --- src/login/login.c | 906 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 534 insertions(+), 372 deletions(-) diff --git a/src/login/login.c b/src/login/login.c index 6909a1a9c..b8b0e53f9 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -335,6 +335,519 @@ int login_lan_config_read(const char *lancfgName) return 0; } +void login_fromchar_auth_ack(int fd, int account_id, uint32 login_id1, uint32 login_id2, uint8 sex, int request_id, struct auth_node* node) +{ + WFIFOHEAD(fd,33); + WFIFOW(fd,0) = 0x2713; + WFIFOL(fd,2) = account_id; + WFIFOL(fd,6) = login_id1; + WFIFOL(fd,10) = login_id2; + WFIFOB(fd,14) = sex; + if (node) + { + WFIFOB(fd,15) = 0;// ok + WFIFOL(fd,16) = request_id; + WFIFOL(fd,20) = node->version; + WFIFOB(fd,24) = node->clienttype; + WFIFOL(fd,25) = node->group_id; + WFIFOL(fd,29) = (unsigned int)node->expiration_time; + } + else + { + WFIFOB(fd,15) = 1;// auth failed + WFIFOL(fd,16) = request_id; + WFIFOL(fd,20) = 0; + WFIFOB(fd,24) = 0; + WFIFOL(fd,25) = 0; + WFIFOL(fd,29) = 0; + } + WFIFOSET(fd,33); +} + +void login_fromchar_parse_auth(int fd, int id, const char *const ip) +{ + struct auth_node* node; + + int account_id = RFIFOL(fd,2); + uint32 login_id1 = RFIFOL(fd,6); + uint32 login_id2 = RFIFOL(fd,10); + uint8 sex = RFIFOB(fd,14); + //uint32 ip_ = ntohl(RFIFOL(fd,15)); + int request_id = RFIFOL(fd,19); + RFIFOSKIP(fd,23); + + node = (struct auth_node*)idb_get(auth_db, account_id); + if( runflag == LOGINSERVER_ST_RUNNING && + node != NULL && + node->account_id == account_id && + node->login_id1 == login_id1 && + node->login_id2 == login_id2 && + node->sex == sex_num2str(sex) /*&& + node->ip == ip_*/ ) + {// found + //ShowStatus("Char-server '%s': authentication of the account %d accepted (ip: %s).\n", server[id].name, account_id, ip); + + // send ack + login_fromchar_auth_ack(fd, account_id, login_id1, login_id2, sex, request_id, node); + // each auth entry can only be used once + idb_remove(auth_db, account_id); + } + else + {// authentication not found + ShowStatus("Char-server '%s': authentication of the account %d REFUSED (ip: %s).\n", server[id].name, account_id, ip); + login_fromchar_auth_ack(fd, account_id, login_id1, login_id2, sex, request_id, NULL); + } +} + +void login_fromchar_parse_update_users(int fd, int id) +{ + int users = RFIFOL(fd,2); + RFIFOSKIP(fd,6); + + // how many users on world? (update) + if( server[id].users != users ) + { + ShowStatus("set users %s : %d\n", server[id].name, users); + + server[id].users = (uint16)users; + } +} + +void login_fromchar_parse_request_change_email(int fd, int id, const char *const ip) +{ + struct mmo_account acc; + char email[40]; + + int account_id = RFIFOL(fd,2); + safestrncpy(email, (char*)RFIFOP(fd,6), 40); remove_control_chars(email); + RFIFOSKIP(fd,46); + + if( e_mail_check(email) == 0 ) + ShowNotice("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - e-mail is invalid (account: %d, ip: %s)\n", server[id].name, account_id, ip); + else + if( !accounts->load_num(accounts, &acc, account_id) || strcmp(acc.email, "a@a.com") == 0 || acc.email[0] == '\0' ) + ShowNotice("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - account doesn't exist or e-mail of account isn't default e-mail (account: %d, ip: %s).\n", server[id].name, account_id, ip); + else { + memcpy(acc.email, email, 40); + ShowNotice("Char-server '%s': Create an e-mail on an account with a default e-mail (account: %d, new e-mail: %s, ip: %s).\n", server[id].name, account_id, email, ip); + // Save + accounts->save(accounts, &acc); + } +} + +void login_fromchar_account(int fd, int account_id, struct mmo_account *acc) +{ + WFIFOHEAD(fd,72); + WFIFOW(fd,0) = 0x2717; + WFIFOL(fd,2) = account_id; + if (acc) + { + time_t expiration_time = 0; + char email[40] = ""; + int group_id = 0; + uint8 char_slots = 0; + char birthdate[10+1] = ""; + char pincode[4+1] = "\0\0\0\0"; + + safestrncpy(email, acc->email, sizeof(email)); + expiration_time = acc->expiration_time; + group_id = acc->group_id; + char_slots = acc->char_slots; + safestrncpy(pincode, acc->pincode, sizeof(pincode)); + safestrncpy(birthdate, acc->birthdate, sizeof(birthdate)); + if( strlen(pincode) == 0 ) + memset(pincode,'\0',sizeof(pincode)); + + safestrncpy((char*)WFIFOP(fd,6), email, 40); + WFIFOL(fd,46) = (uint32)expiration_time; + WFIFOB(fd,50) = (unsigned char)group_id; + WFIFOB(fd,51) = char_slots; + safestrncpy((char*)WFIFOP(fd,52), birthdate, 10+1); + safestrncpy((char*)WFIFOP(fd,63), pincode, 4+1 ); + WFIFOL(fd,68) = acc->pincode_change; + } + else + { + safestrncpy((char*)WFIFOP(fd,6), "", 40); + WFIFOL(fd,46) = 0; + WFIFOB(fd,50) = 0; + WFIFOB(fd,51) = 0; + safestrncpy((char*)WFIFOP(fd,52), "", 10+1); + safestrncpy((char*)WFIFOP(fd,63), "\0\0\0\0", 4+1 ); + WFIFOL(fd,68) = 0; + } + WFIFOSET(fd,72); +} + +void login_fromchar_parse_account_data(int fd, int id, const char *const ip) +{ + struct mmo_account acc; + + int account_id = RFIFOL(fd,2); + RFIFOSKIP(fd,6); + + if( !accounts->load_num(accounts, &acc, account_id) ) + { + ShowNotice("Char-server '%s': account %d NOT found (ip: %s).\n", server[id].name, account_id, ip); + login_fromchar_account(fd, account_id, NULL); + } + else { + login_fromchar_account(fd, account_id, &acc); + } +} + +void login_fromchar_pong(int fd) +{ + WFIFOHEAD(fd,2); + WFIFOW(fd,0) = 0x2718; + WFIFOSET(fd,2); +} + +void login_fromchar_parse_ping(int fd) +{ + RFIFOSKIP(fd,2); + login_fromchar_pong(fd); +} + +void login_fromchar_parse_change_email(int fd, int id, const char *const ip) +{ + struct mmo_account acc; + char actual_email[40]; + char new_email[40]; + + int account_id = RFIFOL(fd,2); + safestrncpy(actual_email, (char*)RFIFOP(fd,6), 40); + safestrncpy(new_email, (char*)RFIFOP(fd,46), 40); + RFIFOSKIP(fd, 86); + + if( e_mail_check(actual_email) == 0 ) + ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual email is invalid (account: %d, ip: %s)\n", server[id].name, account_id, ip); + else + if( e_mail_check(new_email) == 0 ) + ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a invalid new e-mail (account: %d, ip: %s)\n", server[id].name, account_id, ip); + else + if( strcmpi(new_email, "a@a.com") == 0 ) + ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a default e-mail (account: %d, ip: %s)\n", server[id].name, account_id, ip); + else + if( !accounts->load_num(accounts, &acc, account_id) ) + ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but account doesn't exist (account: %d, ip: %s).\n", server[id].name, account_id, ip); + else + if( strcmpi(acc.email, actual_email) != 0 ) + ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual e-mail is incorrect (account: %d (%s), actual e-mail: %s, proposed e-mail: %s, ip: %s).\n", server[id].name, account_id, acc.userid, acc.email, actual_email, ip); + else { + safestrncpy(acc.email, new_email, 40); + ShowNotice("Char-server '%s': Modify an e-mail on an account (@email GM command) (account: %d (%s), new e-mail: %s, ip: %s).\n", server[id].name, account_id, acc.userid, new_email, ip); + // Save + accounts->save(accounts, &acc); + } +} + +void login_fromchar_account_update_other(int account_id, unsigned int state) +{ + uint8 buf[11]; + WBUFW(buf,0) = 0x2731; + WBUFL(buf,2) = account_id; + WBUFB(buf,6) = 0; // 0: change of state, 1: ban + WBUFL(buf,7) = state; // status or final date of a banishment + charif_sendallwos(-1, buf, 11); +} + +void login_fromchar_parse_account_update(int fd, int id, const char *const ip) +{ + struct mmo_account acc; + + int account_id = RFIFOL(fd,2); + unsigned int state = RFIFOL(fd,6); + RFIFOSKIP(fd,10); + + if( !accounts->load_num(accounts, &acc, account_id) ) + ShowNotice("Char-server '%s': Error of Status change (account: %d not found, suggested status %d, ip: %s).\n", server[id].name, account_id, state, ip); + else + if( acc.state == state ) + ShowNotice("Char-server '%s': Error of Status change - actual status is already the good status (account: %d, status %d, ip: %s).\n", server[id].name, account_id, state, ip); + else { + ShowNotice("Char-server '%s': Status change (account: %d, new status %d, ip: %s).\n", server[id].name, account_id, state, ip); + + acc.state = state; + // Save + accounts->save(accounts, &acc); + + // notify other servers + if (state != 0) { + login_fromchar_account_update_other(account_id, state); + } + } +} + +void login_fromchar_ban(int account_id, time_t timestamp) +{ + uint8 buf[11]; + WBUFW(buf,0) = 0x2731; + WBUFL(buf,2) = account_id; + WBUFB(buf,6) = 1; // 0: change of status, 1: ban + WBUFL(buf,7) = (uint32)timestamp; // status or final date of a banishment + charif_sendallwos(-1, buf, 11); +} + +void login_fromchar_parse_ban(int fd, int id, const char *const ip) +{ + struct mmo_account acc; + + int account_id = RFIFOL(fd,2); + int year = (short)RFIFOW(fd,6); + int month = (short)RFIFOW(fd,8); + int mday = (short)RFIFOW(fd,10); + int hour = (short)RFIFOW(fd,12); + int min = (short)RFIFOW(fd,14); + int sec = (short)RFIFOW(fd,16); + RFIFOSKIP(fd,18); + + if (!accounts->load_num(accounts, &acc, account_id)) { + ShowNotice("Char-server '%s': Error of ban request (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); + } else { + time_t timestamp; + struct tm *tmtime; + if (acc.unban_time == 0 || acc.unban_time < time(NULL)) + timestamp = time(NULL); // new ban + else + timestamp = acc.unban_time; // add to existing ban + tmtime = localtime(×tamp); + tmtime->tm_year += year; + tmtime->tm_mon += month; + tmtime->tm_mday += mday; + tmtime->tm_hour += hour; + tmtime->tm_min += min; + tmtime->tm_sec += sec; + timestamp = mktime(tmtime); + if (timestamp == -1) { + ShowNotice("Char-server '%s': Error of ban request (account: %d, invalid date, ip: %s).\n", server[id].name, account_id, ip); + } else if( timestamp <= time(NULL) || timestamp == 0 ) { + ShowNotice("Char-server '%s': Error of ban request (account: %d, new date unbans the account, ip: %s).\n", server[id].name, account_id, ip); + } else { + char tmpstr[24]; + timestamp2string(tmpstr, sizeof(tmpstr), timestamp, login_config.date_format); + ShowNotice("Char-server '%s': Ban request (account: %d, new final date of banishment: %ld (%s), ip: %s).\n", + server[id].name, account_id, (long)timestamp, tmpstr, ip); + + acc.unban_time = timestamp; + + // Save + accounts->save(accounts, &acc); + + login_fromchar_ban(account_id, timestamp); + } + } +} + +void login_fromchar_change_sex_other(int account_id, char sex) +{ + unsigned char buf[7]; + WBUFW(buf,0) = 0x2723; + WBUFL(buf,2) = account_id; + WBUFB(buf,6) = sex_str2num(sex); + charif_sendallwos(-1, buf, 7); +} + +void login_fromchar_parse_change_sex(int fd, int id, const char *const ip) +{ + struct mmo_account acc; + + int account_id = RFIFOL(fd,2); + RFIFOSKIP(fd,6); + + if( !accounts->load_num(accounts, &acc, account_id) ) + ShowNotice("Char-server '%s': Error of sex change (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); + else + if( acc.sex == 'S' ) + ShowNotice("Char-server '%s': Error of sex change - account to change is a Server account (account: %d, ip: %s).\n", server[id].name, account_id, ip); + else + { + char sex = ( acc.sex == 'M' ) ? 'F' : 'M'; //Change gender + + ShowNotice("Char-server '%s': Sex change (account: %d, new sex %c, ip: %s).\n", server[id].name, account_id, sex, ip); + + acc.sex = sex; + // Save + accounts->save(accounts, &acc); + + // announce to other servers + login_fromchar_change_sex_other(account_id, sex); + } +} + +void login_fromchar_parse_account_reg2(int fd, int id, const char *const ip) +{ + struct mmo_account acc; + + int account_id = RFIFOL(fd,4); + + if( !accounts->load_num(accounts, &acc, account_id) ) + ShowStatus("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); + else { + mmo_save_accreg2(accounts,fd,account_id,RFIFOL(fd, 8)); + } + RFIFOSKIP(fd,RFIFOW(fd,2)); +} + +void login_fromchar_parse_unban(int fd, int id, const char *const ip) +{ + struct mmo_account acc; + + int account_id = RFIFOL(fd,2); + RFIFOSKIP(fd,6); + + if( !accounts->load_num(accounts, &acc, account_id) ) + ShowNotice("Char-server '%s': Error of Unban request (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); + else + if( acc.unban_time == 0 ) + ShowNotice("Char-server '%s': Error of Unban request (account: %d, no change for unban date, ip: %s).\n", server[id].name, account_id, ip); + else + { + ShowNotice("Char-server '%s': Unban request (account: %d, ip: %s).\n", server[id].name, account_id, ip); + acc.unban_time = 0; + accounts->save(accounts, &acc); + } +} + +void login_fromchar_parse_account_online(int fd, int id) +{ + login_add_online_user(id, RFIFOL(fd,2)); + RFIFOSKIP(fd,6); +} + +void login_fromchar_parse_account_offline(int fd) +{ + login_remove_online_user(RFIFOL(fd,2)); + RFIFOSKIP(fd,6); +} + +void login_fromchar_parse_online_accounts(int fd, int id) +{ + struct online_login_data *p; + int aid; + uint32 i, users; + online_db->foreach(online_db, login_online_db_setoffline, id); //Set all chars from this char-server offline first + users = RFIFOW(fd,4); + for (i = 0; i < users; i++) { + aid = RFIFOL(fd,6+i*4); + p = idb_ensure(online_db, aid, login_create_online_user); + p->char_server = id; + if (p->waiting_disconnect != INVALID_TIMER) + { + timer->delete(p->waiting_disconnect, login_waiting_disconnect_timer); + p->waiting_disconnect = INVALID_TIMER; + } + } +} + +void login_fromchar_parse_request_account_reg2(int fd) +{ + int account_id = RFIFOL(fd,2); + int char_id = RFIFOL(fd,6); + RFIFOSKIP(fd,10); + + mmo_send_accreg2(accounts,fd,account_id,char_id); +} + +void login_fromchar_parse_update_wan_ip(int fd, int id) +{ + server[id].ip = ntohl(RFIFOL(fd,2)); + ShowInfo("Updated IP of Server #%d to %d.%d.%d.%d.\n",id, CONVIP(server[id].ip)); + RFIFOSKIP(fd,6); +} + +void login_fromchar_parse_all_offline(int fd, int id) +{ + ShowInfo("Setting accounts from char-server %d offline.\n", id); + online_db->foreach(online_db, login_online_db_setoffline, id); + RFIFOSKIP(fd,2); +} + +void login_fromchar_parse_change_pincode(int fd) +{ + struct mmo_account acc; + + if( accounts->load_num(accounts, &acc, RFIFOL(fd,2) ) ) { + strncpy( acc.pincode, (char*)RFIFOP(fd,6), 5 ); + acc.pincode_change = ((unsigned int)time( NULL )); + accounts->save(accounts, &acc); + } + RFIFOSKIP(fd,11); +} + +bool login_fromchar_parse_wrong_pincode(int fd) +{ + struct mmo_account acc; + + if( accounts->load_num(accounts, &acc, RFIFOL(fd,2) ) ) { + struct online_login_data* ld; + + if( ( ld = (struct online_login_data*)idb_get(online_db,acc.account_id) ) == NULL ) + { + RFIFOSKIP(fd,6); + return true; + } + + login_log( host2ip(acc.last_ip), acc.userid, 100, "PIN Code check failed" ); + } + + login_remove_online_user(acc.account_id); + RFIFOSKIP(fd,6); + return false; +} + +void login_fromchar_accinfo(int fd, int account_id, int u_fd, int u_aid, int u_group, int map_fd, struct mmo_account *acc) +{ + if (acc) + { + WFIFOHEAD(fd,183); + WFIFOW(fd,0) = 0x2737; + safestrncpy((char*)WFIFOP(fd,2), acc->userid, NAME_LENGTH); + if (u_group >= acc->group_id) + safestrncpy((char*)WFIFOP(fd,26), acc->pass, 33); + else + memset(WFIFOP(fd,26), '\0', 33); + safestrncpy((char*)WFIFOP(fd,59), acc->email, 40); + safestrncpy((char*)WFIFOP(fd,99), acc->last_ip, 16); + WFIFOL(fd,115) = acc->group_id; + safestrncpy((char*)WFIFOP(fd,119), acc->lastlogin, 24); + WFIFOL(fd,143) = acc->logincount; + WFIFOL(fd,147) = acc->state; + if (u_group >= acc->group_id) + safestrncpy((char*)WFIFOP(fd,151), acc->pincode, 5); + else + memset(WFIFOP(fd,151), '\0', 5); + safestrncpy((char*)WFIFOP(fd,156), acc->birthdate, 11); + WFIFOL(fd,167) = map_fd; + WFIFOL(fd,171) = u_fd; + WFIFOL(fd,175) = u_aid; + WFIFOL(fd,179) = account_id; + WFIFOSET(fd,183); + } + else + { + WFIFOHEAD(fd,18); + WFIFOW(fd,0) = 0x2736; + WFIFOL(fd,2) = map_fd; + WFIFOL(fd,6) = u_fd; + WFIFOL(fd,10) = u_aid; + WFIFOL(fd,14) = account_id; + WFIFOSET(fd,18); + } +} + +void login_fromchar_parse_accinfo(int fd) +{ + struct mmo_account acc; + int account_id = RFIFOL(fd, 2), u_fd = RFIFOL(fd, 6), u_aid = RFIFOL(fd, 10), u_group = RFIFOL(fd, 14), map_fd = RFIFOL(fd, 18); + if (accounts->load_num(accounts, &acc, account_id)) { + login_fromchar_accinfo(fd, account_id, u_fd, u_aid, u_group, map_fd, &acc); + } else { + login_fromchar_accinfo(fd, account_id, u_fd, u_aid, u_group, map_fd, NULL); + } + RFIFOSKIP(fd,22); +} + //-------------------------------- // Packet parsing for char-servers //-------------------------------- @@ -380,62 +893,7 @@ int login_parse_fromchar(int fd) if( RFIFOREST(fd) < 23 ) return 0; { - struct auth_node* node; - - int account_id = RFIFOL(fd,2); - uint32 login_id1 = RFIFOL(fd,6); - uint32 login_id2 = RFIFOL(fd,10); - uint8 sex = RFIFOB(fd,14); - //uint32 ip_ = ntohl(RFIFOL(fd,15)); - int request_id = RFIFOL(fd,19); - RFIFOSKIP(fd,23); - - node = (struct auth_node*)idb_get(auth_db, account_id); - if( runflag == LOGINSERVER_ST_RUNNING && - node != NULL && - node->account_id == account_id && - node->login_id1 == login_id1 && - node->login_id2 == login_id2 && - node->sex == sex_num2str(sex) /*&& - node->ip == ip_*/ ) - {// found - //ShowStatus("Char-server '%s': authentication of the account %d accepted (ip: %s).\n", server[id].name, account_id, ip); - - // send ack - WFIFOHEAD(fd,33); - WFIFOW(fd,0) = 0x2713; - WFIFOL(fd,2) = account_id; - WFIFOL(fd,6) = login_id1; - WFIFOL(fd,10) = login_id2; - WFIFOB(fd,14) = sex; - WFIFOB(fd,15) = 0;// ok - WFIFOL(fd,16) = request_id; - WFIFOL(fd,20) = node->version; - WFIFOB(fd,24) = node->clienttype; - WFIFOL(fd,25) = node->group_id; - WFIFOL(fd,29) = (unsigned int)node->expiration_time; - WFIFOSET(fd,33); - - // each auth entry can only be used once - idb_remove(auth_db, account_id); - } - else - {// authentication not found - ShowStatus("Char-server '%s': authentication of the account %d REFUSED (ip: %s).\n", server[id].name, account_id, ip); - WFIFOHEAD(fd,33); - WFIFOW(fd,0) = 0x2713; - WFIFOL(fd,2) = account_id; - WFIFOL(fd,6) = login_id1; - WFIFOL(fd,10) = login_id2; - WFIFOB(fd,14) = sex; - WFIFOB(fd,15) = 1;// auth failed - WFIFOL(fd,16) = request_id; - WFIFOL(fd,20) = 0; - WFIFOB(fd,24) = 0; - WFIFOL(fd,25) = 0; - WFIFOL(fd,29) = 0; - WFIFOSET(fd,33); - } + login_fromchar_parse_auth(fd, id, ip); } break; @@ -443,16 +901,7 @@ int login_parse_fromchar(int fd) if( RFIFOREST(fd) < 6 ) return 0; { - int users = RFIFOL(fd,2); - RFIFOSKIP(fd,6); - - // how many users on world? (update) - if( server[id].users != users ) - { - ShowStatus("set users %s : %d\n", server[id].name, users); - - server[id].users = (uint16)users; - } + login_fromchar_parse_update_users(fd, id); } break; @@ -460,24 +909,7 @@ int login_parse_fromchar(int fd) if (RFIFOREST(fd) < 46) return 0; { - struct mmo_account acc; - char email[40]; - - int account_id = RFIFOL(fd,2); - safestrncpy(email, (char*)RFIFOP(fd,6), 40); remove_control_chars(email); - RFIFOSKIP(fd,46); - - if( e_mail_check(email) == 0 ) - ShowNotice("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - e-mail is invalid (account: %d, ip: %s)\n", server[id].name, account_id, ip); - else - if( !accounts->load_num(accounts, &acc, account_id) || strcmp(acc.email, "a@a.com") == 0 || acc.email[0] == '\0' ) - ShowNotice("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - account doesn't exist or e-mail of account isn't default e-mail (account: %d, ip: %s).\n", server[id].name, account_id, ip); - else { - memcpy(acc.email, email, 40); - ShowNotice("Char-server '%s': Create an e-mail on an account with a default e-mail (account: %d, new e-mail: %s, ip: %s).\n", server[id].name, account_id, email, ip); - // Save - accounts->save(accounts, &acc); - } + login_fromchar_parse_request_change_email(fd, id, ip); } break; @@ -485,50 +917,12 @@ int login_parse_fromchar(int fd) if( RFIFOREST(fd) < 6 ) return 0; { - struct mmo_account acc; - time_t expiration_time = 0; - char email[40] = ""; - int group_id = 0; - uint8 char_slots = 0; - char birthdate[10+1] = ""; - char pincode[4+1] = "\0\0\0\0"; - - int account_id = RFIFOL(fd,2); - RFIFOSKIP(fd,6); - - if( !accounts->load_num(accounts, &acc, account_id) ) - ShowNotice("Char-server '%s': account %d NOT found (ip: %s).\n", server[id].name, account_id, ip); - else { - safestrncpy(email, acc.email, sizeof(email)); - expiration_time = acc.expiration_time; - group_id = acc.group_id; - char_slots = acc.char_slots; - safestrncpy(pincode, acc.pincode, sizeof(pincode)); - safestrncpy(birthdate, acc.birthdate, sizeof(birthdate)); - if( strlen(pincode) == 0 ) - memset(pincode,'\0',sizeof(pincode)); - } - - WFIFOHEAD(fd,72); - WFIFOW(fd,0) = 0x2717; - WFIFOL(fd,2) = account_id; - safestrncpy((char*)WFIFOP(fd,6), email, 40); - WFIFOL(fd,46) = (uint32)expiration_time; - WFIFOB(fd,50) = (unsigned char)group_id; - WFIFOB(fd,51) = char_slots; - safestrncpy((char*)WFIFOP(fd,52), birthdate, 10+1); - safestrncpy((char*)WFIFOP(fd,63), pincode, 4+1 ); - WFIFOL(fd,68) = acc.pincode_change; - WFIFOSET(fd,72); + login_fromchar_parse_account_data(fd, id, ip); } break; case 0x2719: // ping request from charserver - RFIFOSKIP(fd,2); - - WFIFOHEAD(fd,2); - WFIFOW(fd,0) = 0x2718; - WFIFOSET(fd,2); + login_fromchar_parse_ping(fd); break; // Map server send information to change an email of an account via char-server @@ -536,35 +930,7 @@ int login_parse_fromchar(int fd) if (RFIFOREST(fd) < 86) return 0; { - struct mmo_account acc; - char actual_email[40]; - char new_email[40]; - - int account_id = RFIFOL(fd,2); - safestrncpy(actual_email, (char*)RFIFOP(fd,6), 40); - safestrncpy(new_email, (char*)RFIFOP(fd,46), 40); - RFIFOSKIP(fd, 86); - - if( e_mail_check(actual_email) == 0 ) - ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual email is invalid (account: %d, ip: %s)\n", server[id].name, account_id, ip); - else - if( e_mail_check(new_email) == 0 ) - ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a invalid new e-mail (account: %d, ip: %s)\n", server[id].name, account_id, ip); - else - if( strcmpi(new_email, "a@a.com") == 0 ) - ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a default e-mail (account: %d, ip: %s)\n", server[id].name, account_id, ip); - else - if( !accounts->load_num(accounts, &acc, account_id) ) - ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but account doesn't exist (account: %d, ip: %s).\n", server[id].name, account_id, ip); - else - if( strcmpi(acc.email, actual_email) != 0 ) - ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual e-mail is incorrect (account: %d (%s), actual e-mail: %s, proposed e-mail: %s, ip: %s).\n", server[id].name, account_id, acc.userid, acc.email, actual_email, ip); - else { - safestrncpy(acc.email, new_email, 40); - ShowNotice("Char-server '%s': Modify an e-mail on an account (@email GM command) (account: %d (%s), new e-mail: %s, ip: %s).\n", server[id].name, account_id, acc.userid, new_email, ip); - // Save - accounts->save(accounts, &acc); - } + login_fromchar_parse_change_email(fd, id, ip); } break; @@ -572,34 +938,7 @@ int login_parse_fromchar(int fd) if (RFIFOREST(fd) < 10) return 0; { - struct mmo_account acc; - - int account_id = RFIFOL(fd,2); - unsigned int state = RFIFOL(fd,6); - RFIFOSKIP(fd,10); - - if( !accounts->load_num(accounts, &acc, account_id) ) - ShowNotice("Char-server '%s': Error of Status change (account: %d not found, suggested status %d, ip: %s).\n", server[id].name, account_id, state, ip); - else - if( acc.state == state ) - ShowNotice("Char-server '%s': Error of Status change - actual status is already the good status (account: %d, status %d, ip: %s).\n", server[id].name, account_id, state, ip); - else { - ShowNotice("Char-server '%s': Status change (account: %d, new status %d, ip: %s).\n", server[id].name, account_id, state, ip); - - acc.state = state; - // Save - accounts->save(accounts, &acc); - - // notify other servers - if (state != 0) { - uint8 buf[11]; - WBUFW(buf,0) = 0x2731; - WBUFL(buf,2) = account_id; - WBUFB(buf,6) = 0; // 0: change of state, 1: ban - WBUFL(buf,7) = state; // status or final date of a banishment - charif_sendallwos(-1, buf, 11); - } - } + login_fromchar_parse_account_update(fd, id, ip); } break; @@ -607,57 +946,7 @@ int login_parse_fromchar(int fd) if (RFIFOREST(fd) < 18) return 0; { - struct mmo_account acc; - - int account_id = RFIFOL(fd,2); - int year = (short)RFIFOW(fd,6); - int month = (short)RFIFOW(fd,8); - int mday = (short)RFIFOW(fd,10); - int hour = (short)RFIFOW(fd,12); - int min = (short)RFIFOW(fd,14); - int sec = (short)RFIFOW(fd,16); - RFIFOSKIP(fd,18); - - if (!accounts->load_num(accounts, &acc, account_id)) { - ShowNotice("Char-server '%s': Error of ban request (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); - } else { - time_t timestamp; - struct tm *tmtime; - if (acc.unban_time == 0 || acc.unban_time < time(NULL)) - timestamp = time(NULL); // new ban - else - timestamp = acc.unban_time; // add to existing ban - tmtime = localtime(×tamp); - tmtime->tm_year += year; - tmtime->tm_mon += month; - tmtime->tm_mday += mday; - tmtime->tm_hour += hour; - tmtime->tm_min += min; - tmtime->tm_sec += sec; - timestamp = mktime(tmtime); - if (timestamp == -1) { - ShowNotice("Char-server '%s': Error of ban request (account: %d, invalid date, ip: %s).\n", server[id].name, account_id, ip); - } else if( timestamp <= time(NULL) || timestamp == 0 ) { - ShowNotice("Char-server '%s': Error of ban request (account: %d, new date unbans the account, ip: %s).\n", server[id].name, account_id, ip); - } else { - uint8 buf[11]; - char tmpstr[24]; - timestamp2string(tmpstr, sizeof(tmpstr), timestamp, login_config.date_format); - ShowNotice("Char-server '%s': Ban request (account: %d, new final date of banishment: %ld (%s), ip: %s).\n", - server[id].name, account_id, (long)timestamp, tmpstr, ip); - - acc.unban_time = timestamp; - - // Save - accounts->save(accounts, &acc); - - WBUFW(buf,0) = 0x2731; - WBUFL(buf,2) = account_id; - WBUFB(buf,6) = 1; // 0: change of status, 1: ban - WBUFL(buf,7) = (uint32)timestamp; // status or final date of a banishment - charif_sendallwos(-1, buf, 11); - } - } + login_fromchar_parse_ban(fd, id, ip); } break; @@ -665,33 +954,7 @@ int login_parse_fromchar(int fd) if( RFIFOREST(fd) < 6 ) return 0; { - struct mmo_account acc; - - int account_id = RFIFOL(fd,2); - RFIFOSKIP(fd,6); - - if( !accounts->load_num(accounts, &acc, account_id) ) - ShowNotice("Char-server '%s': Error of sex change (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); - else - if( acc.sex == 'S' ) - ShowNotice("Char-server '%s': Error of sex change - account to change is a Server account (account: %d, ip: %s).\n", server[id].name, account_id, ip); - else - { - unsigned char buf[7]; - char sex = ( acc.sex == 'M' ) ? 'F' : 'M'; //Change gender - - ShowNotice("Char-server '%s': Sex change (account: %d, new sex %c, ip: %s).\n", server[id].name, account_id, sex, ip); - - acc.sex = sex; - // Save - accounts->save(accounts, &acc); - - // announce to other servers - WBUFW(buf,0) = 0x2723; - WBUFL(buf,2) = account_id; - WBUFB(buf,6) = sex_str2num(sex); - charif_sendallwos(-1, buf, 7); - } + login_fromchar_parse_change_sex(fd, id, ip); } break; @@ -699,16 +962,7 @@ int login_parse_fromchar(int fd) if( RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2) ) return 0; { - struct mmo_account acc; - - int account_id = RFIFOL(fd,4); - - if( !accounts->load_num(accounts, &acc, account_id) ) - ShowStatus("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); - else { - mmo_save_accreg2(accounts,fd,account_id,RFIFOL(fd, 8)); - } - RFIFOSKIP(fd,RFIFOW(fd,2)); + login_fromchar_parse_account_reg2(fd, id, ip); } break; @@ -716,58 +970,27 @@ int login_parse_fromchar(int fd) if( RFIFOREST(fd) < 6 ) return 0; { - struct mmo_account acc; - - int account_id = RFIFOL(fd,2); - RFIFOSKIP(fd,6); - - if( !accounts->load_num(accounts, &acc, account_id) ) - ShowNotice("Char-server '%s': Error of Unban request (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); - else - if( acc.unban_time == 0 ) - ShowNotice("Char-server '%s': Error of Unban request (account: %d, no change for unban date, ip: %s).\n", server[id].name, account_id, ip); - else - { - ShowNotice("Char-server '%s': Unban request (account: %d, ip: %s).\n", server[id].name, account_id, ip); - acc.unban_time = 0; - accounts->save(accounts, &acc); - } + login_fromchar_parse_unban(fd, id, ip); } break; case 0x272b: // Set account_id to online [Wizputer] if( RFIFOREST(fd) < 6 ) return 0; - login_add_online_user(id, RFIFOL(fd,2)); - RFIFOSKIP(fd,6); + login_fromchar_parse_account_online(fd, id); break; case 0x272c: // Set account_id to offline [Wizputer] if( RFIFOREST(fd) < 6 ) return 0; - login_remove_online_user(RFIFOL(fd,2)); - RFIFOSKIP(fd,6); + login_fromchar_parse_account_offline(fd); break; case 0x272d: // Receive list of all online accounts. [Skotlex] if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) return 0; { - struct online_login_data *p; - int aid; - uint32 i, users; - online_db->foreach(online_db, login_online_db_setoffline, id); //Set all chars from this char-server offline first - users = RFIFOW(fd,4); - for (i = 0; i < users; i++) { - aid = RFIFOL(fd,6+i*4); - p = idb_ensure(online_db, aid, login_create_online_user); - p->char_server = id; - if (p->waiting_disconnect != INVALID_TIMER) - { - timer->delete(p->waiting_disconnect, login_waiting_disconnect_timer); - p->waiting_disconnect = INVALID_TIMER; - } - } + login_fromchar_parse_online_accounts(fd, id); } RFIFOSKIP(fd,RFIFOW(fd,2)); break; @@ -776,40 +999,25 @@ int login_parse_fromchar(int fd) if (RFIFOREST(fd) < 10) return 0; { - int account_id = RFIFOL(fd,2); - int char_id = RFIFOL(fd,6); - RFIFOSKIP(fd,10); - - mmo_send_accreg2(accounts,fd,account_id,char_id); + login_fromchar_parse_request_account_reg2(fd); } break; case 0x2736: // WAN IP update from char-server if( RFIFOREST(fd) < 6 ) return 0; - server[id].ip = ntohl(RFIFOL(fd,2)); - ShowInfo("Updated IP of Server #%d to %d.%d.%d.%d.\n",id, CONVIP(server[id].ip)); - RFIFOSKIP(fd,6); + login_fromchar_parse_update_wan_ip(fd, id); break; case 0x2737: //Request to set all offline. - ShowInfo("Setting accounts from char-server %d offline.\n", id); - online_db->foreach(online_db, login_online_db_setoffline, id); - RFIFOSKIP(fd,2); + login_fromchar_parse_all_offline(fd, id); break; case 0x2738: //Change PIN Code for a account if( RFIFOREST(fd) < 11 ) return 0; else { - struct mmo_account acc; - - if( accounts->load_num(accounts, &acc, RFIFOL(fd,2) ) ) { - strncpy( acc.pincode, (char*)RFIFOP(fd,6), 5 ); - acc.pincode_change = ((unsigned int)time( NULL )); - accounts->save(accounts, &acc); - } - RFIFOSKIP(fd,11); + login_fromchar_parse_change_pincode(fd); } break; @@ -817,19 +1025,8 @@ int login_parse_fromchar(int fd) if( RFIFOREST(fd) < 6 ) return 0; else { - struct mmo_account acc; - - if( accounts->load_num(accounts, &acc, RFIFOL(fd,2) ) ) { - struct online_login_data* ld; - - if( ( ld = (struct online_login_data*)idb_get(online_db,acc.account_id) ) == NULL ) - return 0; - - login_log( host2ip(acc.last_ip), acc.userid, 100, "PIN Code check failed" ); - } - - login_remove_online_user(acc.account_id); - RFIFOSKIP(fd,6); + if (login_fromchar_parse_wrong_pincode(fd)) + return 0; } break; @@ -837,42 +1034,7 @@ int login_parse_fromchar(int fd) if( RFIFOREST(fd) < 22 ) return 0; else { - struct mmo_account acc; - int account_id = RFIFOL(fd, 2), u_fd = RFIFOL(fd, 6), u_aid = RFIFOL(fd, 10), u_group = RFIFOL(fd, 14), map_fd = RFIFOL(fd, 18); - if (accounts->load_num(accounts, &acc, account_id)) { - WFIFOHEAD(fd,183); - WFIFOW(fd,0) = 0x2737; - safestrncpy((char*)WFIFOP(fd,2), acc.userid, NAME_LENGTH); - if (u_group >= acc.group_id) - safestrncpy((char*)WFIFOP(fd,26), acc.pass, 33); - else - memset(WFIFOP(fd,26), '\0', 33); - safestrncpy((char*)WFIFOP(fd,59), acc.email, 40); - safestrncpy((char*)WFIFOP(fd,99), acc.last_ip, 16); - WFIFOL(fd,115) = acc.group_id; - safestrncpy((char*)WFIFOP(fd,119), acc.lastlogin, 24); - WFIFOL(fd,143) = acc.logincount; - WFIFOL(fd,147) = acc.state; - if (u_group >= acc.group_id) - safestrncpy((char*)WFIFOP(fd,151), acc.pincode, 5); - else - memset(WFIFOP(fd,151), '\0', 5); - safestrncpy((char*)WFIFOP(fd,156), acc.birthdate, 11); - WFIFOL(fd,167) = map_fd; - WFIFOL(fd,171) = u_fd; - WFIFOL(fd,175) = u_aid; - WFIFOL(fd,179) = account_id; - WFIFOSET(fd,183); - } else { - WFIFOHEAD(fd,18); - WFIFOW(fd,0) = 0x2736; - WFIFOL(fd,2) = map_fd; - WFIFOL(fd,6) = u_fd; - WFIFOL(fd,10) = u_aid; - WFIFOL(fd,14) = account_id; - WFIFOSET(fd,18); - } - RFIFOSKIP(fd,22); + login_fromchar_parse_accinfo(fd); } break; default: -- cgit v1.2.3-70-g09d2 From c0af6d5fda1ca6ad97b57fe36aecd49be9b15977 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 25 Oct 2014 23:21:32 +0300 Subject: Split packet handling from login_auth_ok to functions in login.c --- src/login/login.c | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/login/login.c b/src/login/login.c index b8b0e53f9..5079225d2 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -1244,6 +1244,22 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) { return -1; // account OK } +void login_connection_problem(int fd, uint8 status) +{ + WFIFOHEAD(fd,3); + WFIFOW(fd,0) = 0x81; + WFIFOB(fd,2) = status; + WFIFOSET(fd,3); +} + +void login_kick(struct login_session_data* sd) +{ + uint8 buf[6]; + WBUFW(buf,0) = 0x2734; + WBUFL(buf,2) = sd->account_id; + charif_sendallwos(-1, buf, 6); +} + void login_auth_ok(struct login_session_data* sd) { int fd = sd->fd; @@ -1257,26 +1273,17 @@ void login_auth_ok(struct login_session_data* sd) if( runflag != LOGINSERVER_ST_RUNNING ) { // players can only login while running - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x81; - WFIFOB(fd,2) = 1;// server closed - WFIFOSET(fd,3); + login_connection_problem(fd, 1); // 01 = server closed return; } if( login_config.group_id_to_connect >= 0 && sd->group_id != login_config.group_id_to_connect ) { ShowStatus("Connection refused: the required group id for connection is %d (account: %s, group: %d).\n", login_config.group_id_to_connect, sd->userid, sd->group_id); - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x81; - WFIFOB(fd,2) = 1; // 01 = Server closed - WFIFOSET(fd,3); + login_connection_problem(fd, 1); // 01 = server closed return; } else if( login_config.min_group_id_to_connect >= 0 && login_config.group_id_to_connect == -1 && sd->group_id < login_config.min_group_id_to_connect ) { ShowStatus("Connection refused: the minimum group id required for connection is %d (account: %s, group: %d).\n", login_config.min_group_id_to_connect, sd->userid, sd->group_id); - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x81; - WFIFOB(fd,2) = 1; // 01 = Server closed - WFIFOSET(fd,3); + login_connection_problem(fd, 1); // 01 = server closed return; } @@ -1288,10 +1295,7 @@ void login_auth_ok(struct login_session_data* sd) if( server_num == 0 ) {// if no char-server, don't send void list of servers, just disconnect the player with proper message ShowStatus("Connection refused: there is no char-server online (account: %s).\n", sd->userid); - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x81; - WFIFOB(fd,2) = 1; // 01 = Server closed - WFIFOSET(fd,3); + login_connection_problem(fd, 1); // 01 = server closed return; } @@ -1301,18 +1305,12 @@ void login_auth_ok(struct login_session_data* sd) {// account is already marked as online! if( data->char_server > -1 ) {// Request char servers to kick this account out. [Skotlex] - uint8 buf[6]; ShowNotice("User '%s' is already online - Rejected.\n", sd->userid); - WBUFW(buf,0) = 0x2734; - WBUFL(buf,2) = sd->account_id; - charif_sendallwos(-1, buf, 6); + login_kick(sd); if( data->waiting_disconnect == INVALID_TIMER ) data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, login_waiting_disconnect_timer, sd->account_id, 0); - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x81; - WFIFOB(fd,2) = 8; // 08 = Server still recognizes your last login - WFIFOSET(fd,3); + login_connection_problem(fd, 8); // 08 = Server still recognizes your last login return; } else -- cgit v1.2.3-70-g09d2 From c9b3a68d4763cb75c47767791befefcbffc64a5f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 25 Oct 2014 23:55:43 +0300 Subject: Split packet handling from login_parse to functions in login.c --- src/login/login.c | 335 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 187 insertions(+), 148 deletions(-) diff --git a/src/login/login.c b/src/login/login.c index 5079225d2..929cce438 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -1450,6 +1450,187 @@ void login_auth_failed(struct login_session_data* sd, int result) #endif } +void login_login_error(int fd, uint8 status) +{ + WFIFOHEAD(fd,23); + WFIFOW(fd,0) = 0x6a; + WFIFOB(fd,2) = status; + WFIFOSET(fd,23); +} + +void login_parse_ping(int fd, struct login_session_data* sd) +{ + RFIFOSKIP(fd,26); +} + +void login_parse_client_md5(int fd, struct login_session_data* sd) +{ + sd->has_client_hash = 1; + memcpy(sd->client_hash, RFIFOP(fd, 2), 16); + + RFIFOSKIP(fd,18); +} + +bool login_parse_client_login(int fd, struct login_session_data* sd, const char *const ip) +{ + uint32 version; + char username[NAME_LENGTH]; + char password[PASSWD_LEN]; + unsigned char passhash[16]; + uint8 clienttype; + uint16 command = RFIFOW(fd,0); + bool israwpass = (command==0x0064 || command==0x0277 || command==0x02b0 || command == 0x0825); + + // Shinryo: For the time being, just use token as password. + if(command == 0x0825) + { + char *accname = (char *)RFIFOP(fd, 9); + char *token = (char *)RFIFOP(fd, 0x5C); + size_t uAccLen = strlen(accname); + size_t uTokenLen = RFIFOREST(fd) - 0x5C; + + version = RFIFOL(fd,4); + + if(uAccLen <= 0 || uTokenLen <= 0) { + login_auth_failed(sd, 3); + return true; + } + + safestrncpy(username, accname, NAME_LENGTH); + safestrncpy(password, token, min(uTokenLen+1, PASSWD_LEN)); // Variable-length field, don't copy more than necessary + clienttype = RFIFOB(fd, 8); + } + else + { + version = RFIFOL(fd,2); + safestrncpy(username, (const char*)RFIFOP(fd,6), NAME_LENGTH); + if( israwpass ) + { + safestrncpy(password, (const char*)RFIFOP(fd,30), NAME_LENGTH); + clienttype = RFIFOB(fd,54); + } + else + { + memcpy(passhash, RFIFOP(fd,30), 16); + clienttype = RFIFOB(fd,46); + } + } + RFIFOSKIP(fd,RFIFOREST(fd)); // assume no other packet was sent + + sd->clienttype = clienttype; + sd->version = version; + safestrncpy(sd->userid, username, NAME_LENGTH); + if( israwpass ) + { + ShowStatus("Request for connection of %s (ip: %s).\n", sd->userid, ip); + safestrncpy(sd->passwd, password, PASSWD_LEN); + if( login_config.use_md5_passwds ) + MD5_String(sd->passwd, sd->passwd); + sd->passwdenc = 0; + } + else + { + ShowStatus("Request for connection (passwdenc mode) of %s (ip: %s).\n", sd->userid, ip); + bin2hex(sd->passwd, passhash, 16); // raw binary data here! + sd->passwdenc = PASSWORDENC; + } + + if( sd->passwdenc != 0 && login_config.use_md5_passwds ) + { + login_auth_failed(sd, 3); // send "rejected from server" + return true; + } + + int result = login_mmo_auth(sd, false); + + if( result == -1 ) + login_auth_ok(sd); + else + login_auth_failed(sd, result); + return false; +} + +void login_send_coding_key(int fd, struct login_session_data* sd) +{ + WFIFOHEAD(fd,4 + sd->md5keylen); + WFIFOW(fd,0) = 0x01dc; + WFIFOW(fd,2) = 4 + sd->md5keylen; + memcpy(WFIFOP(fd,4), sd->md5key, sd->md5keylen); + WFIFOSET(fd,WFIFOW(fd,2)); +} + +void login_parse_request_coding_key(int fd, struct login_session_data* sd) +{ + memset(sd->md5key, '\0', sizeof(sd->md5key)); + sd->md5keylen = (uint16)(12 + rnd() % 4); + MD5_Salt(sd->md5keylen, sd->md5key); + + login_send_coding_key(fd, sd); +} + +void login_char_server_connection_status(int fd, struct login_session_data* sd, uint8 status) +{ + WFIFOHEAD(fd,3); + WFIFOW(fd,0) = 0x2711; + WFIFOB(fd,2) = status; + WFIFOSET(fd,3); +} + +void login_parse_request_connection(int fd, struct login_session_data* sd, const char *const ip) +{ + char server_name[20]; + char message[256]; + uint32 server_ip; + uint16 server_port; + uint16 type; + uint16 new_; + + safestrncpy(sd->userid, (char*)RFIFOP(fd,2), NAME_LENGTH); + safestrncpy(sd->passwd, (char*)RFIFOP(fd,26), NAME_LENGTH); + if( login_config.use_md5_passwds ) + MD5_String(sd->passwd, sd->passwd); + sd->passwdenc = 0; + sd->version = login_config.client_version_to_connect; // hack to skip version check + server_ip = ntohl(RFIFOL(fd,54)); + server_port = ntohs(RFIFOW(fd,58)); + safestrncpy(server_name, (char*)RFIFOP(fd,60), 20); + type = RFIFOW(fd,82); + new_ = RFIFOW(fd,84); + RFIFOSKIP(fd,86); + + ShowInfo("Connection request of the char-server '%s' @ %u.%u.%u.%u:%u (account: '%s', pass: '%s', ip: '%s')\n", server_name, CONVIP(server_ip), server_port, sd->userid, sd->passwd, ip); + sprintf(message, "charserver - %s@%u.%u.%u.%u:%u", server_name, CONVIP(server_ip), server_port); + login_log(session[fd]->client_addr, sd->userid, 100, message); + + int result = login_mmo_auth(sd, true); + if( runflag == LOGINSERVER_ST_RUNNING && + result == -1 && + sd->sex == 'S' && + sd->account_id >= 0 && sd->account_id < ARRAYLENGTH(server) && + !session_isValid(server[sd->account_id].fd) ) + { + ShowStatus("Connection of the char-server '%s' accepted.\n", server_name); + safestrncpy(server[sd->account_id].name, server_name, sizeof(server[sd->account_id].name)); + server[sd->account_id].fd = fd; + server[sd->account_id].ip = server_ip; + server[sd->account_id].port = server_port; + server[sd->account_id].users = 0; + server[sd->account_id].type = type; + server[sd->account_id].new_ = new_; + + session[fd]->func_parse = login_parse_fromchar; + session[fd]->flag.server = 1; + realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); + + // send connection success + login_char_server_connection_status(fd, sd, 0); + } + else + { + ShowNotice("Connection of the char-server '%s' REFUSED.\n", server_name); + login_char_server_connection_status(fd, sd, 3); + } +} //---------------------------------------------------------------------------------------- // Default packet parsing (normal players or char-server connection requests) @@ -1477,10 +1658,7 @@ int login_parse_login(int fd) { ShowStatus("Connection refused: IP isn't authorized (deny/allow, ip: %s).\n", ip); login_log(ipl, "unknown", -3, "ip banned"); - WFIFOHEAD(fd,23); - WFIFOW(fd,0) = 0x6a; - WFIFOB(fd,2) = 3; // 3 = Rejected from Server - WFIFOSET(fd,23); + login_login_error(fd, 3); // 3 = Rejected from Server set_eof(fd); return 0; } @@ -1506,7 +1684,7 @@ int login_parse_login(int fd) case 0x0200: // New alive packet: structure: 0x200 .24B. used to verify if client is always alive. if (RFIFOREST(fd) < 26) return 0; - RFIFOSKIP(fd,26); + login_parse_ping(fd, sd); break; // client md5 hash (binary) @@ -1514,10 +1692,7 @@ int login_parse_login(int fd) if (RFIFOREST(fd) < 18) return 0; - sd->has_client_hash = 1; - memcpy(sd->client_hash, RFIFOP(fd, 2), 16); - - RFIFOSKIP(fd,18); + login_parse_client_md5(fd, sd); break; // request client login (raw password) @@ -1542,94 +1717,15 @@ int login_parse_login(int fd) return 0; } { - uint32 version; - char username[NAME_LENGTH]; - char password[PASSWD_LEN]; - unsigned char passhash[16]; - uint8 clienttype; - bool israwpass = (command==0x0064 || command==0x0277 || command==0x02b0 || command == 0x0825); - - // Shinryo: For the time being, just use token as password. - if(command == 0x0825) - { - char *accname = (char *)RFIFOP(fd, 9); - char *token = (char *)RFIFOP(fd, 0x5C); - size_t uAccLen = strlen(accname); - size_t uTokenLen = RFIFOREST(fd) - 0x5C; - - version = RFIFOL(fd,4); - - if(uAccLen <= 0 || uTokenLen <= 0) { - login_auth_failed(sd, 3); - return 0; - } - - safestrncpy(username, accname, NAME_LENGTH); - safestrncpy(password, token, min(uTokenLen+1, PASSWD_LEN)); // Variable-length field, don't copy more than necessary - clienttype = RFIFOB(fd, 8); - } - else - { - version = RFIFOL(fd,2); - safestrncpy(username, (const char*)RFIFOP(fd,6), NAME_LENGTH); - if( israwpass ) - { - safestrncpy(password, (const char*)RFIFOP(fd,30), NAME_LENGTH); - clienttype = RFIFOB(fd,54); - } - else - { - memcpy(passhash, RFIFOP(fd,30), 16); - clienttype = RFIFOB(fd,46); - } - } - RFIFOSKIP(fd,RFIFOREST(fd)); // assume no other packet was sent - - sd->clienttype = clienttype; - sd->version = version; - safestrncpy(sd->userid, username, NAME_LENGTH); - if( israwpass ) - { - ShowStatus("Request for connection of %s (ip: %s).\n", sd->userid, ip); - safestrncpy(sd->passwd, password, PASSWD_LEN); - if( login_config.use_md5_passwds ) - MD5_String(sd->passwd, sd->passwd); - sd->passwdenc = 0; - } - else - { - ShowStatus("Request for connection (passwdenc mode) of %s (ip: %s).\n", sd->userid, ip); - bin2hex(sd->passwd, passhash, 16); // raw binary data here! - sd->passwdenc = PASSWORDENC; - } - - if( sd->passwdenc != 0 && login_config.use_md5_passwds ) - { - login_auth_failed(sd, 3); // send "rejected from server" + if (login_parse_client_login(fd, sd, ip)) return 0; - } - - result = login_mmo_auth(sd, false); - - if( result == -1 ) - login_auth_ok(sd); - else - login_auth_failed(sd, result); } break; case 0x01db: // Sending request of the coding key RFIFOSKIP(fd,2); { - memset(sd->md5key, '\0', sizeof(sd->md5key)); - sd->md5keylen = (uint16)(12 + rnd() % 4); - MD5_Salt(sd->md5keylen, sd->md5key); - - WFIFOHEAD(fd,4 + sd->md5keylen); - WFIFOW(fd,0) = 0x01dc; - WFIFOW(fd,2) = 4 + sd->md5keylen; - memcpy(WFIFOP(fd,4), sd->md5key, sd->md5keylen); - WFIFOSET(fd,WFIFOW(fd,2)); + login_parse_request_coding_key(fd, sd); } break; @@ -1637,64 +1733,7 @@ int login_parse_login(int fd) if (RFIFOREST(fd) < 86) return 0; { - char server_name[20]; - char message[256]; - uint32 server_ip; - uint16 server_port; - uint16 type; - uint16 new_; - - safestrncpy(sd->userid, (char*)RFIFOP(fd,2), NAME_LENGTH); - safestrncpy(sd->passwd, (char*)RFIFOP(fd,26), NAME_LENGTH); - if( login_config.use_md5_passwds ) - MD5_String(sd->passwd, sd->passwd); - sd->passwdenc = 0; - sd->version = login_config.client_version_to_connect; // hack to skip version check - server_ip = ntohl(RFIFOL(fd,54)); - server_port = ntohs(RFIFOW(fd,58)); - safestrncpy(server_name, (char*)RFIFOP(fd,60), 20); - type = RFIFOW(fd,82); - new_ = RFIFOW(fd,84); - RFIFOSKIP(fd,86); - - ShowInfo("Connection request of the char-server '%s' @ %u.%u.%u.%u:%u (account: '%s', pass: '%s', ip: '%s')\n", server_name, CONVIP(server_ip), server_port, sd->userid, sd->passwd, ip); - sprintf(message, "charserver - %s@%u.%u.%u.%u:%u", server_name, CONVIP(server_ip), server_port); - login_log(session[fd]->client_addr, sd->userid, 100, message); - - result = login_mmo_auth(sd, true); - if( runflag == LOGINSERVER_ST_RUNNING && - result == -1 && - sd->sex == 'S' && - sd->account_id >= 0 && sd->account_id < ARRAYLENGTH(server) && - !session_isValid(server[sd->account_id].fd) ) - { - ShowStatus("Connection of the char-server '%s' accepted.\n", server_name); - safestrncpy(server[sd->account_id].name, server_name, sizeof(server[sd->account_id].name)); - server[sd->account_id].fd = fd; - server[sd->account_id].ip = server_ip; - server[sd->account_id].port = server_port; - server[sd->account_id].users = 0; - server[sd->account_id].type = type; - server[sd->account_id].new_ = new_; - - session[fd]->func_parse = login_parse_fromchar; - session[fd]->flag.server = 1; - realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); - - // send connection success - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x2711; - WFIFOB(fd,2) = 0; - WFIFOSET(fd,3); - } - else - { - ShowNotice("Connection of the char-server '%s' REFUSED.\n", server_name); - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x2711; - WFIFOB(fd,2) = 3; - WFIFOSET(fd,3); - } + login_parse_request_connection(fd, sd, ip); } return 0; // processing will continue elsewhere -- cgit v1.2.3-70-g09d2 From 653274de31a643d9aa910cc598b3671dfe85bbf4 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 26 Oct 2014 14:43:13 +0300 Subject: Add most function to login interface in login.c --- src/login/login.c | 257 +++++++++++++++++++++++++++++++----------------------- src/login/login.h | 84 ++++++++++++++++++ 2 files changed, 230 insertions(+), 111 deletions(-) diff --git a/src/login/login.c b/src/login/login.c index 929cce438..8f3a25301 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -26,6 +26,7 @@ #include "../common/timer.h" #include "../common/utils.h" +struct login_interface login_s; struct Login_Config login_config; int login_fd; // login server socket @@ -54,41 +55,13 @@ struct s_subnet { int subnet_count = 0; -int login_mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip); - //----------------------------------------------------- // Auth database //----------------------------------------------------- #define AUTH_TIMEOUT 30000 -struct auth_node { - - int account_id; - uint32 login_id1; - uint32 login_id2; - uint32 ip; - char sex; - uint32 version; - uint8 clienttype; - int group_id; - time_t expiration_time; -}; - static DBMap* auth_db; // int account_id -> struct auth_node* - - -//----------------------------------------------------- -// Online User Database [Wizputer] -//----------------------------------------------------- -struct online_login_data { - - int account_id; - int waiting_disconnect; - int char_server; -}; - static DBMap* online_db; // int account_id -> struct online_login_data* -static int login_waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data); /** * @see DBCreateData @@ -106,11 +79,11 @@ static DBData login_create_online_user(DBKey key, va_list args) struct online_login_data* login_add_online_user(int char_server, int account_id) { struct online_login_data* p; - p = idb_ensure(online_db, account_id, login_create_online_user); + p = idb_ensure(online_db, account_id, login->create_online_user); p->char_server = char_server; if( p->waiting_disconnect != INVALID_TIMER ) { - timer->delete(p->waiting_disconnect, login_waiting_disconnect_timer); + timer->delete(p->waiting_disconnect, login->waiting_disconnect_timer); p->waiting_disconnect = INVALID_TIMER; } return p; @@ -123,7 +96,7 @@ void login_remove_online_user(int account_id) if( p == NULL ) return; if( p->waiting_disconnect != INVALID_TIMER ) - timer->delete(p->waiting_disconnect, login_waiting_disconnect_timer); + timer->delete(p->waiting_disconnect, login->waiting_disconnect_timer); idb_remove(online_db, account_id); } @@ -133,7 +106,7 @@ static int login_waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t if( p != NULL && p->waiting_disconnect == tid && p->account_id == id ) { p->waiting_disconnect = INVALID_TIMER; - login_remove_online_user(id); + login->remove_online_user(id); idb_remove(auth_db, id); } return 0; @@ -151,7 +124,7 @@ static int login_online_db_setoffline(DBKey key, DBData *data, va_list ap) p->char_server = -1; if( p->waiting_disconnect != INVALID_TIMER ) { - timer->delete(p->waiting_disconnect, login_waiting_disconnect_timer); + timer->delete(p->waiting_disconnect, login->waiting_disconnect_timer); p->waiting_disconnect = INVALID_TIMER; } } @@ -167,12 +140,12 @@ static int login_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap) { struct online_login_data *character= DB->data2ptr(data); if (character->char_server == -2) //Unknown server.. set them offline - login_remove_online_user(character->account_id); + login->remove_online_user(character->account_id); return 0; } static int login_online_data_cleanup(int tid, int64 tick, int id, intptr_t data) { - online_db->foreach(online_db, login_online_data_cleanup_sub); + online_db->foreach(online_db, login->online_data_cleanup_sub); return 0; } @@ -222,7 +195,7 @@ void chrif_server_destroy(int id) /// Resets all the data related to a server. void chrif_server_reset(int id) { - online_db->foreach(online_db, login_online_db_setoffline, id); //Set all chars from this char server to offline. + online_db->foreach(online_db, login->online_db_setoffline, id); //Set all chars from this char server to offline. chrif_server_destroy(id); chrif_server_init(id); } @@ -272,8 +245,8 @@ bool login_check_password(const char* md5key, int passwdenc, const char* passwd, // password mode set to 1 -> md5(md5key, refpass) enable with // password mode set to 2 -> md5(refpass, md5key) enable with - return ((passwdenc&0x01) && login_check_encrypted(md5key, refpass, passwd)) || - ((passwdenc&0x02) && login_check_encrypted(refpass, md5key, passwd)); + return ((passwdenc&0x01) && login->check_encrypted(md5key, refpass, passwd)) || + ((passwdenc&0x02) && login->check_encrypted(refpass, md5key, passwd)); } } @@ -388,14 +361,14 @@ void login_fromchar_parse_auth(int fd, int id, const char *const ip) //ShowStatus("Char-server '%s': authentication of the account %d accepted (ip: %s).\n", server[id].name, account_id, ip); // send ack - login_fromchar_auth_ack(fd, account_id, login_id1, login_id2, sex, request_id, node); + login->fromchar_auth_ack(fd, account_id, login_id1, login_id2, sex, request_id, node); // each auth entry can only be used once idb_remove(auth_db, account_id); } else {// authentication not found ShowStatus("Char-server '%s': authentication of the account %d REFUSED (ip: %s).\n", server[id].name, account_id, ip); - login_fromchar_auth_ack(fd, account_id, login_id1, login_id2, sex, request_id, NULL); + login->fromchar_auth_ack(fd, account_id, login_id1, login_id2, sex, request_id, NULL); } } @@ -489,10 +462,10 @@ void login_fromchar_parse_account_data(int fd, int id, const char *const ip) if( !accounts->load_num(accounts, &acc, account_id) ) { ShowNotice("Char-server '%s': account %d NOT found (ip: %s).\n", server[id].name, account_id, ip); - login_fromchar_account(fd, account_id, NULL); + login->fromchar_account(fd, account_id, NULL); } else { - login_fromchar_account(fd, account_id, &acc); + login->fromchar_account(fd, account_id, &acc); } } @@ -506,7 +479,7 @@ void login_fromchar_pong(int fd) void login_fromchar_parse_ping(int fd) { RFIFOSKIP(fd,2); - login_fromchar_pong(fd); + login->fromchar_pong(fd); } void login_fromchar_parse_change_email(int fd, int id, const char *const ip) @@ -574,7 +547,7 @@ void login_fromchar_parse_account_update(int fd, int id, const char *const ip) // notify other servers if (state != 0) { - login_fromchar_account_update_other(account_id, state); + login->fromchar_account_update_other(account_id, state); } } } @@ -634,7 +607,7 @@ void login_fromchar_parse_ban(int fd, int id, const char *const ip) // Save accounts->save(accounts, &acc); - login_fromchar_ban(account_id, timestamp); + login->fromchar_ban(account_id, timestamp); } } } @@ -671,7 +644,7 @@ void login_fromchar_parse_change_sex(int fd, int id, const char *const ip) accounts->save(accounts, &acc); // announce to other servers - login_fromchar_change_sex_other(account_id, sex); + login->fromchar_change_sex_other(account_id, sex); } } @@ -711,13 +684,13 @@ void login_fromchar_parse_unban(int fd, int id, const char *const ip) void login_fromchar_parse_account_online(int fd, int id) { - login_add_online_user(id, RFIFOL(fd,2)); + login->add_online_user(id, RFIFOL(fd,2)); RFIFOSKIP(fd,6); } void login_fromchar_parse_account_offline(int fd) { - login_remove_online_user(RFIFOL(fd,2)); + login->remove_online_user(RFIFOL(fd,2)); RFIFOSKIP(fd,6); } @@ -726,15 +699,15 @@ void login_fromchar_parse_online_accounts(int fd, int id) struct online_login_data *p; int aid; uint32 i, users; - online_db->foreach(online_db, login_online_db_setoffline, id); //Set all chars from this char-server offline first + online_db->foreach(online_db, login->online_db_setoffline, id); //Set all chars from this char-server offline first users = RFIFOW(fd,4); for (i = 0; i < users; i++) { aid = RFIFOL(fd,6+i*4); - p = idb_ensure(online_db, aid, login_create_online_user); + p = idb_ensure(online_db, aid, login->create_online_user); p->char_server = id; if (p->waiting_disconnect != INVALID_TIMER) { - timer->delete(p->waiting_disconnect, login_waiting_disconnect_timer); + timer->delete(p->waiting_disconnect, login->waiting_disconnect_timer); p->waiting_disconnect = INVALID_TIMER; } } @@ -759,7 +732,7 @@ void login_fromchar_parse_update_wan_ip(int fd, int id) void login_fromchar_parse_all_offline(int fd, int id) { ShowInfo("Setting accounts from char-server %d offline.\n", id); - online_db->foreach(online_db, login_online_db_setoffline, id); + online_db->foreach(online_db, login->online_db_setoffline, id); RFIFOSKIP(fd,2); } @@ -791,7 +764,7 @@ bool login_fromchar_parse_wrong_pincode(int fd) login_log( host2ip(acc.last_ip), acc.userid, 100, "PIN Code check failed" ); } - login_remove_online_user(acc.account_id); + login->remove_online_user(acc.account_id); RFIFOSKIP(fd,6); return false; } @@ -841,9 +814,9 @@ void login_fromchar_parse_accinfo(int fd) struct mmo_account acc; int account_id = RFIFOL(fd, 2), u_fd = RFIFOL(fd, 6), u_aid = RFIFOL(fd, 10), u_group = RFIFOL(fd, 14), map_fd = RFIFOL(fd, 18); if (accounts->load_num(accounts, &acc, account_id)) { - login_fromchar_accinfo(fd, account_id, u_fd, u_aid, u_group, map_fd, &acc); + login->fromchar_accinfo(fd, account_id, u_fd, u_aid, u_group, map_fd, &acc); } else { - login_fromchar_accinfo(fd, account_id, u_fd, u_aid, u_group, map_fd, NULL); + login->fromchar_accinfo(fd, account_id, u_fd, u_aid, u_group, map_fd, NULL); } RFIFOSKIP(fd,22); } @@ -893,7 +866,7 @@ int login_parse_fromchar(int fd) if( RFIFOREST(fd) < 23 ) return 0; { - login_fromchar_parse_auth(fd, id, ip); + login->fromchar_parse_auth(fd, id, ip); } break; @@ -901,7 +874,7 @@ int login_parse_fromchar(int fd) if( RFIFOREST(fd) < 6 ) return 0; { - login_fromchar_parse_update_users(fd, id); + login->fromchar_parse_update_users(fd, id); } break; @@ -909,7 +882,7 @@ int login_parse_fromchar(int fd) if (RFIFOREST(fd) < 46) return 0; { - login_fromchar_parse_request_change_email(fd, id, ip); + login->fromchar_parse_request_change_email(fd, id, ip); } break; @@ -917,12 +890,12 @@ int login_parse_fromchar(int fd) if( RFIFOREST(fd) < 6 ) return 0; { - login_fromchar_parse_account_data(fd, id, ip); + login->fromchar_parse_account_data(fd, id, ip); } break; case 0x2719: // ping request from charserver - login_fromchar_parse_ping(fd); + login->fromchar_parse_ping(fd); break; // Map server send information to change an email of an account via char-server @@ -930,7 +903,7 @@ int login_parse_fromchar(int fd) if (RFIFOREST(fd) < 86) return 0; { - login_fromchar_parse_change_email(fd, id, ip); + login->fromchar_parse_change_email(fd, id, ip); } break; @@ -938,7 +911,7 @@ int login_parse_fromchar(int fd) if (RFIFOREST(fd) < 10) return 0; { - login_fromchar_parse_account_update(fd, id, ip); + login->fromchar_parse_account_update(fd, id, ip); } break; @@ -946,7 +919,7 @@ int login_parse_fromchar(int fd) if (RFIFOREST(fd) < 18) return 0; { - login_fromchar_parse_ban(fd, id, ip); + login->fromchar_parse_ban(fd, id, ip); } break; @@ -954,7 +927,7 @@ int login_parse_fromchar(int fd) if( RFIFOREST(fd) < 6 ) return 0; { - login_fromchar_parse_change_sex(fd, id, ip); + login->fromchar_parse_change_sex(fd, id, ip); } break; @@ -962,7 +935,7 @@ int login_parse_fromchar(int fd) if( RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2) ) return 0; { - login_fromchar_parse_account_reg2(fd, id, ip); + login->fromchar_parse_account_reg2(fd, id, ip); } break; @@ -970,27 +943,27 @@ int login_parse_fromchar(int fd) if( RFIFOREST(fd) < 6 ) return 0; { - login_fromchar_parse_unban(fd, id, ip); + login->fromchar_parse_unban(fd, id, ip); } break; case 0x272b: // Set account_id to online [Wizputer] if( RFIFOREST(fd) < 6 ) return 0; - login_fromchar_parse_account_online(fd, id); + login->fromchar_parse_account_online(fd, id); break; case 0x272c: // Set account_id to offline [Wizputer] if( RFIFOREST(fd) < 6 ) return 0; - login_fromchar_parse_account_offline(fd); + login->fromchar_parse_account_offline(fd); break; case 0x272d: // Receive list of all online accounts. [Skotlex] if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) return 0; { - login_fromchar_parse_online_accounts(fd, id); + login->fromchar_parse_online_accounts(fd, id); } RFIFOSKIP(fd,RFIFOW(fd,2)); break; @@ -999,25 +972,25 @@ int login_parse_fromchar(int fd) if (RFIFOREST(fd) < 10) return 0; { - login_fromchar_parse_request_account_reg2(fd); + login->fromchar_parse_request_account_reg2(fd); } break; case 0x2736: // WAN IP update from char-server if( RFIFOREST(fd) < 6 ) return 0; - login_fromchar_parse_update_wan_ip(fd, id); + login->fromchar_parse_update_wan_ip(fd, id); break; case 0x2737: //Request to set all offline. - login_fromchar_parse_all_offline(fd, id); + login->fromchar_parse_all_offline(fd, id); break; case 0x2738: //Change PIN Code for a account if( RFIFOREST(fd) < 11 ) return 0; else { - login_fromchar_parse_change_pincode(fd); + login->fromchar_parse_change_pincode(fd); } break; @@ -1025,7 +998,7 @@ int login_parse_fromchar(int fd) if( RFIFOREST(fd) < 6 ) return 0; else { - if (login_fromchar_parse_wrong_pincode(fd)) + if (login->fromchar_parse_wrong_pincode(fd)) return 0; } break; @@ -1034,7 +1007,7 @@ int login_parse_fromchar(int fd) if( RFIFOREST(fd) < 22 ) return 0; else { - login_fromchar_parse_accinfo(fd); + login->fromchar_parse_accinfo(fd); } break; default: @@ -1153,7 +1126,7 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) { len -= 2; sd->userid[len] = '\0'; - result = login_mmo_auth_new(sd->userid, sd->passwd, TOUPPER(sd->userid[len+1]), ip); + result = login->mmo_auth_new(sd->userid, sd->passwd, TOUPPER(sd->userid[len+1]), ip); if( result != -1 ) return result;// Failed to make account. [Skotlex]. } @@ -1169,7 +1142,7 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) { return 0; // 0 = Unregistered ID } - if( !login_check_password(sd->md5key, sd->passwdenc, sd->passwd, acc.pass) ) { + if( !login->check_password(sd->md5key, sd->passwdenc, sd->passwd, acc.pass) ) { ShowNotice("Invalid password (account: '%s', pass: '%s', received pass: '%s', ip: %s)\n", sd->userid, acc.pass, sd->passwd, ip); return 1; // 1 = Incorrect Password } @@ -1273,17 +1246,17 @@ void login_auth_ok(struct login_session_data* sd) if( runflag != LOGINSERVER_ST_RUNNING ) { // players can only login while running - login_connection_problem(fd, 1); // 01 = server closed + login->connection_problem(fd, 1); // 01 = server closed return; } if( login_config.group_id_to_connect >= 0 && sd->group_id != login_config.group_id_to_connect ) { ShowStatus("Connection refused: the required group id for connection is %d (account: %s, group: %d).\n", login_config.group_id_to_connect, sd->userid, sd->group_id); - login_connection_problem(fd, 1); // 01 = server closed + login->connection_problem(fd, 1); // 01 = server closed return; } else if( login_config.min_group_id_to_connect >= 0 && login_config.group_id_to_connect == -1 && sd->group_id < login_config.min_group_id_to_connect ) { ShowStatus("Connection refused: the minimum group id required for connection is %d (account: %s, group: %d).\n", login_config.min_group_id_to_connect, sd->userid, sd->group_id); - login_connection_problem(fd, 1); // 01 = server closed + login->connection_problem(fd, 1); // 01 = server closed return; } @@ -1295,7 +1268,7 @@ void login_auth_ok(struct login_session_data* sd) if( server_num == 0 ) {// if no char-server, don't send void list of servers, just disconnect the player with proper message ShowStatus("Connection refused: there is no char-server online (account: %s).\n", sd->userid); - login_connection_problem(fd, 1); // 01 = server closed + login->connection_problem(fd, 1); // 01 = server closed return; } @@ -1306,11 +1279,11 @@ void login_auth_ok(struct login_session_data* sd) if( data->char_server > -1 ) {// Request char servers to kick this account out. [Skotlex] ShowNotice("User '%s' is already online - Rejected.\n", sd->userid); - login_kick(sd); + login->kick(sd); if( data->waiting_disconnect == INVALID_TIMER ) - data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, login_waiting_disconnect_timer, sd->account_id, 0); + data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, login->waiting_disconnect_timer, sd->account_id, 0); - login_connection_problem(fd, 8); // 08 = Server still recognizes your last login + login->connection_problem(fd, 8); // 08 = Server still recognizes your last login return; } else @@ -1318,7 +1291,7 @@ void login_auth_ok(struct login_session_data* sd) {// client has authed but did not access char-server yet // wipe previous session idb_remove(auth_db, sd->account_id); - login_remove_online_user(sd->account_id); + login->remove_online_user(sd->account_id); data = NULL; } } @@ -1343,7 +1316,7 @@ void login_auth_ok(struct login_session_data* sd) if( !session_isValid(server[i].fd) ) continue; - subnet_char_ip = login_lan_subnetcheck(ip); // Advanced subnet check [LuzZza] + subnet_char_ip = login->lan_subnetcheck(ip); // Advanced subnet check [LuzZza] WFIFOL(fd,47+n*32) = htonl((subnet_char_ip) ? subnet_char_ip : server[i].ip); WFIFOW(fd,47+n*32+4) = ntows(htons(server[i].port)); // [!] LE byte order here [!] memcpy(WFIFOP(fd,47+n*32+6), server[i].name, 20); @@ -1376,10 +1349,10 @@ void login_auth_ok(struct login_session_data* sd) struct online_login_data* data; // mark client as 'online' - data = login_add_online_user(-1, sd->account_id); + data = login->add_online_user(-1, sd->account_id); // schedule deletion of this node - data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, login_waiting_disconnect_timer, sd->account_id, 0); + data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, login->waiting_disconnect_timer, sd->account_id, 0); } } @@ -1492,7 +1465,7 @@ bool login_parse_client_login(int fd, struct login_session_data* sd, const char version = RFIFOL(fd,4); if(uAccLen <= 0 || uTokenLen <= 0) { - login_auth_failed(sd, 3); + login->auth_failed(sd, 3); return true; } @@ -1537,16 +1510,16 @@ bool login_parse_client_login(int fd, struct login_session_data* sd, const char if( sd->passwdenc != 0 && login_config.use_md5_passwds ) { - login_auth_failed(sd, 3); // send "rejected from server" + login->auth_failed(sd, 3); // send "rejected from server" return true; } - int result = login_mmo_auth(sd, false); + int result = login->mmo_auth(sd, false); if( result == -1 ) - login_auth_ok(sd); + login->auth_ok(sd); else - login_auth_failed(sd, result); + login->auth_failed(sd, result); return false; } @@ -1565,7 +1538,7 @@ void login_parse_request_coding_key(int fd, struct login_session_data* sd) sd->md5keylen = (uint16)(12 + rnd() % 4); MD5_Salt(sd->md5keylen, sd->md5key); - login_send_coding_key(fd, sd); + login->send_coding_key(fd, sd); } void login_char_server_connection_status(int fd, struct login_session_data* sd, uint8 status) @@ -1602,7 +1575,7 @@ void login_parse_request_connection(int fd, struct login_session_data* sd, const sprintf(message, "charserver - %s@%u.%u.%u.%u:%u", server_name, CONVIP(server_ip), server_port); login_log(session[fd]->client_addr, sd->userid, 100, message); - int result = login_mmo_auth(sd, true); + int result = login->mmo_auth(sd, true); if( runflag == LOGINSERVER_ST_RUNNING && result == -1 && sd->sex == 'S' && @@ -1618,17 +1591,17 @@ void login_parse_request_connection(int fd, struct login_session_data* sd, const server[sd->account_id].type = type; server[sd->account_id].new_ = new_; - session[fd]->func_parse = login_parse_fromchar; + session[fd]->func_parse = login->parse_fromchar; session[fd]->flag.server = 1; realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); // send connection success - login_char_server_connection_status(fd, sd, 0); + login->char_server_connection_status(fd, sd, 0); } else { ShowNotice("Connection of the char-server '%s' REFUSED.\n", server_name); - login_char_server_connection_status(fd, sd, 3); + login->char_server_connection_status(fd, sd, 3); } } @@ -1658,7 +1631,7 @@ int login_parse_login(int fd) { ShowStatus("Connection refused: IP isn't authorized (deny/allow, ip: %s).\n", ip); login_log(ipl, "unknown", -3, "ip banned"); - login_login_error(fd, 3); // 3 = Rejected from Server + login->login_error(fd, 3); // 3 = Rejected from Server set_eof(fd); return 0; } @@ -1684,7 +1657,7 @@ int login_parse_login(int fd) case 0x0200: // New alive packet: structure: 0x200 .24B. used to verify if client is always alive. if (RFIFOREST(fd) < 26) return 0; - login_parse_ping(fd, sd); + login->parse_ping(fd, sd); break; // client md5 hash (binary) @@ -1692,7 +1665,7 @@ int login_parse_login(int fd) if (RFIFOREST(fd) < 18) return 0; - login_parse_client_md5(fd, sd); + login->parse_client_md5(fd, sd); break; // request client login (raw password) @@ -1717,7 +1690,7 @@ int login_parse_login(int fd) return 0; } { - if (login_parse_client_login(fd, sd, ip)) + if (login->parse_client_login(fd, sd, ip)) return 0; } break; @@ -1725,7 +1698,7 @@ int login_parse_login(int fd) case 0x01db: // Sending request of the coding key RFIFOSKIP(fd,2); { - login_parse_request_coding_key(fd, sd); + login->parse_request_coding_key(fd, sd); } break; @@ -1733,7 +1706,7 @@ int login_parse_login(int fd) if (RFIFOREST(fd) < 86) return 0; { - login_parse_request_connection(fd, sd, ip); + login->parse_request_connection(fd, sd, ip); } return 0; // processing will continue elsewhere @@ -1985,6 +1958,8 @@ int do_init(int argc, char** argv) { int i; + login_defaults(); + // initialize engine (to accept config settings) account_engine[0].db = account_engine[0].constructor(); accounts = account_engine[0].db; @@ -2020,7 +1995,7 @@ int do_init(int argc, char** argv) HPM->event(HPET_PRE_INIT); login_config_read((argc > 1) ? argv[1] : LOGIN_CONF_NAME); - login_lan_config_read((argc > 2) ? argv[2] : LAN_CONF_NAME); + login->lan_config_read((argc > 2) ? argv[2] : LAN_CONF_NAME); for( i = 0; i < ARRAYLENGTH(server); ++i ) chrif_server_init(i); @@ -2034,22 +2009,22 @@ int do_init(int argc, char** argv) // Online user database init online_db = idb_alloc(DB_OPT_RELEASE_DATA); - timer->add_func_list(login_waiting_disconnect_timer, "login_waiting_disconnect_timer"); + timer->add_func_list(login->waiting_disconnect_timer, "login->waiting_disconnect_timer"); // Interserver auth init auth_db = idb_alloc(DB_OPT_RELEASE_DATA); // set default parser as login_parse_login function - set_defaultparse(login_parse_login); + set_defaultparse(login->parse_login); // every 10 minutes cleanup online account db. - timer->add_func_list(login_online_data_cleanup, "login_online_data_cleanup"); - timer->add_interval(timer->gettick() + 600*1000, login_online_data_cleanup, 0, 0, 600*1000); + timer->add_func_list(login->online_data_cleanup, "login->online_data_cleanup"); + timer->add_interval(timer->gettick() + 600*1000, login->online_data_cleanup, 0, 0, 600*1000); // add timer to detect ip address change and perform update if (login_config.ip_sync_interval) { - timer->add_func_list(login_sync_ip_addresses, "login_sync_ip_addresses"); - timer->add_interval(timer->gettick() + login_config.ip_sync_interval, login_sync_ip_addresses, 0, 0, login_config.ip_sync_interval); + timer->add_func_list(login->sync_ip_addresses, "login->sync_ip_addresses"); + timer->add_interval(timer->gettick() + login_config.ip_sync_interval, login->sync_ip_addresses, 0, 0, login_config.ip_sync_interval); } // Account database init @@ -2078,3 +2053,63 @@ int do_init(int argc, char** argv) return 0; } + +void login_defaults(void) { + login = &login_s; + login->mmo_auth = login_mmo_auth; + login->mmo_auth_new = login_mmo_auth_new; + login->waiting_disconnect_timer = login_waiting_disconnect_timer; + login->create_online_user = login_create_online_user; + login->add_online_user = login_add_online_user; + login->remove_online_user = login_remove_online_user; + login->online_db_setoffline = login_online_db_setoffline; + login->online_data_cleanup_sub = login_online_data_cleanup_sub; + login->online_data_cleanup = login_online_data_cleanup; + login->sync_ip_addresses = login_sync_ip_addresses; + login->check_encrypted = login_check_encrypted; + login->check_password = login_check_password; + login->lan_subnetcheck = login_lan_subnetcheck; + login->lan_config_read = login_lan_config_read; + + login->fromchar_auth_ack = login_fromchar_auth_ack; + login->fromchar_accinfo = login_fromchar_accinfo; + login->fromchar_account = login_fromchar_account; + login->fromchar_account_update_other = login_fromchar_account_update_other; + login->fromchar_ban = login_fromchar_ban; + login->fromchar_change_sex_other = login_fromchar_change_sex_other; + login->fromchar_pong = login_fromchar_pong; + login->fromchar_parse_auth = login_fromchar_parse_auth; + login->fromchar_parse_update_users = login_fromchar_parse_update_users; + login->fromchar_parse_request_change_email = login_fromchar_parse_request_change_email; + login->fromchar_parse_account_data = login_fromchar_parse_account_data; + login->fromchar_parse_ping = login_fromchar_parse_ping; + login->fromchar_parse_change_email = login_fromchar_parse_change_email; + login->fromchar_parse_account_update = login_fromchar_parse_account_update; + login->fromchar_parse_ban = login_fromchar_parse_ban; + login->fromchar_parse_change_sex = login_fromchar_parse_change_sex; + login->fromchar_parse_account_reg2 = login_fromchar_parse_account_reg2; + login->fromchar_parse_unban = login_fromchar_parse_unban; + login->fromchar_parse_account_online = login_fromchar_parse_account_online; + login->fromchar_parse_account_offline = login_fromchar_parse_account_offline; + login->fromchar_parse_online_accounts = login_fromchar_parse_online_accounts; + login->fromchar_parse_request_account_reg2 = login_fromchar_parse_request_account_reg2; + login->fromchar_parse_update_wan_ip = login_fromchar_parse_update_wan_ip; + login->fromchar_parse_all_offline = login_fromchar_parse_all_offline; + login->fromchar_parse_change_pincode = login_fromchar_parse_change_pincode; + login->fromchar_parse_wrong_pincode = login_fromchar_parse_wrong_pincode; + login->fromchar_parse_accinfo = login_fromchar_parse_accinfo; + + login->parse_fromchar = login_parse_fromchar; + login->parse_login = login_parse_login; + login->parse_ping = login_parse_ping; + login->parse_client_md5 = login_parse_client_md5; + login->parse_client_login = login_parse_client_login; + login->parse_request_coding_key = login_parse_request_coding_key; + login->parse_request_connection = login_parse_request_connection; + login->auth_ok = login_auth_ok; + login->char_server_connection_status = login_char_server_connection_status; + login->connection_problem = login_connection_problem; + login->kick = login_kick; + login->login_error = login_login_error; + login->send_coding_key = login_send_coding_key; +} diff --git a/src/login/login.h b/src/login/login.h index 9b9d1e82c..3d347857e 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -8,6 +8,8 @@ #include "../common/core.h" // CORE_ST_LAST #include "../common/mmo.h" // NAME_LENGTH,SEX_* +struct mmo_account; + enum E_LOGINSERVER_ST { LOGINSERVER_ST_RUNNING = CORE_ST_LAST, @@ -92,6 +94,27 @@ struct Login_Config { struct client_hash_node *client_hash_nodes; // linked list containg md5 hash for each gm group }; +struct auth_node { + int account_id; + uint32 login_id1; + uint32 login_id2; + uint32 ip; + char sex; + uint32 version; + uint8 clienttype; + int group_id; + time_t expiration_time; +}; + +//----------------------------------------------------- +// Online User Database [Wizputer] +//----------------------------------------------------- +struct online_login_data { + int account_id; + int waiting_disconnect; + int char_server; +}; + #define sex_num2str(num) ( ((num) == SEX_FEMALE) ? 'F' : ((num) == SEX_MALE) ? 'M' : 'S' ) #define sex_str2num(str) ( ((str) == 'F') ? SEX_FEMALE : ((str) == 'M') ? SEX_MALE : SEX_SERVER ) @@ -99,5 +122,66 @@ struct Login_Config { extern struct mmo_char_server server[MAX_SERVERS]; extern struct Login_Config login_config; +struct login_interface { + int (*mmo_auth) (struct login_session_data* sd, bool isServer); + int (*mmo_auth_new) (const char* userid, const char* pass, const char sex, const char* last_ip); + int (*waiting_disconnect_timer) (int tid, int64 tick, int id, intptr_t data); + DBData (*create_online_user) (DBKey key, va_list args); + struct online_login_data* (*add_online_user) (int char_server, int account_id); + void (*remove_online_user) (int account_id); + int (*online_db_setoffline) (DBKey key, DBData *data, va_list ap); + int (*online_data_cleanup_sub) (DBKey key, DBData *data, va_list ap); + int (*online_data_cleanup) (int tid, int64 tick, int id, intptr_t data); + int (*sync_ip_addresses) (int tid, int64 tick, int id, intptr_t data); + bool (*check_encrypted) (const char* str1, const char* str2, const char* passwd); + bool (*check_password) (const char* md5key, int passwdenc, const char* passwd, const char* refpass); + int (*lan_subnetcheck) (uint32 ip); + int (*lan_config_read) (const char *lancfgName); + void (*fromchar_accinfo) (int fd, int account_id, int u_fd, int u_aid, int u_group, int map_fd, struct mmo_account *acc); + void (*fromchar_account) (int fd, int account_id, struct mmo_account *acc); + void (*fromchar_account_update_other) (int account_id, unsigned int state); + void (*fromchar_auth_ack) (int fd, int account_id, uint32 login_id1, uint32 login_id2, uint8 sex, int request_id, struct auth_node* node); + void (*fromchar_ban) (int account_id, time_t timestamp); + void (*fromchar_change_sex_other) (int account_id, char sex); + void (*fromchar_pong) (int fd); + void (*fromchar_parse_auth) (int fd, int id, const char *const ip); + void (*fromchar_parse_update_users) (int fd, int id); + void (*fromchar_parse_request_change_email) (int fd, int id, const char *const ip); + void (*fromchar_parse_account_data) (int fd, int id, const char *const ip); + void (*fromchar_parse_ping) (int fd); + void (*fromchar_parse_change_email) (int fd, int id, const char *const ip); + void (*fromchar_parse_account_update) (int fd, int id, const char *const ip); + void (*fromchar_parse_ban) (int fd, int id, const char *const ip); + void (*fromchar_parse_change_sex) (int fd, int id, const char *const ip); + void (*fromchar_parse_account_reg2) (int fd, int id, const char *const ip); + void (*fromchar_parse_unban) (int fd, int id, const char *const ip); + void (*fromchar_parse_account_online) (int fd, int id); + void (*fromchar_parse_account_offline) (int fd); + void (*fromchar_parse_online_accounts) (int fd, int id); + void (*fromchar_parse_request_account_reg2) (int fd); + void (*fromchar_parse_update_wan_ip) (int fd, int id); + void (*fromchar_parse_all_offline) (int fd, int id); + void (*fromchar_parse_change_pincode) (int fd); + bool (*fromchar_parse_wrong_pincode) (int fd); + void (*fromchar_parse_accinfo) (int fd); + int (*parse_fromchar) (int fd); + void (*connection_problem) (int fd, uint8 status); + void (*kick) (struct login_session_data* sd); + void (*auth_ok) (struct login_session_data* sd); + void (*auth_failed) (struct login_session_data* sd, int result); + void (*login_error) (int fd, uint8 status); + void (*parse_ping) (int fd, struct login_session_data* sd); + void (*parse_client_md5) (int fd, struct login_session_data* sd); + bool (*parse_client_login) (int fd, struct login_session_data* sd, const char *const ip); + void (*send_coding_key) (int fd, struct login_session_data* sd); + void (*parse_request_coding_key) (int fd, struct login_session_data* sd); + void (*char_server_connection_status) (int fd, struct login_session_data* sd, uint8 status); + void (*parse_request_connection) (int fd, struct login_session_data* sd, const char *const ip); + int (*parse_login) (int fd); +}; + +struct login_interface *login; + +void login_defaults(void); #endif /* LOGIN_LOGIN_H */ -- cgit v1.2.3-70-g09d2 From b623af001d219e1a8c7bde80982007c9a2e93808 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 26 Oct 2014 15:59:17 +0300 Subject: Move global variables to interfaces in login.c --- src/login/account.h | 4 ++ src/login/login.c | 103 ++++++++++++++++++++++------------------------------ src/login/login.h | 14 +++++++ 3 files changed, 62 insertions(+), 59 deletions(-) diff --git a/src/login/account.h b/src/login/account.h index e15143ce9..fb7368d69 100644 --- a/src/login/account.h +++ b/src/login/account.h @@ -52,6 +52,10 @@ struct AccountDBIterator bool (*next)(AccountDBIterator* self, struct mmo_account* acc); }; +struct Account_engine { + AccountDB* (*constructor)(void); + AccountDB* db; +}; struct AccountDB { diff --git a/src/login/login.c b/src/login/login.c index 8f3a25301..7fd941192 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -28,41 +28,20 @@ struct login_interface login_s; struct Login_Config login_config; - -int login_fd; // login server socket struct mmo_char_server server[MAX_SERVERS]; // char server data -static struct account_engine { - AccountDB* (*constructor)(void); - AccountDB* db; -} account_engine[] = { +struct Account_engine account_engine[] = { {account_db_sql, NULL} }; // account database AccountDB* accounts = NULL; -//Account registration flood protection [Kevin] -int allowed_regs = 1; -int time_allowed = 10; //in seconds - -// Advanced subnet check [LuzZza] -struct s_subnet { - uint32 mask; - uint32 char_ip; - uint32 map_ip; -} subnet[16]; - -int subnet_count = 0; - //----------------------------------------------------- // Auth database //----------------------------------------------------- #define AUTH_TIMEOUT 30000 -static DBMap* auth_db; // int account_id -> struct auth_node* -static DBMap* online_db; // int account_id -> struct online_login_data* - /** * @see DBCreateData */ @@ -79,7 +58,7 @@ static DBData login_create_online_user(DBKey key, va_list args) struct online_login_data* login_add_online_user(int char_server, int account_id) { struct online_login_data* p; - p = idb_ensure(online_db, account_id, login->create_online_user); + p = idb_ensure(login->online_db, account_id, login->create_online_user); p->char_server = char_server; if( p->waiting_disconnect != INVALID_TIMER ) { @@ -92,22 +71,22 @@ struct online_login_data* login_add_online_user(int char_server, int account_id) void login_remove_online_user(int account_id) { struct online_login_data* p; - p = (struct online_login_data*)idb_get(online_db, account_id); + p = (struct online_login_data*)idb_get(login->online_db, account_id); if( p == NULL ) return; if( p->waiting_disconnect != INVALID_TIMER ) timer->delete(p->waiting_disconnect, login->waiting_disconnect_timer); - idb_remove(online_db, account_id); + idb_remove(login->online_db, account_id); } static int login_waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data) { - struct online_login_data* p = (struct online_login_data*)idb_get(online_db, id); + struct online_login_data* p = (struct online_login_data*)idb_get(login->online_db, id); if( p != NULL && p->waiting_disconnect == tid && p->account_id == id ) { p->waiting_disconnect = INVALID_TIMER; login->remove_online_user(id); - idb_remove(auth_db, id); + idb_remove(login->auth_db, id); } return 0; } @@ -145,7 +124,7 @@ static int login_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap) } static int login_online_data_cleanup(int tid, int64 tick, int id, intptr_t data) { - online_db->foreach(online_db, login->online_data_cleanup_sub); + login->online_db->foreach(login->online_db, login->online_data_cleanup_sub); return 0; } @@ -195,7 +174,7 @@ void chrif_server_destroy(int id) /// Resets all the data related to a server. void chrif_server_reset(int id) { - online_db->foreach(online_db, login->online_db_setoffline, id); //Set all chars from this char server to offline. + login->online_db->foreach(login->online_db, login->online_db_setoffline, id); //Set all chars from this char server to offline. chrif_server_destroy(id); chrif_server_init(id); } @@ -256,8 +235,8 @@ bool login_check_password(const char* md5key, int passwdenc, const char* passwd, int login_lan_subnetcheck(uint32 ip) { int i; - ARR_FIND( 0, subnet_count, i, (subnet[i].char_ip & subnet[i].mask) == (ip & subnet[i].mask) ); - return ( i < subnet_count ) ? subnet[i].char_ip : 0; + ARR_FIND( 0, login_config.subnet_count, i, (login_config.subnet[i].char_ip & login_config.subnet[i].mask) == (ip & login_config.subnet[i].mask) ); + return ( i < login_config.subnet_count ) ? login_config.subnet[i].char_ip : 0; } //---------------------------------- @@ -287,22 +266,24 @@ int login_lan_config_read(const char *lancfgName) if( strcmpi(w1, "subnet") == 0 ) { - subnet[subnet_count].mask = str2ip(w2); - subnet[subnet_count].char_ip = str2ip(w3); - subnet[subnet_count].map_ip = str2ip(w4); + login_config.subnet[login_config.subnet_count].mask = str2ip(w2); + login_config.subnet[login_config.subnet_count].char_ip = str2ip(w3); + login_config.subnet[login_config.subnet_count].map_ip = str2ip(w4); - if( (subnet[subnet_count].char_ip & subnet[subnet_count].mask) != (subnet[subnet_count].map_ip & subnet[subnet_count].mask) ) + if( (login_config.subnet[login_config.subnet_count].char_ip + & login_config.subnet[login_config.subnet_count].mask) != (login_config.subnet[login_config.subnet_count].map_ip + & login_config.subnet[login_config.subnet_count].mask) ) { ShowError("%s: Configuration Error: The char server (%s) and map server (%s) belong to different subnetworks!\n", lancfgName, w3, w4); continue; } - subnet_count++; + login_config.subnet_count++; } } - if( subnet_count > 1 ) /* only useful if there is more than 1 available */ - ShowStatus("Read information about %d subnetworks.\n", subnet_count); + if( login_config.subnet_count > 1 ) /* only useful if there is more than 1 available */ + ShowStatus("Read information about %d subnetworks.\n", login_config.subnet_count); fclose(fp); return 0; @@ -349,7 +330,7 @@ void login_fromchar_parse_auth(int fd, int id, const char *const ip) int request_id = RFIFOL(fd,19); RFIFOSKIP(fd,23); - node = (struct auth_node*)idb_get(auth_db, account_id); + node = (struct auth_node*)idb_get(login->auth_db, account_id); if( runflag == LOGINSERVER_ST_RUNNING && node != NULL && node->account_id == account_id && @@ -363,7 +344,7 @@ void login_fromchar_parse_auth(int fd, int id, const char *const ip) // send ack login->fromchar_auth_ack(fd, account_id, login_id1, login_id2, sex, request_id, node); // each auth entry can only be used once - idb_remove(auth_db, account_id); + idb_remove(login->auth_db, account_id); } else {// authentication not found @@ -699,11 +680,11 @@ void login_fromchar_parse_online_accounts(int fd, int id) struct online_login_data *p; int aid; uint32 i, users; - online_db->foreach(online_db, login->online_db_setoffline, id); //Set all chars from this char-server offline first + login->online_db->foreach(login->online_db, login->online_db_setoffline, id); //Set all chars from this char-server offline first users = RFIFOW(fd,4); for (i = 0; i < users; i++) { aid = RFIFOL(fd,6+i*4); - p = idb_ensure(online_db, aid, login->create_online_user); + p = idb_ensure(login->online_db, aid, login->create_online_user); p->char_server = id; if (p->waiting_disconnect != INVALID_TIMER) { @@ -732,7 +713,7 @@ void login_fromchar_parse_update_wan_ip(int fd, int id) void login_fromchar_parse_all_offline(int fd, int id) { ShowInfo("Setting accounts from char-server %d offline.\n", id); - online_db->foreach(online_db, login->online_db_setoffline, id); + login->online_db->foreach(login->online_db, login->online_db_setoffline, id); RFIFOSKIP(fd,2); } @@ -755,7 +736,7 @@ bool login_fromchar_parse_wrong_pincode(int fd) if( accounts->load_num(accounts, &acc, RFIFOL(fd,2) ) ) { struct online_login_data* ld; - if( ( ld = (struct online_login_data*)idb_get(online_db,acc.account_id) ) == NULL ) + if( ( ld = (struct online_login_data*)idb_get(login->online_db,acc.account_id) ) == NULL ) { RFIFOSKIP(fd,6); return true; @@ -1033,7 +1014,7 @@ int login_mmo_auth_new(const char* userid, const char* pass, const char sex, con //Account Registration Flood Protection by [Kevin] if( new_reg_tick == 0 ) new_reg_tick = timer->gettick(); - if( DIFF_TICK(tick, new_reg_tick) < 0 && num_regs >= allowed_regs ) { + if( DIFF_TICK(tick, new_reg_tick) < 0 && num_regs >= login_config.allowed_regs ) { ShowNotice("Account registration denied (registration limit exceeded)\n"); return 3; } @@ -1072,7 +1053,7 @@ int login_mmo_auth_new(const char* userid, const char* pass, const char sex, con if( DIFF_TICK(tick, new_reg_tick) > 0 ) {// Update the registration check. num_regs = 0; - new_reg_tick = tick + time_allowed*1000; + new_reg_tick = tick + login_config.time_allowed*1000; } ++num_regs; @@ -1273,7 +1254,7 @@ void login_auth_ok(struct login_session_data* sd) } { - struct online_login_data* data = (struct online_login_data*)idb_get(online_db, sd->account_id); + struct online_login_data* data = (struct online_login_data*)idb_get(login->online_db, sd->account_id); if( data ) {// account is already marked as online! if( data->char_server > -1 ) @@ -1290,7 +1271,7 @@ void login_auth_ok(struct login_session_data* sd) if( data->char_server == -1 ) {// client has authed but did not access char-server yet // wipe previous session - idb_remove(auth_db, sd->account_id); + idb_remove(login->auth_db, sd->account_id); login->remove_online_user(sd->account_id); data = NULL; } @@ -1343,7 +1324,7 @@ void login_auth_ok(struct login_session_data* sd) node->clienttype = sd->clienttype; node->group_id = sd->group_id; node->expiration_time = sd->expiration_time; - idb_put(auth_db, sd->account_id, node); + idb_put(login->auth_db, sd->account_id, node); { struct online_login_data* data; @@ -1736,6 +1717,8 @@ void login_set_defaults() login_config.min_group_id_to_connect = -1; login_config.check_client_version = false; login_config.client_version_to_connect = 20; + login_config.allowed_regs = 1; + login_config.time_allowed = 10; login_config.ipban = true; login_config.dynamic_pass_failure_ban = true; @@ -1747,6 +1730,7 @@ void login_set_defaults() login_config.client_hash_check = 0; login_config.client_hash_nodes = NULL; + login_config.subnet_count = 0; } //----------------------------------- @@ -1808,9 +1792,9 @@ int login_config_read(const char* cfgName) else if(!strcmpi(w1, "date_format")) safestrncpy(login_config.date_format, w2, sizeof(login_config.date_format)); else if(!strcmpi(w1, "allowed_regs")) //account flood protection system - allowed_regs = atoi(w2); + login_config.allowed_regs = atoi(w2); else if(!strcmpi(w1, "time_allowed")) - time_allowed = atoi(w2); + login_config.time_allowed = atoi(w2); else if(!strcmpi(w1, "use_dnsbl")) login_config.use_dnsbl = (bool)config_switch(w2); else if(!strcmpi(w1, "dnsbl_servers")) @@ -1898,16 +1882,16 @@ int do_final(void) { account_engine[0].db = NULL; } accounts = NULL; // destroyed in account_engine - online_db->destroy(online_db, NULL); - auth_db->destroy(auth_db, NULL); + login->online_db->destroy(login->online_db, NULL); + login->auth_db->destroy(login->auth_db, NULL); for( i = 0; i < ARRAYLENGTH(server); ++i ) chrif_server_destroy(i); - if( login_fd != -1 ) + if( login->fd != -1 ) { - do_close(login_fd); - login_fd = -1; + do_close(login->fd); + login->fd = -1; } HPM_login_do_final(); @@ -2008,11 +1992,11 @@ int do_init(int argc, char** argv) ipban_init(); // Online user database init - online_db = idb_alloc(DB_OPT_RELEASE_DATA); + login->online_db = idb_alloc(DB_OPT_RELEASE_DATA); timer->add_func_list(login->waiting_disconnect_timer, "login->waiting_disconnect_timer"); // Interserver auth init - auth_db = idb_alloc(DB_OPT_RELEASE_DATA); + login->auth_db = idb_alloc(DB_OPT_RELEASE_DATA); // set default parser as login_parse_login function set_defaultparse(login->parse_login); @@ -2036,7 +2020,7 @@ int do_init(int argc, char** argv) HPM->event(HPET_INIT); // server port open & binding - if( (login_fd = make_listen_bind(login_config.login_ip,login_config.login_port)) == -1 ) { + if( (login->fd = make_listen_bind(login_config.login_ip,login_config.login_port)) == -1 ) { ShowFatalError("Failed to bind to port '"CL_WHITE"%d"CL_RESET"'\n",login_config.login_port); exit(EXIT_FAILURE); } @@ -2056,6 +2040,7 @@ int do_init(int argc, char** argv) void login_defaults(void) { login = &login_s; + login->mmo_auth = login_mmo_auth; login->mmo_auth_new = login_mmo_auth_new; login->waiting_disconnect_timer = login_waiting_disconnect_timer; diff --git a/src/login/login.h b/src/login/login.h index 3d347857e..5dfbe7b95 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -81,6 +81,8 @@ struct Login_Config { int min_group_id_to_connect; // minimum group id to connect bool check_client_version; // check the clientversion set in the clientinfo ? uint32 client_version_to_connect; // the client version needed to connect (if checking is enabled) + int allowed_regs; // account registration flood protection [Kevin] + int time_allowed; // time in seconds bool ipban; // perform IP blocking (via contents of `ipbanlist`) ? bool dynamic_pass_failure_ban; // automatic IP blocking due to failed login attemps ? @@ -92,6 +94,14 @@ struct Login_Config { int client_hash_check; // flags for checking client md5 struct client_hash_node *client_hash_nodes; // linked list containg md5 hash for each gm group + + // Advanced subnet check [LuzZza] + struct s_subnet { + uint32 mask; + uint32 char_ip; + uint32 map_ip; + } subnet[16]; + int subnet_count; }; struct auth_node { @@ -123,6 +133,10 @@ extern struct mmo_char_server server[MAX_SERVERS]; extern struct Login_Config login_config; struct login_interface { + DBMap* auth_db; + DBMap* online_db; + int fd; + int (*mmo_auth) (struct login_session_data* sd, bool isServer); int (*mmo_auth_new) (const char* userid, const char* pass, const char sex, const char* last_ip); int (*waiting_disconnect_timer) (int tid, int64 tick, int id, intptr_t data); -- cgit v1.2.3-70-g09d2 From 29a2fd0fa38ad1ec131f64f4d7ec0aa7ffef907d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 26 Oct 2014 17:17:53 +0300 Subject: Fix login_interface for allow generate hooks from it. --- src/login/login.h | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/login/login.h b/src/login/login.h index 5dfbe7b95..2917ae2b3 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -132,6 +132,9 @@ struct online_login_data { extern struct mmo_char_server server[MAX_SERVERS]; extern struct Login_Config login_config; +/** + * Login.c Interface + **/ struct login_interface { DBMap* auth_db; DBMap* online_db; @@ -158,17 +161,17 @@ struct login_interface { void (*fromchar_ban) (int account_id, time_t timestamp); void (*fromchar_change_sex_other) (int account_id, char sex); void (*fromchar_pong) (int fd); - void (*fromchar_parse_auth) (int fd, int id, const char *const ip); + void (*fromchar_parse_auth) (int fd, int id, const char *ip); void (*fromchar_parse_update_users) (int fd, int id); - void (*fromchar_parse_request_change_email) (int fd, int id, const char *const ip); - void (*fromchar_parse_account_data) (int fd, int id, const char *const ip); + void (*fromchar_parse_request_change_email) (int fd, int id, const char *ip); + void (*fromchar_parse_account_data) (int fd, int id, const char *ip); void (*fromchar_parse_ping) (int fd); - void (*fromchar_parse_change_email) (int fd, int id, const char *const ip); - void (*fromchar_parse_account_update) (int fd, int id, const char *const ip); - void (*fromchar_parse_ban) (int fd, int id, const char *const ip); - void (*fromchar_parse_change_sex) (int fd, int id, const char *const ip); - void (*fromchar_parse_account_reg2) (int fd, int id, const char *const ip); - void (*fromchar_parse_unban) (int fd, int id, const char *const ip); + void (*fromchar_parse_change_email) (int fd, int id, const char *ip); + void (*fromchar_parse_account_update) (int fd, int id, const char *ip); + void (*fromchar_parse_ban) (int fd, int id, const char *ip); + void (*fromchar_parse_change_sex) (int fd, int id, const char *ip); + void (*fromchar_parse_account_reg2) (int fd, int id, const char *ip); + void (*fromchar_parse_unban) (int fd, int id, const char *ip); void (*fromchar_parse_account_online) (int fd, int id); void (*fromchar_parse_account_offline) (int fd); void (*fromchar_parse_online_accounts) (int fd, int id); @@ -186,11 +189,11 @@ struct login_interface { void (*login_error) (int fd, uint8 status); void (*parse_ping) (int fd, struct login_session_data* sd); void (*parse_client_md5) (int fd, struct login_session_data* sd); - bool (*parse_client_login) (int fd, struct login_session_data* sd, const char *const ip); + bool (*parse_client_login) (int fd, struct login_session_data* sd, const char *ip); void (*send_coding_key) (int fd, struct login_session_data* sd); void (*parse_request_coding_key) (int fd, struct login_session_data* sd); void (*char_server_connection_status) (int fd, struct login_session_data* sd, uint8 status); - void (*parse_request_connection) (int fd, struct login_session_data* sd, const char *const ip); + void (*parse_request_connection) (int fd, struct login_session_data* sd, const char *ip); int (*parse_login) (int fd); }; -- cgit v1.2.3-70-g09d2 From 1baf68e197ad64444dcb558d34235c1a670eb2ed Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 26 Oct 2014 19:59:35 +0300 Subject: fix plugins compilation. --- src/login/login.c | 10 +++++----- src/login/login.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/login/login.c b/src/login/login.c index 7fd941192..f64615553 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -289,7 +289,7 @@ int login_lan_config_read(const char *lancfgName) return 0; } -void login_fromchar_auth_ack(int fd, int account_id, uint32 login_id1, uint32 login_id2, uint8 sex, int request_id, struct auth_node* node) +void login_fromchar_auth_ack(int fd, int account_id, uint32 login_id1, uint32 login_id2, uint8 sex, int request_id, struct login_auth_node* node) { WFIFOHEAD(fd,33); WFIFOW(fd,0) = 0x2713; @@ -320,7 +320,7 @@ void login_fromchar_auth_ack(int fd, int account_id, uint32 login_id1, uint32 lo void login_fromchar_parse_auth(int fd, int id, const char *const ip) { - struct auth_node* node; + struct login_auth_node* node; int account_id = RFIFOL(fd,2); uint32 login_id1 = RFIFOL(fd,6); @@ -330,7 +330,7 @@ void login_fromchar_parse_auth(int fd, int id, const char *const ip) int request_id = RFIFOL(fd,19); RFIFOSKIP(fd,23); - node = (struct auth_node*)idb_get(login->auth_db, account_id); + node = (struct login_auth_node*)idb_get(login->auth_db, account_id); if( runflag == LOGINSERVER_ST_RUNNING && node != NULL && node->account_id == account_id && @@ -1221,7 +1221,7 @@ void login_auth_ok(struct login_session_data* sd) uint8 server_num, n; uint32 subnet_char_ip; - struct auth_node* node; + struct login_auth_node* node; int i; if( runflag != LOGINSERVER_ST_RUNNING ) @@ -1314,7 +1314,7 @@ void login_auth_ok(struct login_session_data* sd) WFIFOSET(fd,47+32*server_num); // create temporary auth entry - CREATE(node, struct auth_node, 1); + CREATE(node, struct login_auth_node, 1); node->account_id = sd->account_id; node->login_id1 = sd->login_id1; node->login_id2 = sd->login_id2; diff --git a/src/login/login.h b/src/login/login.h index 2917ae2b3..096329d33 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -104,7 +104,7 @@ struct Login_Config { int subnet_count; }; -struct auth_node { +struct login_auth_node { int account_id; uint32 login_id1; uint32 login_id2; @@ -157,7 +157,7 @@ struct login_interface { void (*fromchar_accinfo) (int fd, int account_id, int u_fd, int u_aid, int u_group, int map_fd, struct mmo_account *acc); void (*fromchar_account) (int fd, int account_id, struct mmo_account *acc); void (*fromchar_account_update_other) (int account_id, unsigned int state); - void (*fromchar_auth_ack) (int fd, int account_id, uint32 login_id1, uint32 login_id2, uint8 sex, int request_id, struct auth_node* node); + void (*fromchar_auth_ack) (int fd, int account_id, uint32 login_id1, uint32 login_id2, uint8 sex, int request_id, struct login_auth_node* node); void (*fromchar_ban) (int account_id, time_t timestamp); void (*fromchar_change_sex_other) (int account_id, char sex); void (*fromchar_pong) (int fd); -- cgit v1.2.3-70-g09d2 From a7a4df03d4fff968e0139a8b87ead0887ac63149 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 26 Oct 2014 21:54:28 +0300 Subject: Add login symbol in login server HPM. --- src/login/login.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/login/login.c b/src/login/login.c index f64615553..a8f0c1f87 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -1933,6 +1933,7 @@ void do_shutdown_login(void) void login_hp_symbols(void) { HPM->share(account_db_sql_up(accounts),"sql_handle"); + HPM->share(login,"login"); } //------------------------------ -- cgit v1.2.3-70-g09d2 From 0181f49270c0c06aa421cd9022aac2b597c90a77 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 28 Oct 2014 23:44:06 +0300 Subject: Add missing interface member initialisation in login.c --- src/login/login.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/login/login.c b/src/login/login.c index a8f0c1f87..8e2ed7f0f 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -2093,6 +2093,7 @@ void login_defaults(void) { login->parse_request_coding_key = login_parse_request_coding_key; login->parse_request_connection = login_parse_request_connection; login->auth_ok = login_auth_ok; + login->auth_failed = login_auth_failed; login->char_server_connection_status = login_char_server_connection_status; login->connection_problem = login_connection_problem; login->kick = login_kick; -- cgit v1.2.3-70-g09d2 From 05394b48d045f5dfd725dfc37565ee8ea354d21f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 3 Nov 2014 16:49:35 +0300 Subject: Add login_config into login interface in login.c --- src/login/login.c | 2 ++ src/login/login.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/login/login.c b/src/login/login.c index 8e2ed7f0f..fe5d08835 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -2042,6 +2042,8 @@ int do_init(int argc, char** argv) void login_defaults(void) { login = &login_s; + login->lc = &login_config; + login->mmo_auth = login_mmo_auth; login->mmo_auth_new = login_mmo_auth_new; login->waiting_disconnect_timer = login_waiting_disconnect_timer; diff --git a/src/login/login.h b/src/login/login.h index 096329d33..1dd402291 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -139,6 +139,7 @@ struct login_interface { DBMap* auth_db; DBMap* online_db; int fd; + struct Login_Config *lc; int (*mmo_auth) (struct login_session_data* sd, bool isServer); int (*mmo_auth_new) (const char* userid, const char* pass, const char sex, const char* last_ip); -- cgit v1.2.3-70-g09d2 From bbe7fedeaff263999f6c105835c23f0c0ad0a81f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 29 Oct 2014 12:20:58 +0300 Subject: Enable HPMHooking building for login server. --- src/plugins/HPMHooking.c | 1 + src/plugins/Makefile.in | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/HPMHooking.c b/src/plugins/HPMHooking.c index 3f3ecc4ec..da92c90b4 100644 --- a/src/plugins/HPMHooking.c +++ b/src/plugins/HPMHooking.c @@ -19,6 +19,7 @@ #define HPM_HOOKS_INCLUDE "../plugins/HPMHooking/HPMHooking_login.Hooks.inc" #define HPM_POINTS_INCLUDE "../plugins/HPMHooking/HPMHooking_login.HookingPoints.inc" #define HPM_SOURCES_INCLUDE "../plugins/HPMHooking/HPMHooking_login.sources.inc" +#include "../login/login.h" #elif defined (HPMHOOKING_CHAR) #define HPM_SERVER_TYPE SERVER_TYPE_CHAR #define HPM_CORE_INCLUDE "../plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc" diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in index 7f94e6b67..5c93edb84 100644 --- a/src/plugins/Makefile.in +++ b/src/plugins/Makefile.in @@ -28,7 +28,7 @@ HPMHOOKING = $(addprefix HPMHooking_, login char map) ALLPLUGINS = $(filter-out HPMHooking, $(basename $(wildcard *.c))) $(HPMHOOKING) # Plugins that will be built through 'make plugins' or 'make all' -PLUGINS = sample db2sql HPMHooking_map $(MYPLUGINS) +PLUGINS = sample db2sql HPMHooking_login HPMHooking_map $(MYPLUGINS) COMMON_D = ../common COMMON_H = $(wildcard $(COMMON_D)/*.h) -- cgit v1.2.3-70-g09d2 From 24c6aa90952a8f458556f4adcfe1ce7981f86262 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 3 Nov 2014 16:58:43 +0300 Subject: HPM Hooks Update. --- src/common/HPMDataCheck.h | 5 + .../HPMHooking/HPMHooking_login.GetSymbol.inc | 1 + .../HPMHooking/HPMHooking_login.HPMHooksCore.inc | 221 +++ .../HPMHooking/HPMHooking_login.HookingPoints.inc | 58 +- src/plugins/HPMHooking/HPMHooking_login.Hooks.inc | 1467 ++++++++++++++++++++ .../HPMHooking/HPMHooking_login.sources.inc | 1 + 6 files changed, 1752 insertions(+), 1 deletion(-) diff --git a/src/common/HPMDataCheck.h b/src/common/HPMDataCheck.h index 9f4316617..ccaf21828 100644 --- a/src/common/HPMDataCheck.h +++ b/src/common/HPMDataCheck.h @@ -56,6 +56,11 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #else #define COMMON_SYSINFO_H #endif // COMMON_SYSINFO_H + #ifdef LOGIN_LOGIN_H + { "login_interface", sizeof(struct login_interface), SERVER_TYPE_LOGIN }, + #else + #define LOGIN_LOGIN_H + #endif // LOGIN_LOGIN_H #ifdef MAP_ATCOMMAND_H { "AliasInfo", sizeof(struct AliasInfo), SERVER_TYPE_MAP }, { "atcommand_interface", sizeof(struct atcommand_interface), SERVER_TYPE_MAP }, diff --git a/src/plugins/HPMHooking/HPMHooking_login.GetSymbol.inc b/src/plugins/HPMHooking/HPMHooking_login.GetSymbol.inc index 6dcfae29d..3348b5cde 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.GetSymbol.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.GetSymbol.inc @@ -4,3 +4,4 @@ // NOTE: This file was auto-generated and should never be manually edited, // as it will get overwritten. +if( !(login = GET_SYMBOL("login") ) ) return false; diff --git a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc index 4c380b367..af7e7250c 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc @@ -5,10 +5,231 @@ // as it will get overwritten. struct { + struct HPMHookPoint *HP_login_mmo_auth_pre; + struct HPMHookPoint *HP_login_mmo_auth_post; + struct HPMHookPoint *HP_login_mmo_auth_new_pre; + struct HPMHookPoint *HP_login_mmo_auth_new_post; + struct HPMHookPoint *HP_login_waiting_disconnect_timer_pre; + struct HPMHookPoint *HP_login_waiting_disconnect_timer_post; + struct HPMHookPoint *HP_login_create_online_user_pre; + struct HPMHookPoint *HP_login_create_online_user_post; + struct HPMHookPoint *HP_login_add_online_user_pre; + struct HPMHookPoint *HP_login_add_online_user_post; + struct HPMHookPoint *HP_login_remove_online_user_pre; + struct HPMHookPoint *HP_login_remove_online_user_post; + struct HPMHookPoint *HP_login_online_db_setoffline_pre; + struct HPMHookPoint *HP_login_online_db_setoffline_post; + struct HPMHookPoint *HP_login_online_data_cleanup_sub_pre; + struct HPMHookPoint *HP_login_online_data_cleanup_sub_post; + struct HPMHookPoint *HP_login_online_data_cleanup_pre; + struct HPMHookPoint *HP_login_online_data_cleanup_post; + struct HPMHookPoint *HP_login_sync_ip_addresses_pre; + struct HPMHookPoint *HP_login_sync_ip_addresses_post; + struct HPMHookPoint *HP_login_check_encrypted_pre; + struct HPMHookPoint *HP_login_check_encrypted_post; + struct HPMHookPoint *HP_login_check_password_pre; + struct HPMHookPoint *HP_login_check_password_post; + struct HPMHookPoint *HP_login_lan_subnetcheck_pre; + struct HPMHookPoint *HP_login_lan_subnetcheck_post; + struct HPMHookPoint *HP_login_lan_config_read_pre; + struct HPMHookPoint *HP_login_lan_config_read_post; + struct HPMHookPoint *HP_login_fromchar_accinfo_pre; + struct HPMHookPoint *HP_login_fromchar_accinfo_post; + struct HPMHookPoint *HP_login_fromchar_account_pre; + struct HPMHookPoint *HP_login_fromchar_account_post; + struct HPMHookPoint *HP_login_fromchar_account_update_other_pre; + struct HPMHookPoint *HP_login_fromchar_account_update_other_post; + struct HPMHookPoint *HP_login_fromchar_auth_ack_pre; + struct HPMHookPoint *HP_login_fromchar_auth_ack_post; + struct HPMHookPoint *HP_login_fromchar_ban_pre; + struct HPMHookPoint *HP_login_fromchar_ban_post; + struct HPMHookPoint *HP_login_fromchar_change_sex_other_pre; + struct HPMHookPoint *HP_login_fromchar_change_sex_other_post; + struct HPMHookPoint *HP_login_fromchar_pong_pre; + struct HPMHookPoint *HP_login_fromchar_pong_post; + struct HPMHookPoint *HP_login_fromchar_parse_auth_pre; + struct HPMHookPoint *HP_login_fromchar_parse_auth_post; + struct HPMHookPoint *HP_login_fromchar_parse_update_users_pre; + struct HPMHookPoint *HP_login_fromchar_parse_update_users_post; + struct HPMHookPoint *HP_login_fromchar_parse_request_change_email_pre; + struct HPMHookPoint *HP_login_fromchar_parse_request_change_email_post; + struct HPMHookPoint *HP_login_fromchar_parse_account_data_pre; + struct HPMHookPoint *HP_login_fromchar_parse_account_data_post; + struct HPMHookPoint *HP_login_fromchar_parse_ping_pre; + struct HPMHookPoint *HP_login_fromchar_parse_ping_post; + struct HPMHookPoint *HP_login_fromchar_parse_change_email_pre; + struct HPMHookPoint *HP_login_fromchar_parse_change_email_post; + struct HPMHookPoint *HP_login_fromchar_parse_account_update_pre; + struct HPMHookPoint *HP_login_fromchar_parse_account_update_post; + struct HPMHookPoint *HP_login_fromchar_parse_ban_pre; + struct HPMHookPoint *HP_login_fromchar_parse_ban_post; + struct HPMHookPoint *HP_login_fromchar_parse_change_sex_pre; + struct HPMHookPoint *HP_login_fromchar_parse_change_sex_post; + struct HPMHookPoint *HP_login_fromchar_parse_account_reg2_pre; + struct HPMHookPoint *HP_login_fromchar_parse_account_reg2_post; + struct HPMHookPoint *HP_login_fromchar_parse_unban_pre; + struct HPMHookPoint *HP_login_fromchar_parse_unban_post; + struct HPMHookPoint *HP_login_fromchar_parse_account_online_pre; + struct HPMHookPoint *HP_login_fromchar_parse_account_online_post; + struct HPMHookPoint *HP_login_fromchar_parse_account_offline_pre; + struct HPMHookPoint *HP_login_fromchar_parse_account_offline_post; + struct HPMHookPoint *HP_login_fromchar_parse_online_accounts_pre; + struct HPMHookPoint *HP_login_fromchar_parse_online_accounts_post; + struct HPMHookPoint *HP_login_fromchar_parse_request_account_reg2_pre; + struct HPMHookPoint *HP_login_fromchar_parse_request_account_reg2_post; + struct HPMHookPoint *HP_login_fromchar_parse_update_wan_ip_pre; + struct HPMHookPoint *HP_login_fromchar_parse_update_wan_ip_post; + struct HPMHookPoint *HP_login_fromchar_parse_all_offline_pre; + struct HPMHookPoint *HP_login_fromchar_parse_all_offline_post; + struct HPMHookPoint *HP_login_fromchar_parse_change_pincode_pre; + struct HPMHookPoint *HP_login_fromchar_parse_change_pincode_post; + struct HPMHookPoint *HP_login_fromchar_parse_wrong_pincode_pre; + struct HPMHookPoint *HP_login_fromchar_parse_wrong_pincode_post; + struct HPMHookPoint *HP_login_fromchar_parse_accinfo_pre; + struct HPMHookPoint *HP_login_fromchar_parse_accinfo_post; + struct HPMHookPoint *HP_login_parse_fromchar_pre; + struct HPMHookPoint *HP_login_parse_fromchar_post; + struct HPMHookPoint *HP_login_connection_problem_pre; + struct HPMHookPoint *HP_login_connection_problem_post; + struct HPMHookPoint *HP_login_kick_pre; + struct HPMHookPoint *HP_login_kick_post; + struct HPMHookPoint *HP_login_auth_ok_pre; + struct HPMHookPoint *HP_login_auth_ok_post; + struct HPMHookPoint *HP_login_auth_failed_pre; + struct HPMHookPoint *HP_login_auth_failed_post; + struct HPMHookPoint *HP_login_login_error_pre; + struct HPMHookPoint *HP_login_login_error_post; + struct HPMHookPoint *HP_login_parse_ping_pre; + struct HPMHookPoint *HP_login_parse_ping_post; + struct HPMHookPoint *HP_login_parse_client_md5_pre; + struct HPMHookPoint *HP_login_parse_client_md5_post; + struct HPMHookPoint *HP_login_parse_client_login_pre; + struct HPMHookPoint *HP_login_parse_client_login_post; + struct HPMHookPoint *HP_login_send_coding_key_pre; + struct HPMHookPoint *HP_login_send_coding_key_post; + struct HPMHookPoint *HP_login_parse_request_coding_key_pre; + struct HPMHookPoint *HP_login_parse_request_coding_key_post; + struct HPMHookPoint *HP_login_char_server_connection_status_pre; + struct HPMHookPoint *HP_login_char_server_connection_status_post; + struct HPMHookPoint *HP_login_parse_request_connection_pre; + struct HPMHookPoint *HP_login_parse_request_connection_post; + struct HPMHookPoint *HP_login_parse_login_pre; + struct HPMHookPoint *HP_login_parse_login_post; } list; struct { + int HP_login_mmo_auth_pre; + int HP_login_mmo_auth_post; + int HP_login_mmo_auth_new_pre; + int HP_login_mmo_auth_new_post; + int HP_login_waiting_disconnect_timer_pre; + int HP_login_waiting_disconnect_timer_post; + int HP_login_create_online_user_pre; + int HP_login_create_online_user_post; + int HP_login_add_online_user_pre; + int HP_login_add_online_user_post; + int HP_login_remove_online_user_pre; + int HP_login_remove_online_user_post; + int HP_login_online_db_setoffline_pre; + int HP_login_online_db_setoffline_post; + int HP_login_online_data_cleanup_sub_pre; + int HP_login_online_data_cleanup_sub_post; + int HP_login_online_data_cleanup_pre; + int HP_login_online_data_cleanup_post; + int HP_login_sync_ip_addresses_pre; + int HP_login_sync_ip_addresses_post; + int HP_login_check_encrypted_pre; + int HP_login_check_encrypted_post; + int HP_login_check_password_pre; + int HP_login_check_password_post; + int HP_login_lan_subnetcheck_pre; + int HP_login_lan_subnetcheck_post; + int HP_login_lan_config_read_pre; + int HP_login_lan_config_read_post; + int HP_login_fromchar_accinfo_pre; + int HP_login_fromchar_accinfo_post; + int HP_login_fromchar_account_pre; + int HP_login_fromchar_account_post; + int HP_login_fromchar_account_update_other_pre; + int HP_login_fromchar_account_update_other_post; + int HP_login_fromchar_auth_ack_pre; + int HP_login_fromchar_auth_ack_post; + int HP_login_fromchar_ban_pre; + int HP_login_fromchar_ban_post; + int HP_login_fromchar_change_sex_other_pre; + int HP_login_fromchar_change_sex_other_post; + int HP_login_fromchar_pong_pre; + int HP_login_fromchar_pong_post; + int HP_login_fromchar_parse_auth_pre; + int HP_login_fromchar_parse_auth_post; + int HP_login_fromchar_parse_update_users_pre; + int HP_login_fromchar_parse_update_users_post; + int HP_login_fromchar_parse_request_change_email_pre; + int HP_login_fromchar_parse_request_change_email_post; + int HP_login_fromchar_parse_account_data_pre; + int HP_login_fromchar_parse_account_data_post; + int HP_login_fromchar_parse_ping_pre; + int HP_login_fromchar_parse_ping_post; + int HP_login_fromchar_parse_change_email_pre; + int HP_login_fromchar_parse_change_email_post; + int HP_login_fromchar_parse_account_update_pre; + int HP_login_fromchar_parse_account_update_post; + int HP_login_fromchar_parse_ban_pre; + int HP_login_fromchar_parse_ban_post; + int HP_login_fromchar_parse_change_sex_pre; + int HP_login_fromchar_parse_change_sex_post; + int HP_login_fromchar_parse_account_reg2_pre; + int HP_login_fromchar_parse_account_reg2_post; + int HP_login_fromchar_parse_unban_pre; + int HP_login_fromchar_parse_unban_post; + int HP_login_fromchar_parse_account_online_pre; + int HP_login_fromchar_parse_account_online_post; + int HP_login_fromchar_parse_account_offline_pre; + int HP_login_fromchar_parse_account_offline_post; + int HP_login_fromchar_parse_online_accounts_pre; + int HP_login_fromchar_parse_online_accounts_post; + int HP_login_fromchar_parse_request_account_reg2_pre; + int HP_login_fromchar_parse_request_account_reg2_post; + int HP_login_fromchar_parse_update_wan_ip_pre; + int HP_login_fromchar_parse_update_wan_ip_post; + int HP_login_fromchar_parse_all_offline_pre; + int HP_login_fromchar_parse_all_offline_post; + int HP_login_fromchar_parse_change_pincode_pre; + int HP_login_fromchar_parse_change_pincode_post; + int HP_login_fromchar_parse_wrong_pincode_pre; + int HP_login_fromchar_parse_wrong_pincode_post; + int HP_login_fromchar_parse_accinfo_pre; + int HP_login_fromchar_parse_accinfo_post; + int HP_login_parse_fromchar_pre; + int HP_login_parse_fromchar_post; + int HP_login_connection_problem_pre; + int HP_login_connection_problem_post; + int HP_login_kick_pre; + int HP_login_kick_post; + int HP_login_auth_ok_pre; + int HP_login_auth_ok_post; + int HP_login_auth_failed_pre; + int HP_login_auth_failed_post; + int HP_login_login_error_pre; + int HP_login_login_error_post; + int HP_login_parse_ping_pre; + int HP_login_parse_ping_post; + int HP_login_parse_client_md5_pre; + int HP_login_parse_client_md5_post; + int HP_login_parse_client_login_pre; + int HP_login_parse_client_login_post; + int HP_login_send_coding_key_pre; + int HP_login_send_coding_key_post; + int HP_login_parse_request_coding_key_pre; + int HP_login_parse_request_coding_key_post; + int HP_login_char_server_connection_status_pre; + int HP_login_char_server_connection_status_post; + int HP_login_parse_request_connection_pre; + int HP_login_parse_request_connection_post; + int HP_login_parse_login_pre; + int HP_login_parse_login_post; } count; struct { + struct login_interface login; } source; diff --git a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc index 6752a4324..a4a9db119 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc @@ -5,6 +5,62 @@ // as it will get overwritten. struct HookingPointData HookingPoints[] = { +/* login */ + { HP_POP(login->mmo_auth, HP_login_mmo_auth) }, + { HP_POP(login->mmo_auth_new, HP_login_mmo_auth_new) }, + { HP_POP(login->waiting_disconnect_timer, HP_login_waiting_disconnect_timer) }, + { HP_POP(login->create_online_user, HP_login_create_online_user) }, + { HP_POP(login->add_online_user, HP_login_add_online_user) }, + { HP_POP(login->remove_online_user, HP_login_remove_online_user) }, + { HP_POP(login->online_db_setoffline, HP_login_online_db_setoffline) }, + { HP_POP(login->online_data_cleanup_sub, HP_login_online_data_cleanup_sub) }, + { HP_POP(login->online_data_cleanup, HP_login_online_data_cleanup) }, + { HP_POP(login->sync_ip_addresses, HP_login_sync_ip_addresses) }, + { HP_POP(login->check_encrypted, HP_login_check_encrypted) }, + { HP_POP(login->check_password, HP_login_check_password) }, + { HP_POP(login->lan_subnetcheck, HP_login_lan_subnetcheck) }, + { HP_POP(login->lan_config_read, HP_login_lan_config_read) }, + { HP_POP(login->fromchar_accinfo, HP_login_fromchar_accinfo) }, + { HP_POP(login->fromchar_account, HP_login_fromchar_account) }, + { HP_POP(login->fromchar_account_update_other, HP_login_fromchar_account_update_other) }, + { HP_POP(login->fromchar_auth_ack, HP_login_fromchar_auth_ack) }, + { HP_POP(login->fromchar_ban, HP_login_fromchar_ban) }, + { HP_POP(login->fromchar_change_sex_other, HP_login_fromchar_change_sex_other) }, + { HP_POP(login->fromchar_pong, HP_login_fromchar_pong) }, + { HP_POP(login->fromchar_parse_auth, HP_login_fromchar_parse_auth) }, + { HP_POP(login->fromchar_parse_update_users, HP_login_fromchar_parse_update_users) }, + { HP_POP(login->fromchar_parse_request_change_email, HP_login_fromchar_parse_request_change_email) }, + { HP_POP(login->fromchar_parse_account_data, HP_login_fromchar_parse_account_data) }, + { HP_POP(login->fromchar_parse_ping, HP_login_fromchar_parse_ping) }, + { HP_POP(login->fromchar_parse_change_email, HP_login_fromchar_parse_change_email) }, + { HP_POP(login->fromchar_parse_account_update, HP_login_fromchar_parse_account_update) }, + { HP_POP(login->fromchar_parse_ban, HP_login_fromchar_parse_ban) }, + { HP_POP(login->fromchar_parse_change_sex, HP_login_fromchar_parse_change_sex) }, + { HP_POP(login->fromchar_parse_account_reg2, HP_login_fromchar_parse_account_reg2) }, + { HP_POP(login->fromchar_parse_unban, HP_login_fromchar_parse_unban) }, + { HP_POP(login->fromchar_parse_account_online, HP_login_fromchar_parse_account_online) }, + { HP_POP(login->fromchar_parse_account_offline, HP_login_fromchar_parse_account_offline) }, + { HP_POP(login->fromchar_parse_online_accounts, HP_login_fromchar_parse_online_accounts) }, + { HP_POP(login->fromchar_parse_request_account_reg2, HP_login_fromchar_parse_request_account_reg2) }, + { HP_POP(login->fromchar_parse_update_wan_ip, HP_login_fromchar_parse_update_wan_ip) }, + { HP_POP(login->fromchar_parse_all_offline, HP_login_fromchar_parse_all_offline) }, + { HP_POP(login->fromchar_parse_change_pincode, HP_login_fromchar_parse_change_pincode) }, + { HP_POP(login->fromchar_parse_wrong_pincode, HP_login_fromchar_parse_wrong_pincode) }, + { HP_POP(login->fromchar_parse_accinfo, HP_login_fromchar_parse_accinfo) }, + { HP_POP(login->parse_fromchar, HP_login_parse_fromchar) }, + { HP_POP(login->connection_problem, HP_login_connection_problem) }, + { HP_POP(login->kick, HP_login_kick) }, + { HP_POP(login->auth_ok, HP_login_auth_ok) }, + { HP_POP(login->auth_failed, HP_login_auth_failed) }, + { HP_POP(login->login_error, HP_login_login_error) }, + { HP_POP(login->parse_ping, HP_login_parse_ping) }, + { HP_POP(login->parse_client_md5, HP_login_parse_client_md5) }, + { HP_POP(login->parse_client_login, HP_login_parse_client_login) }, + { HP_POP(login->send_coding_key, HP_login_send_coding_key) }, + { HP_POP(login->parse_request_coding_key, HP_login_parse_request_coding_key) }, + { HP_POP(login->char_server_connection_status, HP_login_char_server_connection_status) }, + { HP_POP(login->parse_request_connection, HP_login_parse_request_connection) }, + { HP_POP(login->parse_login, HP_login_parse_login) }, }; -int HookingPointsLenMax = 0; +int HookingPointsLenMax = 42; diff --git a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc index 6dcfae29d..1ebd9fd1a 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc @@ -4,3 +4,1470 @@ // NOTE: This file was auto-generated and should never be manually edited, // as it will get overwritten. +/* login */ +int HP_login_mmo_auth(struct login_session_data *sd, bool isServer) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_login_mmo_auth_pre ) { + int (*preHookFunc) (struct login_session_data *sd, bool *isServer); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_mmo_auth_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_mmo_auth_pre[hIndex].func; + retVal___ = preHookFunc(sd, &isServer); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.login.mmo_auth(sd, isServer); + } + if( HPMHooks.count.HP_login_mmo_auth_post ) { + int (*postHookFunc) (int retVal___, struct login_session_data *sd, bool *isServer); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_mmo_auth_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_mmo_auth_post[hIndex].func; + retVal___ = postHookFunc(retVal___, sd, &isServer); + } + } + return retVal___; +} +int HP_login_mmo_auth_new(const char *userid, const char *pass, const char sex, const char *last_ip) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_login_mmo_auth_new_pre ) { + int (*preHookFunc) (const char *userid, const char *pass, const char *sex, const char *last_ip); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_mmo_auth_new_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_mmo_auth_new_pre[hIndex].func; + retVal___ = preHookFunc(userid, pass, &sex, last_ip); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.login.mmo_auth_new(userid, pass, sex, last_ip); + } + if( HPMHooks.count.HP_login_mmo_auth_new_post ) { + int (*postHookFunc) (int retVal___, const char *userid, const char *pass, const char *sex, const char *last_ip); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_mmo_auth_new_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_mmo_auth_new_post[hIndex].func; + retVal___ = postHookFunc(retVal___, userid, pass, &sex, last_ip); + } + } + return retVal___; +} +int HP_login_waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_login_waiting_disconnect_timer_pre ) { + int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_waiting_disconnect_timer_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_waiting_disconnect_timer_pre[hIndex].func; + retVal___ = preHookFunc(&tid, &tick, &id, &data); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.login.waiting_disconnect_timer(tid, tick, id, data); + } + if( HPMHooks.count.HP_login_waiting_disconnect_timer_post ) { + int (*postHookFunc) (int retVal___, int *tid, int64 *tick, int *id, intptr_t *data); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_waiting_disconnect_timer_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_waiting_disconnect_timer_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &tid, &tick, &id, &data); + } + } + return retVal___; +} +DBData HP_login_create_online_user(DBKey key, va_list args) { + int hIndex = 0; + DBData retVal___; + memset(&retVal___, '\0', sizeof(DBData)); + if( HPMHooks.count.HP_login_create_online_user_pre ) { + DBData (*preHookFunc) (DBKey *key, va_list args); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_create_online_user_pre; hIndex++ ) { + va_list args___copy; va_copy(args___copy, args); + preHookFunc = HPMHooks.list.HP_login_create_online_user_pre[hIndex].func; + retVal___ = preHookFunc(&key, args___copy); + va_end(args___copy); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + va_list args___copy; va_copy(args___copy, args); + retVal___ = HPMHooks.source.login.create_online_user(key, args___copy); + va_end(args___copy); + } + if( HPMHooks.count.HP_login_create_online_user_post ) { + DBData (*postHookFunc) (DBData retVal___, DBKey *key, va_list args); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_create_online_user_post; hIndex++ ) { + va_list args___copy; va_copy(args___copy, args); + postHookFunc = HPMHooks.list.HP_login_create_online_user_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &key, args___copy); + va_end(args___copy); + } + } + return retVal___; +} +struct online_login_data* HP_login_add_online_user(int char_server, int account_id) { + int hIndex = 0; + struct online_login_data* retVal___ = NULL; + if( HPMHooks.count.HP_login_add_online_user_pre ) { + struct online_login_data* (*preHookFunc) (int *char_server, int *account_id); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_add_online_user_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_add_online_user_pre[hIndex].func; + retVal___ = preHookFunc(&char_server, &account_id); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.login.add_online_user(char_server, account_id); + } + if( HPMHooks.count.HP_login_add_online_user_post ) { + struct online_login_data* (*postHookFunc) (struct online_login_data* retVal___, int *char_server, int *account_id); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_add_online_user_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_add_online_user_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &char_server, &account_id); + } + } + return retVal___; +} +void HP_login_remove_online_user(int account_id) { + int hIndex = 0; + if( HPMHooks.count.HP_login_remove_online_user_pre ) { + void (*preHookFunc) (int *account_id); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_remove_online_user_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_remove_online_user_pre[hIndex].func; + preHookFunc(&account_id); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.remove_online_user(account_id); + } + if( HPMHooks.count.HP_login_remove_online_user_post ) { + void (*postHookFunc) (int *account_id); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_remove_online_user_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_remove_online_user_post[hIndex].func; + postHookFunc(&account_id); + } + } + return; +} +int HP_login_online_db_setoffline(DBKey key, DBData *data, va_list ap) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_login_online_db_setoffline_pre ) { + int (*preHookFunc) (DBKey *key, DBData *data, va_list ap); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_online_db_setoffline_pre; hIndex++ ) { + va_list ap___copy; va_copy(ap___copy, ap); + preHookFunc = HPMHooks.list.HP_login_online_db_setoffline_pre[hIndex].func; + retVal___ = preHookFunc(&key, data, ap___copy); + va_end(ap___copy); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + va_list ap___copy; va_copy(ap___copy, ap); + retVal___ = HPMHooks.source.login.online_db_setoffline(key, data, ap___copy); + va_end(ap___copy); + } + if( HPMHooks.count.HP_login_online_db_setoffline_post ) { + int (*postHookFunc) (int retVal___, DBKey *key, DBData *data, va_list ap); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_online_db_setoffline_post; hIndex++ ) { + va_list ap___copy; va_copy(ap___copy, ap); + postHookFunc = HPMHooks.list.HP_login_online_db_setoffline_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &key, data, ap___copy); + va_end(ap___copy); + } + } + return retVal___; +} +int HP_login_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_login_online_data_cleanup_sub_pre ) { + int (*preHookFunc) (DBKey *key, DBData *data, va_list ap); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_online_data_cleanup_sub_pre; hIndex++ ) { + va_list ap___copy; va_copy(ap___copy, ap); + preHookFunc = HPMHooks.list.HP_login_online_data_cleanup_sub_pre[hIndex].func; + retVal___ = preHookFunc(&key, data, ap___copy); + va_end(ap___copy); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + va_list ap___copy; va_copy(ap___copy, ap); + retVal___ = HPMHooks.source.login.online_data_cleanup_sub(key, data, ap___copy); + va_end(ap___copy); + } + if( HPMHooks.count.HP_login_online_data_cleanup_sub_post ) { + int (*postHookFunc) (int retVal___, DBKey *key, DBData *data, va_list ap); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_online_data_cleanup_sub_post; hIndex++ ) { + va_list ap___copy; va_copy(ap___copy, ap); + postHookFunc = HPMHooks.list.HP_login_online_data_cleanup_sub_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &key, data, ap___copy); + va_end(ap___copy); + } + } + return retVal___; +} +int HP_login_online_data_cleanup(int tid, int64 tick, int id, intptr_t data) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_login_online_data_cleanup_pre ) { + int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_online_data_cleanup_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_online_data_cleanup_pre[hIndex].func; + retVal___ = preHookFunc(&tid, &tick, &id, &data); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.login.online_data_cleanup(tid, tick, id, data); + } + if( HPMHooks.count.HP_login_online_data_cleanup_post ) { + int (*postHookFunc) (int retVal___, int *tid, int64 *tick, int *id, intptr_t *data); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_online_data_cleanup_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_online_data_cleanup_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &tid, &tick, &id, &data); + } + } + return retVal___; +} +int HP_login_sync_ip_addresses(int tid, int64 tick, int id, intptr_t data) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_login_sync_ip_addresses_pre ) { + int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_sync_ip_addresses_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_sync_ip_addresses_pre[hIndex].func; + retVal___ = preHookFunc(&tid, &tick, &id, &data); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.login.sync_ip_addresses(tid, tick, id, data); + } + if( HPMHooks.count.HP_login_sync_ip_addresses_post ) { + int (*postHookFunc) (int retVal___, int *tid, int64 *tick, int *id, intptr_t *data); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_sync_ip_addresses_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_sync_ip_addresses_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &tid, &tick, &id, &data); + } + } + return retVal___; +} +bool HP_login_check_encrypted(const char *str1, const char *str2, const char *passwd) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_login_check_encrypted_pre ) { + bool (*preHookFunc) (const char *str1, const char *str2, const char *passwd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_check_encrypted_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_check_encrypted_pre[hIndex].func; + retVal___ = preHookFunc(str1, str2, passwd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.login.check_encrypted(str1, str2, passwd); + } + if( HPMHooks.count.HP_login_check_encrypted_post ) { + bool (*postHookFunc) (bool retVal___, const char *str1, const char *str2, const char *passwd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_check_encrypted_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_check_encrypted_post[hIndex].func; + retVal___ = postHookFunc(retVal___, str1, str2, passwd); + } + } + return retVal___; +} +bool HP_login_check_password(const char *md5key, int passwdenc, const char *passwd, const char *refpass) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_login_check_password_pre ) { + bool (*preHookFunc) (const char *md5key, int *passwdenc, const char *passwd, const char *refpass); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_check_password_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_check_password_pre[hIndex].func; + retVal___ = preHookFunc(md5key, &passwdenc, passwd, refpass); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.login.check_password(md5key, passwdenc, passwd, refpass); + } + if( HPMHooks.count.HP_login_check_password_post ) { + bool (*postHookFunc) (bool retVal___, const char *md5key, int *passwdenc, const char *passwd, const char *refpass); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_check_password_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_check_password_post[hIndex].func; + retVal___ = postHookFunc(retVal___, md5key, &passwdenc, passwd, refpass); + } + } + return retVal___; +} +int HP_login_lan_subnetcheck(uint32 ip) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_login_lan_subnetcheck_pre ) { + int (*preHookFunc) (uint32 *ip); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_lan_subnetcheck_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_lan_subnetcheck_pre[hIndex].func; + retVal___ = preHookFunc(&ip); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.login.lan_subnetcheck(ip); + } + if( HPMHooks.count.HP_login_lan_subnetcheck_post ) { + int (*postHookFunc) (int retVal___, uint32 *ip); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_lan_subnetcheck_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_lan_subnetcheck_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &ip); + } + } + return retVal___; +} +int HP_login_lan_config_read(const char *lancfgName) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_login_lan_config_read_pre ) { + int (*preHookFunc) (const char *lancfgName); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_lan_config_read_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_lan_config_read_pre[hIndex].func; + retVal___ = preHookFunc(lancfgName); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.login.lan_config_read(lancfgName); + } + if( HPMHooks.count.HP_login_lan_config_read_post ) { + int (*postHookFunc) (int retVal___, const char *lancfgName); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_lan_config_read_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_lan_config_read_post[hIndex].func; + retVal___ = postHookFunc(retVal___, lancfgName); + } + } + return retVal___; +} +void HP_login_fromchar_accinfo(int fd, int account_id, int u_fd, int u_aid, int u_group, int map_fd, struct mmo_account *acc) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_accinfo_pre ) { + void (*preHookFunc) (int *fd, int *account_id, int *u_fd, int *u_aid, int *u_group, int *map_fd, struct mmo_account *acc); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_accinfo_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_accinfo_pre[hIndex].func; + preHookFunc(&fd, &account_id, &u_fd, &u_aid, &u_group, &map_fd, acc); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_accinfo(fd, account_id, u_fd, u_aid, u_group, map_fd, acc); + } + if( HPMHooks.count.HP_login_fromchar_accinfo_post ) { + void (*postHookFunc) (int *fd, int *account_id, int *u_fd, int *u_aid, int *u_group, int *map_fd, struct mmo_account *acc); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_accinfo_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_accinfo_post[hIndex].func; + postHookFunc(&fd, &account_id, &u_fd, &u_aid, &u_group, &map_fd, acc); + } + } + return; +} +void HP_login_fromchar_account(int fd, int account_id, struct mmo_account *acc) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_account_pre ) { + void (*preHookFunc) (int *fd, int *account_id, struct mmo_account *acc); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_account_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_account_pre[hIndex].func; + preHookFunc(&fd, &account_id, acc); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_account(fd, account_id, acc); + } + if( HPMHooks.count.HP_login_fromchar_account_post ) { + void (*postHookFunc) (int *fd, int *account_id, struct mmo_account *acc); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_account_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_account_post[hIndex].func; + postHookFunc(&fd, &account_id, acc); + } + } + return; +} +void HP_login_fromchar_account_update_other(int account_id, unsigned int state) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_account_update_other_pre ) { + void (*preHookFunc) (int *account_id, unsigned int *state); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_account_update_other_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_account_update_other_pre[hIndex].func; + preHookFunc(&account_id, &state); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_account_update_other(account_id, state); + } + if( HPMHooks.count.HP_login_fromchar_account_update_other_post ) { + void (*postHookFunc) (int *account_id, unsigned int *state); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_account_update_other_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_account_update_other_post[hIndex].func; + postHookFunc(&account_id, &state); + } + } + return; +} +void HP_login_fromchar_auth_ack(int fd, int account_id, uint32 login_id1, uint32 login_id2, uint8 sex, int request_id, struct login_auth_node *node) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_auth_ack_pre ) { + void (*preHookFunc) (int *fd, int *account_id, uint32 *login_id1, uint32 *login_id2, uint8 *sex, int *request_id, struct login_auth_node *node); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_auth_ack_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_auth_ack_pre[hIndex].func; + preHookFunc(&fd, &account_id, &login_id1, &login_id2, &sex, &request_id, node); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_auth_ack(fd, account_id, login_id1, login_id2, sex, request_id, node); + } + if( HPMHooks.count.HP_login_fromchar_auth_ack_post ) { + void (*postHookFunc) (int *fd, int *account_id, uint32 *login_id1, uint32 *login_id2, uint8 *sex, int *request_id, struct login_auth_node *node); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_auth_ack_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_auth_ack_post[hIndex].func; + postHookFunc(&fd, &account_id, &login_id1, &login_id2, &sex, &request_id, node); + } + } + return; +} +void HP_login_fromchar_ban(int account_id, time_t timestamp) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_ban_pre ) { + void (*preHookFunc) (int *account_id, time_t *timestamp); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_ban_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_ban_pre[hIndex].func; + preHookFunc(&account_id, ×tamp); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_ban(account_id, timestamp); + } + if( HPMHooks.count.HP_login_fromchar_ban_post ) { + void (*postHookFunc) (int *account_id, time_t *timestamp); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_ban_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_ban_post[hIndex].func; + postHookFunc(&account_id, ×tamp); + } + } + return; +} +void HP_login_fromchar_change_sex_other(int account_id, char sex) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_change_sex_other_pre ) { + void (*preHookFunc) (int *account_id, char *sex); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_change_sex_other_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_change_sex_other_pre[hIndex].func; + preHookFunc(&account_id, &sex); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_change_sex_other(account_id, sex); + } + if( HPMHooks.count.HP_login_fromchar_change_sex_other_post ) { + void (*postHookFunc) (int *account_id, char *sex); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_change_sex_other_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_change_sex_other_post[hIndex].func; + postHookFunc(&account_id, &sex); + } + } + return; +} +void HP_login_fromchar_pong(int fd) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_pong_pre ) { + void (*preHookFunc) (int *fd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_pong_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_pong_pre[hIndex].func; + preHookFunc(&fd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_pong(fd); + } + if( HPMHooks.count.HP_login_fromchar_pong_post ) { + void (*postHookFunc) (int *fd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_pong_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_pong_post[hIndex].func; + postHookFunc(&fd); + } + } + return; +} +void HP_login_fromchar_parse_auth(int fd, int id, const char *ip) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_auth_pre ) { + void (*preHookFunc) (int *fd, int *id, const char *ip); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_auth_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_auth_pre[hIndex].func; + preHookFunc(&fd, &id, ip); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_auth(fd, id, ip); + } + if( HPMHooks.count.HP_login_fromchar_parse_auth_post ) { + void (*postHookFunc) (int *fd, int *id, const char *ip); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_auth_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_auth_post[hIndex].func; + postHookFunc(&fd, &id, ip); + } + } + return; +} +void HP_login_fromchar_parse_update_users(int fd, int id) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_update_users_pre ) { + void (*preHookFunc) (int *fd, int *id); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_update_users_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_update_users_pre[hIndex].func; + preHookFunc(&fd, &id); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_update_users(fd, id); + } + if( HPMHooks.count.HP_login_fromchar_parse_update_users_post ) { + void (*postHookFunc) (int *fd, int *id); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_update_users_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_update_users_post[hIndex].func; + postHookFunc(&fd, &id); + } + } + return; +} +void HP_login_fromchar_parse_request_change_email(int fd, int id, const char *ip) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_request_change_email_pre ) { + void (*preHookFunc) (int *fd, int *id, const char *ip); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_request_change_email_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_request_change_email_pre[hIndex].func; + preHookFunc(&fd, &id, ip); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_request_change_email(fd, id, ip); + } + if( HPMHooks.count.HP_login_fromchar_parse_request_change_email_post ) { + void (*postHookFunc) (int *fd, int *id, const char *ip); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_request_change_email_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_request_change_email_post[hIndex].func; + postHookFunc(&fd, &id, ip); + } + } + return; +} +void HP_login_fromchar_parse_account_data(int fd, int id, const char *ip) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_account_data_pre ) { + void (*preHookFunc) (int *fd, int *id, const char *ip); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_data_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_data_pre[hIndex].func; + preHookFunc(&fd, &id, ip); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_account_data(fd, id, ip); + } + if( HPMHooks.count.HP_login_fromchar_parse_account_data_post ) { + void (*postHookFunc) (int *fd, int *id, const char *ip); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_data_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_data_post[hIndex].func; + postHookFunc(&fd, &id, ip); + } + } + return; +} +void HP_login_fromchar_parse_ping(int fd) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_ping_pre ) { + void (*preHookFunc) (int *fd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_ping_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_ping_pre[hIndex].func; + preHookFunc(&fd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_ping(fd); + } + if( HPMHooks.count.HP_login_fromchar_parse_ping_post ) { + void (*postHookFunc) (int *fd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_ping_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_ping_post[hIndex].func; + postHookFunc(&fd); + } + } + return; +} +void HP_login_fromchar_parse_change_email(int fd, int id, const char *ip) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_change_email_pre ) { + void (*preHookFunc) (int *fd, int *id, const char *ip); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_change_email_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_change_email_pre[hIndex].func; + preHookFunc(&fd, &id, ip); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_change_email(fd, id, ip); + } + if( HPMHooks.count.HP_login_fromchar_parse_change_email_post ) { + void (*postHookFunc) (int *fd, int *id, const char *ip); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_change_email_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_change_email_post[hIndex].func; + postHookFunc(&fd, &id, ip); + } + } + return; +} +void HP_login_fromchar_parse_account_update(int fd, int id, const char *ip) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_account_update_pre ) { + void (*preHookFunc) (int *fd, int *id, const char *ip); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_update_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_update_pre[hIndex].func; + preHookFunc(&fd, &id, ip); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_account_update(fd, id, ip); + } + if( HPMHooks.count.HP_login_fromchar_parse_account_update_post ) { + void (*postHookFunc) (int *fd, int *id, const char *ip); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_update_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_update_post[hIndex].func; + postHookFunc(&fd, &id, ip); + } + } + return; +} +void HP_login_fromchar_parse_ban(int fd, int id, const char *ip) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_ban_pre ) { + void (*preHookFunc) (int *fd, int *id, const char *ip); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_ban_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_ban_pre[hIndex].func; + preHookFunc(&fd, &id, ip); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_ban(fd, id, ip); + } + if( HPMHooks.count.HP_login_fromchar_parse_ban_post ) { + void (*postHookFunc) (int *fd, int *id, const char *ip); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_ban_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_ban_post[hIndex].func; + postHookFunc(&fd, &id, ip); + } + } + return; +} +void HP_login_fromchar_parse_change_sex(int fd, int id, const char *ip) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_change_sex_pre ) { + void (*preHookFunc) (int *fd, int *id, const char *ip); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_change_sex_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_change_sex_pre[hIndex].func; + preHookFunc(&fd, &id, ip); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_change_sex(fd, id, ip); + } + if( HPMHooks.count.HP_login_fromchar_parse_change_sex_post ) { + void (*postHookFunc) (int *fd, int *id, const char *ip); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_change_sex_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_change_sex_post[hIndex].func; + postHookFunc(&fd, &id, ip); + } + } + return; +} +void HP_login_fromchar_parse_account_reg2(int fd, int id, const char *ip) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_account_reg2_pre ) { + void (*preHookFunc) (int *fd, int *id, const char *ip); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_reg2_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_reg2_pre[hIndex].func; + preHookFunc(&fd, &id, ip); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_account_reg2(fd, id, ip); + } + if( HPMHooks.count.HP_login_fromchar_parse_account_reg2_post ) { + void (*postHookFunc) (int *fd, int *id, const char *ip); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_reg2_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_reg2_post[hIndex].func; + postHookFunc(&fd, &id, ip); + } + } + return; +} +void HP_login_fromchar_parse_unban(int fd, int id, const char *ip) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_unban_pre ) { + void (*preHookFunc) (int *fd, int *id, const char *ip); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_unban_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_unban_pre[hIndex].func; + preHookFunc(&fd, &id, ip); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_unban(fd, id, ip); + } + if( HPMHooks.count.HP_login_fromchar_parse_unban_post ) { + void (*postHookFunc) (int *fd, int *id, const char *ip); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_unban_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_unban_post[hIndex].func; + postHookFunc(&fd, &id, ip); + } + } + return; +} +void HP_login_fromchar_parse_account_online(int fd, int id) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_account_online_pre ) { + void (*preHookFunc) (int *fd, int *id); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_online_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_online_pre[hIndex].func; + preHookFunc(&fd, &id); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_account_online(fd, id); + } + if( HPMHooks.count.HP_login_fromchar_parse_account_online_post ) { + void (*postHookFunc) (int *fd, int *id); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_online_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_online_post[hIndex].func; + postHookFunc(&fd, &id); + } + } + return; +} +void HP_login_fromchar_parse_account_offline(int fd) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_account_offline_pre ) { + void (*preHookFunc) (int *fd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_offline_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_offline_pre[hIndex].func; + preHookFunc(&fd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_account_offline(fd); + } + if( HPMHooks.count.HP_login_fromchar_parse_account_offline_post ) { + void (*postHookFunc) (int *fd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_account_offline_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_account_offline_post[hIndex].func; + postHookFunc(&fd); + } + } + return; +} +void HP_login_fromchar_parse_online_accounts(int fd, int id) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_online_accounts_pre ) { + void (*preHookFunc) (int *fd, int *id); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_online_accounts_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_online_accounts_pre[hIndex].func; + preHookFunc(&fd, &id); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_online_accounts(fd, id); + } + if( HPMHooks.count.HP_login_fromchar_parse_online_accounts_post ) { + void (*postHookFunc) (int *fd, int *id); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_online_accounts_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_online_accounts_post[hIndex].func; + postHookFunc(&fd, &id); + } + } + return; +} +void HP_login_fromchar_parse_request_account_reg2(int fd) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_request_account_reg2_pre ) { + void (*preHookFunc) (int *fd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_request_account_reg2_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_request_account_reg2_pre[hIndex].func; + preHookFunc(&fd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_request_account_reg2(fd); + } + if( HPMHooks.count.HP_login_fromchar_parse_request_account_reg2_post ) { + void (*postHookFunc) (int *fd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_request_account_reg2_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_request_account_reg2_post[hIndex].func; + postHookFunc(&fd); + } + } + return; +} +void HP_login_fromchar_parse_update_wan_ip(int fd, int id) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_update_wan_ip_pre ) { + void (*preHookFunc) (int *fd, int *id); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_update_wan_ip_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_update_wan_ip_pre[hIndex].func; + preHookFunc(&fd, &id); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_update_wan_ip(fd, id); + } + if( HPMHooks.count.HP_login_fromchar_parse_update_wan_ip_post ) { + void (*postHookFunc) (int *fd, int *id); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_update_wan_ip_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_update_wan_ip_post[hIndex].func; + postHookFunc(&fd, &id); + } + } + return; +} +void HP_login_fromchar_parse_all_offline(int fd, int id) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_all_offline_pre ) { + void (*preHookFunc) (int *fd, int *id); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_all_offline_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_all_offline_pre[hIndex].func; + preHookFunc(&fd, &id); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_all_offline(fd, id); + } + if( HPMHooks.count.HP_login_fromchar_parse_all_offline_post ) { + void (*postHookFunc) (int *fd, int *id); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_all_offline_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_all_offline_post[hIndex].func; + postHookFunc(&fd, &id); + } + } + return; +} +void HP_login_fromchar_parse_change_pincode(int fd) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_change_pincode_pre ) { + void (*preHookFunc) (int *fd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_change_pincode_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_change_pincode_pre[hIndex].func; + preHookFunc(&fd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_change_pincode(fd); + } + if( HPMHooks.count.HP_login_fromchar_parse_change_pincode_post ) { + void (*postHookFunc) (int *fd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_change_pincode_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_change_pincode_post[hIndex].func; + postHookFunc(&fd); + } + } + return; +} +bool HP_login_fromchar_parse_wrong_pincode(int fd) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_login_fromchar_parse_wrong_pincode_pre ) { + bool (*preHookFunc) (int *fd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_wrong_pincode_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_wrong_pincode_pre[hIndex].func; + retVal___ = preHookFunc(&fd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.login.fromchar_parse_wrong_pincode(fd); + } + if( HPMHooks.count.HP_login_fromchar_parse_wrong_pincode_post ) { + bool (*postHookFunc) (bool retVal___, int *fd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_wrong_pincode_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_wrong_pincode_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd); + } + } + return retVal___; +} +void HP_login_fromchar_parse_accinfo(int fd) { + int hIndex = 0; + if( HPMHooks.count.HP_login_fromchar_parse_accinfo_pre ) { + void (*preHookFunc) (int *fd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_accinfo_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_fromchar_parse_accinfo_pre[hIndex].func; + preHookFunc(&fd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.fromchar_parse_accinfo(fd); + } + if( HPMHooks.count.HP_login_fromchar_parse_accinfo_post ) { + void (*postHookFunc) (int *fd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_fromchar_parse_accinfo_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_fromchar_parse_accinfo_post[hIndex].func; + postHookFunc(&fd); + } + } + return; +} +int HP_login_parse_fromchar(int fd) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_login_parse_fromchar_pre ) { + int (*preHookFunc) (int *fd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_fromchar_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_parse_fromchar_pre[hIndex].func; + retVal___ = preHookFunc(&fd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.login.parse_fromchar(fd); + } + if( HPMHooks.count.HP_login_parse_fromchar_post ) { + int (*postHookFunc) (int retVal___, int *fd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_fromchar_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_parse_fromchar_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd); + } + } + return retVal___; +} +void HP_login_connection_problem(int fd, uint8 status) { + int hIndex = 0; + if( HPMHooks.count.HP_login_connection_problem_pre ) { + void (*preHookFunc) (int *fd, uint8 *status); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_connection_problem_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_connection_problem_pre[hIndex].func; + preHookFunc(&fd, &status); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.connection_problem(fd, status); + } + if( HPMHooks.count.HP_login_connection_problem_post ) { + void (*postHookFunc) (int *fd, uint8 *status); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_connection_problem_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_connection_problem_post[hIndex].func; + postHookFunc(&fd, &status); + } + } + return; +} +void HP_login_kick(struct login_session_data *sd) { + int hIndex = 0; + if( HPMHooks.count.HP_login_kick_pre ) { + void (*preHookFunc) (struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_kick_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_kick_pre[hIndex].func; + preHookFunc(sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.kick(sd); + } + if( HPMHooks.count.HP_login_kick_post ) { + void (*postHookFunc) (struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_kick_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_kick_post[hIndex].func; + postHookFunc(sd); + } + } + return; +} +void HP_login_auth_ok(struct login_session_data *sd) { + int hIndex = 0; + if( HPMHooks.count.HP_login_auth_ok_pre ) { + void (*preHookFunc) (struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_auth_ok_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_auth_ok_pre[hIndex].func; + preHookFunc(sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.auth_ok(sd); + } + if( HPMHooks.count.HP_login_auth_ok_post ) { + void (*postHookFunc) (struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_auth_ok_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_auth_ok_post[hIndex].func; + postHookFunc(sd); + } + } + return; +} +void HP_login_auth_failed(struct login_session_data *sd, int result) { + int hIndex = 0; + if( HPMHooks.count.HP_login_auth_failed_pre ) { + void (*preHookFunc) (struct login_session_data *sd, int *result); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_auth_failed_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_auth_failed_pre[hIndex].func; + preHookFunc(sd, &result); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.auth_failed(sd, result); + } + if( HPMHooks.count.HP_login_auth_failed_post ) { + void (*postHookFunc) (struct login_session_data *sd, int *result); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_auth_failed_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_auth_failed_post[hIndex].func; + postHookFunc(sd, &result); + } + } + return; +} +void HP_login_login_error(int fd, uint8 status) { + int hIndex = 0; + if( HPMHooks.count.HP_login_login_error_pre ) { + void (*preHookFunc) (int *fd, uint8 *status); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_login_error_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_login_error_pre[hIndex].func; + preHookFunc(&fd, &status); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.login_error(fd, status); + } + if( HPMHooks.count.HP_login_login_error_post ) { + void (*postHookFunc) (int *fd, uint8 *status); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_login_error_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_login_error_post[hIndex].func; + postHookFunc(&fd, &status); + } + } + return; +} +void HP_login_parse_ping(int fd, struct login_session_data *sd) { + int hIndex = 0; + if( HPMHooks.count.HP_login_parse_ping_pre ) { + void (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_ping_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_parse_ping_pre[hIndex].func; + preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.parse_ping(fd, sd); + } + if( HPMHooks.count.HP_login_parse_ping_post ) { + void (*postHookFunc) (int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_ping_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_parse_ping_post[hIndex].func; + postHookFunc(&fd, sd); + } + } + return; +} +void HP_login_parse_client_md5(int fd, struct login_session_data *sd) { + int hIndex = 0; + if( HPMHooks.count.HP_login_parse_client_md5_pre ) { + void (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_client_md5_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_parse_client_md5_pre[hIndex].func; + preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.parse_client_md5(fd, sd); + } + if( HPMHooks.count.HP_login_parse_client_md5_post ) { + void (*postHookFunc) (int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_client_md5_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_parse_client_md5_post[hIndex].func; + postHookFunc(&fd, sd); + } + } + return; +} +bool HP_login_parse_client_login(int fd, struct login_session_data *sd, const char *ip) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_login_parse_client_login_pre ) { + bool (*preHookFunc) (int *fd, struct login_session_data *sd, const char *ip); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_client_login_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_parse_client_login_pre[hIndex].func; + retVal___ = preHookFunc(&fd, sd, ip); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.login.parse_client_login(fd, sd, ip); + } + if( HPMHooks.count.HP_login_parse_client_login_post ) { + bool (*postHookFunc) (bool retVal___, int *fd, struct login_session_data *sd, const char *ip); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_client_login_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_parse_client_login_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd, sd, ip); + } + } + return retVal___; +} +void HP_login_send_coding_key(int fd, struct login_session_data *sd) { + int hIndex = 0; + if( HPMHooks.count.HP_login_send_coding_key_pre ) { + void (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_send_coding_key_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_send_coding_key_pre[hIndex].func; + preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.send_coding_key(fd, sd); + } + if( HPMHooks.count.HP_login_send_coding_key_post ) { + void (*postHookFunc) (int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_send_coding_key_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_send_coding_key_post[hIndex].func; + postHookFunc(&fd, sd); + } + } + return; +} +void HP_login_parse_request_coding_key(int fd, struct login_session_data *sd) { + int hIndex = 0; + if( HPMHooks.count.HP_login_parse_request_coding_key_pre ) { + void (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_request_coding_key_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_parse_request_coding_key_pre[hIndex].func; + preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.parse_request_coding_key(fd, sd); + } + if( HPMHooks.count.HP_login_parse_request_coding_key_post ) { + void (*postHookFunc) (int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_request_coding_key_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_parse_request_coding_key_post[hIndex].func; + postHookFunc(&fd, sd); + } + } + return; +} +void HP_login_char_server_connection_status(int fd, struct login_session_data *sd, uint8 status) { + int hIndex = 0; + if( HPMHooks.count.HP_login_char_server_connection_status_pre ) { + void (*preHookFunc) (int *fd, struct login_session_data *sd, uint8 *status); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_char_server_connection_status_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_char_server_connection_status_pre[hIndex].func; + preHookFunc(&fd, sd, &status); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.char_server_connection_status(fd, sd, status); + } + if( HPMHooks.count.HP_login_char_server_connection_status_post ) { + void (*postHookFunc) (int *fd, struct login_session_data *sd, uint8 *status); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_char_server_connection_status_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_char_server_connection_status_post[hIndex].func; + postHookFunc(&fd, sd, &status); + } + } + return; +} +void HP_login_parse_request_connection(int fd, struct login_session_data *sd, const char *ip) { + int hIndex = 0; + if( HPMHooks.count.HP_login_parse_request_connection_pre ) { + void (*preHookFunc) (int *fd, struct login_session_data *sd, const char *ip); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_request_connection_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_parse_request_connection_pre[hIndex].func; + preHookFunc(&fd, sd, ip); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.parse_request_connection(fd, sd, ip); + } + if( HPMHooks.count.HP_login_parse_request_connection_post ) { + void (*postHookFunc) (int *fd, struct login_session_data *sd, const char *ip); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_request_connection_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_parse_request_connection_post[hIndex].func; + postHookFunc(&fd, sd, ip); + } + } + return; +} +int HP_login_parse_login(int fd) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_login_parse_login_pre ) { + int (*preHookFunc) (int *fd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_login_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_parse_login_pre[hIndex].func; + retVal___ = preHookFunc(&fd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.login.parse_login(fd); + } + if( HPMHooks.count.HP_login_parse_login_post ) { + int (*postHookFunc) (int retVal___, int *fd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_login_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_parse_login_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd); + } + } + return retVal___; +} diff --git a/src/plugins/HPMHooking/HPMHooking_login.sources.inc b/src/plugins/HPMHooking/HPMHooking_login.sources.inc index 6dcfae29d..aa1bb2625 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.sources.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.sources.inc @@ -4,3 +4,4 @@ // NOTE: This file was auto-generated and should never be manually edited, // as it will get overwritten. +memcpy(&HPMHooks.source.login, login, sizeof(struct login_interface)); -- cgit v1.2.3-70-g09d2