From b7bda5cccb691b35415a7aa1f51190c4ca487fc9 Mon Sep 17 00:00:00 2001 From: ultramage Date: Thu, 27 Mar 2008 12:06:12 +0000 Subject: Partial rewrite of the login server's auth system. * replaced the cyclic, size-limited auth_fifo data structure with the more appropriate DBMap-based alternative (stops some erratic behavior) * added code to simulate the pseudo-status "online on login server" * auth data will now expire after 30 seconds instead of persisting * better-than-aegis handling of login cancellation (the server will wipe all previous auth data instead of making you wait for it to expire) * proper status message - no more generic "rejected from server", now you'll get "the server still recognizes your last connection" * fixed a typo in r10110 which caused disconnect timer removal to fail * split off some parsing code to login_auth_ok() and login_auth_failed() * extended the auth confirmation packet so that the login_id1/2 values are sent along with the associated account id (stops charserver from making wrong choices if two incoming sessions have the same account id) * fixed a bug in the disconnect part of the main charserver parsing loop, where a non-authed client would erase the online db entry for a client that's already online, thus bypassing any dual-login checks * added code to stop the waiting_disconnect timer when the associated online entry is removed right away, instead of doing checks later * removed code that would periodically wipe the online status of clients that are in the auth process (producing yet more erratic behavior) * commented out some TXT-only reconnect prevention code (bugreport:1281) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12441 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/char/char.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/char') diff --git a/src/char/char.c b/src/char/char.c index 2a9c00943..0acb967ad 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2009,27 +2009,36 @@ int parse_fromlogin(int fd) // acknowledgement of account authentication request case 0x2713: - if (RFIFOREST(fd) < 51) + if (RFIFOREST(fd) < 59) return 0; + { + int account_id = RFIFOL(fd,2); + int login_id1 = RFIFOL(fd,6); + int login_id2 = RFIFOL(fd,10); + bool result = RFIFOB(fd,14); + const char* email = (const char*)RFIFOP(fd,15); + time_t connect_until = (time_t)RFIFOL(fd,55); // find the session with this account id - ARR_FIND( 0, fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->account_id == RFIFOL(fd,2) ); + ARR_FIND( 0, fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && + sd->account_id == account_id && sd->login_id1 == login_id1 && sd->login_id2 == login_id2 ); if( i < fd_max ) { - if( RFIFOB(fd,6) != 0 ) { // failure + if( result ) { // failure WFIFOHEAD(i,3); WFIFOW(i,0) = 0x6c; WFIFOB(i,2) = 0x42; WFIFOSET(i,3); } else { // success - memcpy(sd->email, RFIFOP(fd,7), 40); + memcpy(sd->email, email, 40); if (e_mail_check(sd->email) == 0) strncpy(sd->email, "a@a.com", 40); // default e-mail - sd->connect_until_time = (time_t)RFIFOL(fd,47); + sd->connect_until_time = connect_until; char_auth_ok(i, sd); } } - RFIFOSKIP(fd,51); + } + RFIFOSKIP(fd,59); break; // Receiving of an e-mail/time limit from the login-server (answer of a request because a player comes back from map-server to char-server) by [Yor] @@ -3223,12 +3232,12 @@ int parse_char(int fd) if(session[fd]->flag.eof) { - if (sd != NULL) + if( sd != NULL && sd->auth ) { struct online_char_data* data = (struct online_char_data*)idb_get(online_char_db, sd->account_id); - if (!data || data->server == -1) //If it is not in any server, send it offline. [Skotlex] + if( data == NULL || data->server == -1) //If it is not in any server, send it offline. [Skotlex] set_char_offline(99,sd->account_id); - if (data && data->fd == fd) + if( data != NULL && data->fd == fd) data->fd = -1; } do_close(fd); -- cgit v1.2.3-60-g2f50