loginclif.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "loginclif.hpp"
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include "../common/malloc.hpp"
  7. #include "../common/md5calc.hpp"
  8. #include "../common/random.hpp"
  9. #include "../common/showmsg.hpp" //show notice
  10. #include "../common/socket.hpp" //wfifo session
  11. #include "../common/strlib.hpp" //safeprint
  12. #include "../common/timer.hpp" //difftick
  13. #include "../common/utils.hpp"
  14. #include "account.hpp"
  15. #include "ipban.hpp" //ipban_check
  16. #include "login.hpp"
  17. #include "loginchrif.hpp"
  18. #include "loginlog.hpp"
  19. /**
  20. * Transmit auth result to client.
  21. * @param fd: client file desciptor link
  22. * @param result: result to transmit to client, see below
  23. * 1 : Server closed
  24. * 2 : Someone has already logged in with this id
  25. * 8 : already online
  26. * <result>.B (SC_NOTIFY_BAN)
  27. */
  28. static void logclif_sent_auth_result(int fd,char result){
  29. WFIFOHEAD(fd,3);
  30. WFIFOW(fd,0) = 0x81;
  31. WFIFOB(fd,2) = result;
  32. WFIFOSET(fd,3);
  33. }
  34. /**
  35. * Auth successful, inform client and create a temp auth_node.
  36. * @param sd: player session
  37. */
  38. static void logclif_auth_ok(struct login_session_data* sd) {
  39. int fd = sd->fd;
  40. uint32 ip = session[fd]->client_addr;
  41. uint8 server_num, n;
  42. uint32 subnet_char_ip;
  43. int i;
  44. #if PACKETVER < 20170315
  45. int cmd = 0x69; // AC_ACCEPT_LOGIN
  46. int header = 47;
  47. int size = 32;
  48. #else
  49. int cmd = 0xac4; // AC_ACCEPT_LOGIN3
  50. int header = 64;
  51. int size = 160;
  52. #endif
  53. if( runflag != LOGINSERVER_ST_RUNNING ){
  54. // players can only login while running
  55. logclif_sent_auth_result(fd,1); // server closed
  56. return;
  57. }
  58. if( login_config.group_id_to_connect >= 0 && sd->group_id != login_config.group_id_to_connect ) {
  59. 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);
  60. logclif_sent_auth_result(fd,1); // server closed
  61. return;
  62. } 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 ) {
  63. 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);
  64. logclif_sent_auth_result(fd,1); // server closed
  65. return;
  66. }
  67. server_num = 0;
  68. for( i = 0; i < ARRAYLENGTH(ch_server); ++i )
  69. if( session_isActive(ch_server[i].fd) )
  70. server_num++;
  71. if( server_num == 0 )
  72. {// if no char-server, don't send void list of servers, just disconnect the player with proper message
  73. ShowStatus("Connection refused: there is no char-server online (account: %s).\n", sd->userid);
  74. logclif_sent_auth_result(fd,1); // server closed
  75. return;
  76. }
  77. {
  78. struct online_login_data* data = login_get_online_user( sd->account_id );
  79. if( data )
  80. {// account is already marked as online!
  81. if( data->char_server > -1 )
  82. {// Request char servers to kick this account out. [Skotlex]
  83. uint8 buf[6];
  84. ShowNotice("User '%s' is already online - Rejected.\n", sd->userid);
  85. WBUFW(buf,0) = 0x2734;
  86. WBUFL(buf,2) = sd->account_id;
  87. logchrif_sendallwos(-1, buf, 6);
  88. if( data->waiting_disconnect == INVALID_TIMER )
  89. data->waiting_disconnect = add_timer(gettick()+AUTH_TIMEOUT, login_waiting_disconnect_timer, sd->account_id, 0);
  90. logclif_sent_auth_result(fd,8); // 08 = Server still recognizes your last login
  91. return;
  92. }
  93. else
  94. if( data->char_server == -1 )
  95. {// client has authed but did not access char-server yet
  96. // wipe previous session
  97. login_remove_auth_node(sd->account_id);
  98. login_remove_online_user(sd->account_id);
  99. data = NULL;
  100. }
  101. }
  102. }
  103. login_log(ip, sd->userid, 100, "login ok");
  104. ShowStatus("Connection of the account '%s' accepted.\n", sd->userid);
  105. WFIFOHEAD(fd,header+size*server_num);
  106. WFIFOW(fd,0) = cmd;
  107. WFIFOW(fd,2) = header+size*server_num;
  108. WFIFOL(fd,4) = sd->login_id1;
  109. WFIFOL(fd,8) = sd->account_id;
  110. WFIFOL(fd,12) = sd->login_id2;
  111. WFIFOL(fd,16) = 0; // in old version, that was for ip (not more used)
  112. //memcpy(WFIFOP(fd,20), sd->lastlogin, 24); // in old version, that was for name (not more used)
  113. memset(WFIFOP(fd,20), 0, 24);
  114. WFIFOW(fd,44) = 0; // unknown
  115. WFIFOB(fd,46) = sex_str2num(sd->sex);
  116. #if PACKETVER >= 20170315
  117. memset(WFIFOP(fd,47),0,17); // Unknown
  118. #endif
  119. for( i = 0, n = 0; i < ARRAYLENGTH(ch_server); ++i ) {
  120. if( !session_isValid(ch_server[i].fd) )
  121. continue;
  122. subnet_char_ip = lan_subnetcheck(ip); // Advanced subnet check [LuzZza]
  123. WFIFOL(fd,header+n*size) = htonl((subnet_char_ip) ? subnet_char_ip : ch_server[i].ip);
  124. WFIFOW(fd,header+n*size+4) = ntows(htons(ch_server[i].port)); // [!] LE byte order here [!]
  125. memcpy(WFIFOP(fd,header+n*size+6), ch_server[i].name, 20);
  126. WFIFOW(fd,header+n*size+26) = login_get_usercount( ch_server[i].users );
  127. WFIFOW(fd,header+n*size+28) = ch_server[i].type;
  128. WFIFOW(fd,header+n*size+30) = ch_server[i].new_;
  129. #if PACKETVER >= 20170315
  130. memset(WFIFOP(fd, header+n*size+32), 0, 128); // Unknown
  131. #endif
  132. n++;
  133. }
  134. WFIFOSET(fd,header+size*server_num);
  135. // create temporary auth entry
  136. login_add_auth_node( sd, ip );
  137. // mark client as 'online'
  138. struct online_login_data* data = login_add_online_user(-1, sd->account_id);
  139. // schedule deletion of this node
  140. data->waiting_disconnect = add_timer(gettick()+AUTH_TIMEOUT, login_waiting_disconnect_timer, sd->account_id, 0);
  141. }
  142. /**
  143. * Inform client that auth has failed.
  144. * @param sd: player session
  145. * @param result: nb (msg define in conf)
  146. 0 = Unregistered ID
  147. 1 = Incorrect Password
  148. 2 = This ID is expired
  149. 3 = Rejected from Server
  150. 4 = You have been blocked by the GM Team
  151. 5 = Your Game's EXE file is not the latest version
  152. 6 = You are prohibited to log in until %s
  153. 7 = Server is jammed due to over populated
  154. 8 = No more accounts may be connected from this company
  155. 9 = MSI_REFUSE_BAN_BY_DBA
  156. 10 = MSI_REFUSE_EMAIL_NOT_CONFIRMED
  157. 11 = MSI_REFUSE_BAN_BY_GM
  158. 12 = MSI_REFUSE_TEMP_BAN_FOR_DBWORK
  159. 13 = MSI_REFUSE_SELF_LOCK
  160. 14 = MSI_REFUSE_NOT_PERMITTED_GROUP
  161. 15 = MSI_REFUSE_NOT_PERMITTED_GROUP
  162. 99 = This ID has been totally erased
  163. 100 = Login information remains at %s
  164. 101 = Account has been locked for a hacking investigation. Please contact the GM Team for more information
  165. 102 = This account has been temporarily prohibited from login due to a bug-related investigation
  166. 103 = This character is being deleted. Login is temporarily unavailable for the time being
  167. 104 = This character is being deleted. Login is temporarily unavailable for the time being
  168. default = Unknown Error.
  169. */
  170. static void logclif_auth_failed(struct login_session_data* sd, int result) {
  171. int fd = sd->fd;
  172. uint32 ip = session[fd]->client_addr;
  173. if (login_config.log_login)
  174. {
  175. if(result >= 0 && result <= 15)
  176. login_log(ip, sd->userid, result, msg_txt(result));
  177. else if(result >= 99 && result <= 104)
  178. login_log(ip, sd->userid, result, msg_txt(result-83)); //-83 offset
  179. else
  180. login_log(ip, sd->userid, result, msg_txt(22)); //unknow error
  181. }
  182. if( (result == 0 || result == 1) && login_config.dynamic_pass_failure_ban )
  183. ipban_log(ip); // log failed password attempt
  184. #if PACKETVER >= 20120000 /* not sure when this started */
  185. WFIFOHEAD(fd,26);
  186. WFIFOW(fd,0) = 0x83e;
  187. WFIFOL(fd,2) = result;
  188. if( result != 6 )
  189. memset(WFIFOP(fd,6), '\0', 20);
  190. else { // 6 = You are prohibited to log in until %s
  191. struct mmo_account acc;
  192. AccountDB* accounts = login_get_accounts_db();
  193. time_t unban_time = ( accounts->load_str(accounts, &acc, sd->userid) ) ? acc.unban_time : 0;
  194. timestamp2string(WFIFOCP(fd,6), 20, unban_time, login_config.date_format);
  195. }
  196. WFIFOSET(fd,26);
  197. #else
  198. WFIFOHEAD(fd,23);
  199. WFIFOW(fd,0) = 0x6a;
  200. WFIFOB(fd,2) = (uint8)result;
  201. if( result != 6 )
  202. memset(WFIFOP(fd,3), '\0', 20);
  203. else { // 6 = You are prohibited to log in until %s
  204. struct mmo_account acc;
  205. AccountDB* accounts = login_get_accounts_db();
  206. time_t unban_time = ( accounts->load_str(accounts, &acc, sd->userid) ) ? acc.unban_time : 0;
  207. timestamp2string(WFIFOCP(fd,3), 20, unban_time, login_config.date_format);
  208. }
  209. WFIFOSET(fd,23);
  210. #endif
  211. }
  212. /**
  213. * Received a keepalive packet to maintain connection.
  214. * 0x200 <account.userid>.24B.
  215. * @param fd: fd to parse from (client fd)
  216. * @return 0 not enough info transmitted, 1 success
  217. */
  218. static int logclif_parse_keepalive(int fd){
  219. if (RFIFOREST(fd) < 26)
  220. return 0;
  221. RFIFOSKIP(fd,26);
  222. return 1;
  223. }
  224. /**
  225. * Received a keepalive packet to maintain connection.
  226. * S 0204 <md5 hash>.16B (kRO 2004-05-31aSakexe langtype 0 and 6)
  227. * @param fd: fd to parse from (client fd)
  228. * @return 0 not enough info transmitted, 1 success
  229. */
  230. static int logclif_parse_updclhash(int fd, struct login_session_data *sd){
  231. if (RFIFOREST(fd) < 18)
  232. return 0;
  233. sd->has_client_hash = 1;
  234. memcpy(sd->client_hash, RFIFOP(fd, 2), 16);
  235. RFIFOSKIP(fd,18);
  236. return 1;
  237. }
  238. /**
  239. * Received a connection request.
  240. * @param fd: file descriptor to parse from (client)
  241. * @param sd: client session
  242. * @param command: packet type sent
  243. * @param ip: ipv4 address (client)
  244. * S 0064 <version>.L <username>.24B <password>.24B <clienttype>.B
  245. * S 0277 <version>.L <username>.24B <password>.24B <clienttype>.B <ip address>.16B <adapter address>.13B
  246. * S 02b0 <version>.L <username>.24B <password>.24B <clienttype>.B <ip address>.16B <adapter address>.13B <g_isGravityID>.B
  247. * S 01dd <version>.L <username>.24B <password hash>.16B <clienttype>.B
  248. * S 01fa <version>.L <username>.24B <password hash>.16B <clienttype>.B <?>.B(index of the connection in the clientinfo file (+10 if the command-line contains "pc"))
  249. * S 027c <version>.L <username>.24B <password hash>.16B <clienttype>.B <?>.13B(junk)
  250. * S 0825 <packetsize>.W <version>.L <clienttype>.B <userid>.24B <password>.27B <mac>.17B <ip>.15B <token>.(packetsize - 0x5C)B
  251. * @param fd: fd to parse from (client fd)
  252. * @return 0 failure, 1 success
  253. */
  254. static int logclif_parse_reqauth(int fd, struct login_session_data *sd, int command, char* ip){
  255. size_t packet_len = RFIFOREST(fd);
  256. if( (command == 0x0064 && packet_len < 55)
  257. || (command == 0x0277 && packet_len < 84)
  258. || (command == 0x02b0 && packet_len < 85)
  259. || (command == 0x01dd && packet_len < 47)
  260. || (command == 0x01fa && packet_len < 48)
  261. || (command == 0x027c && packet_len < 60)
  262. || (command == 0x0825 && (packet_len < 4 || packet_len < RFIFOW(fd, 2))) )
  263. return 0;
  264. else {
  265. int result;
  266. char username[NAME_LENGTH];
  267. char password[PASSWD_LENGTH];
  268. unsigned char passhash[16];
  269. uint8 clienttype;
  270. bool israwpass = (command==0x0064 || command==0x0277 || command==0x02b0 || command == 0x0825);
  271. // Shinryo: For the time being, just use token as password.
  272. if(command == 0x0825) {
  273. char *accname = RFIFOCP(fd, 9);
  274. char *token = RFIFOCP(fd, 0x5C);
  275. size_t uAccLen = strlen(accname);
  276. size_t uTokenLen = RFIFOREST(fd) - 0x5C;
  277. if(uAccLen > NAME_LENGTH - 1 || uAccLen == 0 || uTokenLen > NAME_LENGTH - 1 || uTokenLen == 0)
  278. {
  279. logclif_auth_failed(sd, 3);
  280. return 0;
  281. }
  282. safestrncpy(username, accname, uAccLen + 1);
  283. safestrncpy(password, token, uTokenLen + 1);
  284. clienttype = RFIFOB(fd, 8);
  285. }
  286. else
  287. {
  288. safestrncpy(username, RFIFOCP(fd,6), NAME_LENGTH);
  289. if( israwpass )
  290. {
  291. safestrncpy(password, RFIFOCP(fd,30), PASSWD_LENGTH);
  292. clienttype = RFIFOB(fd,54);
  293. }
  294. else
  295. {
  296. memcpy(passhash, RFIFOP(fd,30), 16);
  297. clienttype = RFIFOB(fd,46);
  298. }
  299. }
  300. RFIFOSKIP(fd,RFIFOREST(fd)); // assume no other packet was sent
  301. sd->clienttype = clienttype;
  302. safestrncpy(sd->userid, username, NAME_LENGTH);
  303. if( israwpass )
  304. {
  305. ShowStatus("Request for connection of %s (ip: %s)\n", sd->userid, ip);
  306. safestrncpy(sd->passwd, password, PASSWD_LENGTH);
  307. if( login_config.use_md5_passwds )
  308. MD5_String(sd->passwd, sd->passwd);
  309. sd->passwdenc = 0;
  310. }
  311. else
  312. {
  313. ShowStatus("Request for connection (passwdenc mode) of %s (ip: %s)\n", sd->userid, ip);
  314. bin2hex(sd->passwd, passhash, 16); // raw binary data here!
  315. sd->passwdenc = PASSWORDENC;
  316. }
  317. if( sd->passwdenc != 0 && login_config.use_md5_passwds )
  318. {
  319. logclif_auth_failed(sd, 3); // send "rejected from server"
  320. return 0;
  321. }
  322. result = login_mmo_auth(sd, false);
  323. if( result == -1 )
  324. logclif_auth_ok(sd);
  325. else
  326. logclif_auth_failed(sd, result);
  327. }
  328. return 1;
  329. }
  330. /**
  331. * Client requests an md5key for his session: keys will be generated and sent back.
  332. * @param fd: file descriptor to parse from (client)
  333. * @param sd: client session
  334. * @return 1 success
  335. */
  336. static int logclif_parse_reqkey(int fd, struct login_session_data *sd){
  337. RFIFOSKIP(fd,2);
  338. {
  339. memset(sd->md5key, '\0', sizeof(sd->md5key));
  340. sd->md5keylen = (uint16)(12 + rnd() % 4);
  341. MD5_Salt(sd->md5keylen, sd->md5key);
  342. WFIFOHEAD(fd,4 + sd->md5keylen);
  343. WFIFOW(fd,0) = 0x01dc;
  344. WFIFOW(fd,2) = 4 + sd->md5keylen;
  345. memcpy(WFIFOP(fd,4), sd->md5key, sd->md5keylen);
  346. WFIFOSET(fd,WFIFOW(fd,2));
  347. }
  348. return 1;
  349. }
  350. /**
  351. * Char-server request to connect to the login-server.
  352. * This is needed to exchange packets.
  353. * @param fd: file descriptor to parse from (client)
  354. * @param sd: client session
  355. * @param ip: ipv4 address (client)
  356. * @return 0 packet received too shirt, 1 success
  357. */
  358. static int logclif_parse_reqcharconnec(int fd, struct login_session_data *sd, char* ip){
  359. if (RFIFOREST(fd) < 86)
  360. return 0;
  361. else {
  362. int result;
  363. char server_name[20];
  364. char message[256];
  365. uint32 server_ip;
  366. uint16 server_port;
  367. uint16 type;
  368. uint16 new_;
  369. safestrncpy(sd->userid, RFIFOCP(fd,2), NAME_LENGTH);
  370. safestrncpy(sd->passwd, RFIFOCP(fd,26), NAME_LENGTH);
  371. if( login_config.use_md5_passwds )
  372. MD5_String(sd->passwd, sd->passwd);
  373. sd->passwdenc = 0;
  374. server_ip = ntohl(RFIFOL(fd,54));
  375. server_port = ntohs(RFIFOW(fd,58));
  376. safestrncpy(server_name, RFIFOCP(fd,60), 20);
  377. type = RFIFOW(fd,82);
  378. new_ = RFIFOW(fd,84);
  379. RFIFOSKIP(fd,86);
  380. ShowInfo("Connection request of the char-server '%s' @ %u.%u.%u.%u:%u (account: '%s', ip: '%s')\n", server_name, CONVIP(server_ip), server_port, sd->userid, ip);
  381. sprintf(message, "charserver - %s@%u.%u.%u.%u:%u", server_name, CONVIP(server_ip), server_port);
  382. login_log(session[fd]->client_addr, sd->userid, 100, message);
  383. result = login_mmo_auth(sd, true);
  384. if( runflag == LOGINSERVER_ST_RUNNING &&
  385. result == -1 &&
  386. sd->sex == 'S' &&
  387. sd->account_id < ARRAYLENGTH(ch_server) &&
  388. !session_isValid(ch_server[sd->account_id].fd) )
  389. {
  390. ShowStatus("Connection of the char-server '%s' accepted.\n", server_name);
  391. safestrncpy(ch_server[sd->account_id].name, server_name, sizeof(ch_server[sd->account_id].name));
  392. ch_server[sd->account_id].fd = fd;
  393. ch_server[sd->account_id].ip = server_ip;
  394. ch_server[sd->account_id].port = server_port;
  395. ch_server[sd->account_id].users = 0;
  396. ch_server[sd->account_id].type = type;
  397. ch_server[sd->account_id].new_ = new_;
  398. session[fd]->func_parse = logchrif_parse;
  399. session[fd]->flag.server = 1;
  400. realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
  401. // send connection success
  402. WFIFOHEAD(fd,3);
  403. WFIFOW(fd,0) = 0x2711;
  404. WFIFOB(fd,2) = 0;
  405. WFIFOSET(fd,3);
  406. }
  407. else
  408. {
  409. ShowNotice("Connection of the char-server '%s' REFUSED.\n", server_name);
  410. WFIFOHEAD(fd,3);
  411. WFIFOW(fd,0) = 0x2711;
  412. WFIFOB(fd,2) = 3;
  413. WFIFOSET(fd,3);
  414. }
  415. }
  416. return 1;
  417. }
  418. int logclif_parse_otp_login( int fd, struct login_session_data* sd ){
  419. RFIFOSKIP( fd, 68 );
  420. WFIFOHEAD( fd, 34 );
  421. WFIFOW( fd, 0 ) = 0xae3;
  422. WFIFOW( fd, 2 ) = 34;
  423. WFIFOL( fd, 4 ) = 0; // normal login
  424. safestrncpy( WFIFOCP( fd, 8 ), "S1000", 6 );
  425. safestrncpy( WFIFOCP( fd, 28 ), "token", 6 );
  426. WFIFOSET( fd, 34 );
  427. return 1;
  428. }
  429. /**
  430. * Entry point from client to log-server.
  431. * Function that checks incoming command, then splits it to the correct handler.
  432. * @param fd: file descriptor to parse, (link to client)
  433. * @return 0=invalid session,marked for disconnection,unknow packet, banned..; 1=success
  434. */
  435. int logclif_parse(int fd) {
  436. struct login_session_data* sd = (struct login_session_data*)session[fd]->session_data;
  437. char ip[16];
  438. uint32 ipl = session[fd]->client_addr;
  439. ip2str(ipl, ip);
  440. if( session[fd]->flag.eof )
  441. {
  442. ShowInfo("Closed connection from '" CL_WHITE "%s" CL_RESET "'.\n", ip);
  443. do_close(fd);
  444. return 0;
  445. }
  446. if( sd == NULL )
  447. {
  448. // Perform ip-ban check
  449. if( login_config.ipban && ipban_check(ipl) )
  450. {
  451. ShowStatus("Connection refused: IP isn't authorised (deny/allow, ip: %s).\n", ip);
  452. login_log(ipl, "unknown", -3, "ip banned");
  453. WFIFOHEAD(fd,23);
  454. WFIFOW(fd,0) = 0x6a;
  455. WFIFOB(fd,2) = 3; // 3 = Rejected from Server
  456. WFIFOSET(fd,23);
  457. set_eof(fd);
  458. return 0;
  459. }
  460. // create a session for this new connection
  461. CREATE(session[fd]->session_data, struct login_session_data, 1);
  462. sd = (struct login_session_data*)session[fd]->session_data;
  463. sd->fd = fd;
  464. }
  465. while( RFIFOREST(fd) >= 2 )
  466. {
  467. uint16 command = RFIFOW(fd,0);
  468. int next=1;
  469. switch( command )
  470. {
  471. // New alive packet: used to verify if client is always alive.
  472. case 0x0200: next = logclif_parse_keepalive(fd); break;
  473. // client md5 hash (binary)
  474. case 0x0204: next = logclif_parse_updclhash(fd,sd); break;
  475. // request client login (raw password)
  476. case 0x0064: // S 0064 <version>.L <username>.24B <password>.24B <clienttype>.B
  477. case 0x0277: // S 0277 <version>.L <username>.24B <password>.24B <clienttype>.B <ip address>.16B <adapter address>.13B
  478. case 0x02b0: // S 02b0 <version>.L <username>.24B <password>.24B <clienttype>.B <ip address>.16B <adapter address>.13B <g_isGravityID>.B
  479. // request client login (md5-hashed password)
  480. case 0x01dd: // S 01dd <version>.L <username>.24B <password hash>.16B <clienttype>.B
  481. case 0x01fa: // S 01fa <version>.L <username>.24B <password hash>.16B <clienttype>.B <?>.B(index of the connection in the clientinfo file (+10 if the command-line contains "pc"))
  482. case 0x027c: // S 027c <version>.L <username>.24B <password hash>.16B <clienttype>.B <?>.13B(junk)
  483. case 0x0825: // S 0825 <packetsize>.W <version>.L <clienttype>.B <userid>.24B <password>.27B <mac>.17B <ip>.15B <token>.(packetsize - 0x5C)B
  484. next = logclif_parse_reqauth(fd, sd, command, ip);
  485. break;
  486. // Sending request of the coding key
  487. case 0x01db: next = logclif_parse_reqkey(fd, sd); break;
  488. // OTP token login
  489. case 0x0acf:
  490. next = logclif_parse_otp_login( fd, sd );
  491. break;
  492. // Connection request of a char-server
  493. case 0x2710: logclif_parse_reqcharconnec(fd,sd, ip); return 0; // processing will continue elsewhere
  494. default:
  495. ShowNotice("Abnormal end of connection (ip: %s): Unknown packet 0x%x\n", ip, command);
  496. set_eof(fd);
  497. return 0;
  498. }
  499. if(next==0) return 0; // avoid processing of followup packets (prev was probably incomplete)
  500. }
  501. return 0;
  502. }
  503. /// Constructor destructor
  504. /**
  505. * Initialize the module.
  506. * Launched at login-serv start, create db or other long scope variable here.
  507. */
  508. void do_init_loginclif(void){
  509. return;
  510. }
  511. /**
  512. * loginclif destructor
  513. * dealloc..., function called at exit of the login-serv
  514. */
  515. void do_final_loginclif(void){
  516. return;
  517. }