diff options
author | Haru <haru@dotalux.com> | 2014-11-16 06:35:51 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2014-11-16 07:16:23 +0100 |
commit | 02fcaed6bd32b0ffbc4f03b8f9de6f0720e6253f (patch) | |
tree | 3161fd5786bb563c32059068eb3b4876d2ae11ca /src/login | |
parent | 31bff051ee3c353fb7ee5e544d68feeaefd4941f (diff) | |
download | hercules-02fcaed6bd32b0ffbc4f03b8f9de6f0720e6253f.tar.gz hercules-02fcaed6bd32b0ffbc4f03b8f9de6f0720e6253f.tar.bz2 hercules-02fcaed6bd32b0ffbc4f03b8f9de6f0720e6253f.tar.xz hercules-02fcaed6bd32b0ffbc4f03b8f9de6f0720e6253f.zip |
Whitespace cleanup (no code changes)
This includes, and is not limited to: mixed or wrong indentation, excess
whitespace (horizontal and vertical), misalignment, trailing spaces.
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/login')
-rw-r--r-- | src/login/account_sql.c | 79 | ||||
-rw-r--r-- | src/login/ipban_sql.c | 2 | ||||
-rw-r--r-- | src/login/login.c | 56 | ||||
-rw-r--r-- | src/login/login.h | 58 |
4 files changed, 95 insertions, 100 deletions
diff --git a/src/login/account_sql.c b/src/login/account_sql.c index 5f9357c81..adbb7914d 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -222,7 +222,7 @@ static bool account_db_sql_get_property(AccountDB* self, const char* key, char* if( strcmpi(key, "db_username") == 0 ) safesnprintf(buf, buflen, "%s", db->global_db_username); else - if( strcmpi(key, "db_password") == 0 ) + if( strcmpi(key, "db_password") == 0 ) safesnprintf(buf, buflen, "%s", db->global_db_password); else if( strcmpi(key, "db_database") == 0 ) @@ -248,7 +248,7 @@ static bool account_db_sql_get_property(AccountDB* self, const char* key, char* if( strcmpi(key, "db_username") == 0 ) safesnprintf(buf, buflen, "%s", db->db_username); else - if( strcmpi(key, "db_password") == 0 ) + if( strcmpi(key, "db_password") == 0 ) safesnprintf(buf, buflen, "%s", db->db_password); else if( strcmpi(key, "db_database") == 0 ) @@ -573,7 +573,7 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int acc SQL->GetData(sql_handle, 13, &data, NULL); acc->char_slots = (uint8)atoi(data); SQL->GetData(sql_handle, 14, &data, NULL); safestrncpy(acc->pincode, data, sizeof(acc->pincode)); SQL->GetData(sql_handle, 15, &data, NULL); acc->pincode_change = (unsigned int)atol(data); - + SQL->FreeResult(sql_handle); return true; @@ -665,19 +665,19 @@ void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) { Sql* sql_handle = ((AccountDB_SQL*)self)->accounts; AccountDB_SQL* db = (AccountDB_SQL*)self; int count = RFIFOW(fd, 12); - + if( count ) { int cursor = 14, i; char key[32], sval[254]; unsigned int index; - + for(i = 0; i < count; i++) { safestrncpy(key, (char*)RFIFOP(fd, cursor + 1), RFIFOB(fd, cursor)); cursor += RFIFOB(fd, cursor) + 1; - + index = RFIFOL(fd, cursor); cursor += 4; - + switch (RFIFOB(fd, cursor++)) { /* int */ case 0: @@ -700,24 +700,21 @@ void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) { if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", db->global_acc_reg_str_db, account_id, key, index) ) Sql_ShowDebug(sql_handle); break; - default: ShowError("mmo_save_accreg2: DA HOO UNKNOWN TYPE %d\n",RFIFOB(fd, cursor - 1)); return; } - } - } - } + void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) { Sql* sql_handle = ((AccountDB_SQL*)self)->accounts; AccountDB_SQL* db = (AccountDB_SQL*)self; char* data; int plen = 0; size_t len; - + if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", db->global_acc_reg_str_db, account_id) ) Sql_ShowDebug(sql_handle); @@ -730,7 +727,7 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) { WFIFOB(fd, 13) = 1;/* is string type */ WFIFOW(fd, 14) = 0;/* count */ plen = 16; - + /** * Vessel! * @@ -738,36 +735,35 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) { * { keyLength(B), key(<keyLength>), index(L), valLength(B), val(<valLength>) } **/ while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) { - SQL->GetData(sql_handle, 0, &data, NULL); len = strlen(data)+1; - + WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 32 */ plen += 1; - + safestrncpy((char*)WFIFOP(fd,plen), data, len); plen += len; - + SQL->GetData(sql_handle, 1, &data, NULL); - + WFIFOL(fd, plen) = (unsigned int)atol(data); plen += 4; - + SQL->GetData(sql_handle, 2, &data, NULL); len = strlen(data)+1; - + WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 254 */ plen += 1; - + safestrncpy((char*)WFIFOP(fd,plen), data, len); plen += len; - + WFIFOW(fd, 14) += 1; - + if( plen > 60000 ) { WFIFOW(fd, 2) = plen; WFIFOSET(fd, plen); - + /* prepare follow up */ WFIFOHEAD(fd, 60000 + 300); WFIFOW(fd, 0) = 0x3804; @@ -780,16 +776,16 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) { plen = 16; } } - + /* mark & go. */ WFIFOW(fd, 2) = plen; WFIFOSET(fd, plen); - + SQL->FreeResult(sql_handle); - + if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", db->global_acc_reg_num_db, account_id) ) Sql_ShowDebug(sql_handle); - + WFIFOHEAD(fd, 60000 + 300); WFIFOW(fd, 0) = 0x3804; /* 0x2 = length, set prior to being sent */ @@ -799,7 +795,7 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) { WFIFOB(fd, 13) = 0;/* is int type */ WFIFOW(fd, 14) = 0;/* count */ plen = 16; - + /** * Vessel! * @@ -807,32 +803,31 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) { * { keyLength(B), key(<keyLength>), index(L), value(L) } **/ while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) { - SQL->GetData(sql_handle, 0, &data, NULL); len = strlen(data)+1; - + WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 32 */ plen += 1; - + safestrncpy((char*)WFIFOP(fd,plen), data, len); plen += len; - + SQL->GetData(sql_handle, 1, &data, NULL); - + WFIFOL(fd, plen) = (unsigned int)atol(data); plen += 4; - + SQL->GetData(sql_handle, 2, &data, NULL); - + WFIFOL(fd, plen) = atoi(data); plen += 4; - + WFIFOW(fd, 14) += 1; - + if( plen > 60000 ) { WFIFOW(fd, 2) = plen; WFIFOSET(fd, plen); - + /* prepare follow up */ WFIFOHEAD(fd, 60000 + 300); WFIFOW(fd, 0) = 0x3804; @@ -842,15 +837,15 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) { WFIFOB(fd, 12) = 0;/* var type (only set when all vars have been sent, regardless of type) */ WFIFOB(fd, 13) = 0;/* is int type */ WFIFOW(fd, 14) = 0;/* count */ - + plen = 16; } } - + /* mark as complete & go. */ WFIFOB(fd, 12) = 1; WFIFOW(fd, 2) = plen; WFIFOSET(fd, plen); - + SQL->FreeResult(sql_handle); } diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c index 82512b0f0..bfc90ad11 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban_sql.c @@ -105,7 +105,7 @@ void ipban_final(void) if( login_config.ipban_cleanup_interval > 0 ) // release data timer->delete(cleanup_timer_id, ipban_cleanup); - + ipban_cleanup(0,0,0,0); // always clean up on login-server stop // close connections diff --git a/src/login/login.c b/src/login/login.c index 2a322ba40..c006d9c45 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -223,7 +223,7 @@ bool login_check_password(const char* md5key, int passwdenc, const char* passwd, { // password mode set to 1 -> md5(md5key, refpass) enable with <passwordencrypt></passwordencrypt> // password mode set to 2 -> md5(refpass, md5key) enable with <passwordencrypt2></passwordencrypt2> - + return ((passwdenc&0x01) && login->check_encrypted(md5key, refpass, passwd)) || ((passwdenc&0x02) && login->check_encrypted(refpass, md5key, passwd)); } @@ -767,7 +767,7 @@ void login_fromchar_accinfo(int fd, int account_id, int u_fd, int u_aid, int u_g safestrncpy((char*)WFIFOP(fd,119), acc->lastlogin, 24); WFIFOL(fd,143) = acc->logincount; WFIFOL(fd,147) = acc->state; - if (u_group >= acc->group_id) + if (u_group >= acc->group_id) safestrncpy((char*)WFIFOP(fd,151), acc->pincode, 5); else memset(WFIFOP(fd,151), '\0', 5); @@ -840,7 +840,7 @@ int login_parse_fromchar(int fd) if( j == 2 ) return 0; } } - + switch( command ) { case 0x2712: // request from char-server to authenticate an account @@ -880,7 +880,7 @@ int login_parse_fromchar(int fd) break; // Map server send information to change an email of an account via char-server - case 0x2722: // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B + case 0x2722: // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B if (RFIFOREST(fd) < 86) return 0; { @@ -912,7 +912,7 @@ int login_parse_fromchar(int fd) } break; - case 0x2728: // We receive account_reg2 from a char-server, and we send them to other map-servers. + case 0x2728: // We receive account_reg2 from a char-server, and we send them to other map-servers. if( RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2) ) return 0; { @@ -920,7 +920,7 @@ int login_parse_fromchar(int fd) } break; - case 0x272a: // Receiving of map-server via char-server an unban request + case 0x272a: // Receiving of map-server via char-server an unban request if( RFIFOREST(fd) < 6 ) return 0; { @@ -940,7 +940,7 @@ int login_parse_fromchar(int fd) login->fromchar_parse_account_offline(fd); break; - case 0x272d: // Receive list of all online accounts. [Skotlex] + case 0x272d: // Receive list of all online accounts. [Skotlex] if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) return 0; { @@ -974,7 +974,7 @@ int login_parse_fromchar(int fd) login->fromchar_parse_change_pincode(fd); } break; - + case 0x2739: // PIN Code was entered wrong too often if( RFIFOREST(fd) < 6 ) return 0; @@ -983,7 +983,7 @@ int login_parse_fromchar(int fd) return 0; } break; - + case 0x2740: // Accinfo request forwarded by charserver on mapserver's account if( RFIFOREST(fd) < 22 ) return 0; @@ -1045,7 +1045,7 @@ int login_mmo_auth_new(const char* userid, const char* pass, const char sex, con safestrncpy(acc.pincode, "\0", sizeof(acc.pincode)); acc.pincode_change = 0; acc.char_slots = 0; - + if( !accounts->create(accounts, &acc) ) return 0; @@ -1117,7 +1117,7 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) { ShowNotice("Empty userid (received pass: '%s', ip: %s)\n", sd->passwd, ip); return 0; // 0 = Unregistered ID } - + if( !accounts->load_str(accounts, &acc, sd->userid) ) { ShowNotice("Unknown account (account: %s, received pass: %s, ip: %s)\n", sd->userid, sd->passwd, ip); return 0; // 0 = Unregistered ID @@ -1139,7 +1139,7 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) { ShowNotice("Connection refused (account: %s, pass: %s, state: %d, ip: %s)\n", sd->userid, sd->passwd, acc.state, ip); return acc.state - 1; } - + if( login_config.client_hash_check && !isServer ) { struct client_hash_node *node = NULL; bool match = false; @@ -1302,12 +1302,12 @@ void login_auth_ok(struct login_session_data* sd) 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); WFIFOW(fd,47+n*32+26) = server[i].users; - + if( server[i].type == CST_PAYING && sd->expiration_time > time(NULL) ) WFIFOW(fd,47+n*32+28) = CST_NORMAL; else WFIFOW(fd,47+n*32+28) = server[i].type; - + WFIFOW(fd,47+n*32+30) = server[i].new_; n++; } @@ -1634,10 +1634,10 @@ int login_parse_login(int fd) if( result == 2 ) return 0; } } - + switch( command ) { - case 0x0200: // New alive packet: structure: 0x200 <account.userid>.24B. used to verify if client is always alive. + case 0x0200: // New alive packet: structure: 0x200 <account.userid>.24B. used to verify if client is always alive. if (RFIFOREST(fd) < 26) return 0; login->parse_ping(fd, sd); @@ -1678,14 +1678,14 @@ int login_parse_login(int fd) } break; - case 0x01db: // Sending request of the coding key + case 0x01db: // Sending request of the coding key RFIFOSKIP(fd,2); { login->parse_request_coding_key(fd, sd); } break; - case 0x2710: // Connection request of a char-server + case 0x2710: // Connection request of a char-server if (RFIFOREST(fd) < 86) return 0; { @@ -1863,9 +1863,9 @@ int do_final(void) { struct client_hash_node *hn = login_config.client_hash_nodes; ShowStatus("Terminating...\n"); - + HPM->event(HPET_FINAL); - + while (hn) { struct client_hash_node *tmp = hn; hn = hn->next; @@ -1887,7 +1887,7 @@ int do_final(void) { accounts = NULL; // destroyed in account_engine 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); @@ -1984,7 +1984,7 @@ int do_init(int argc, char** argv) login_config_read((argc > 1) ? argv[1] : LOGIN_CONF_NAME); login->lan_config_read((argc > 2) ? argv[2] : LAN_CONF_NAME); - + for( i = 0; i < ARRAYLENGTH(server); ++i ) chrif_server_init(i); @@ -1994,7 +1994,7 @@ int do_init(int argc, char** argv) // initialize static and dynamic ipban system ipban_init(); - + // Online user database init login->online_db = idb_alloc(DB_OPT_RELEASE_DATA); timer->add_func_list(login->waiting_disconnect_timer, "login->waiting_disconnect_timer"); @@ -2022,23 +2022,23 @@ 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 ) { ShowFatalError("Failed to bind to port '"CL_WHITE"%d"CL_RESET"'\n",login_config.login_port); exit(EXIT_FAILURE); } - + if( runflag != CORE_ST_STOP ) { shutdown_callback = do_shutdown_login; runflag = LOGINSERVER_ST_RUNNING; } - + ShowStatus("The login-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %u).\n\n", login_config.login_port); login_log(0, "login server", 100, "login server started"); - + HPM->event(HPET_READY); - + return 0; } diff --git a/src/login/login.h b/src/login/login.h index f86abaf4b..4c9bbd8b7 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -46,7 +46,7 @@ struct login_session_data { int has_client_hash; int fd; - + time_t expiration_time; }; @@ -69,34 +69,34 @@ struct client_hash_node { struct Login_Config { - uint32 login_ip; // the address to bind to - uint16 login_port; // the port to bind to - unsigned int ipban_cleanup_interval; // interval (in seconds) to clean up expired IP bans - unsigned int ip_sync_interval; // interval (in minutes) to execute a DNS/IP update (for dynamic IPs) - bool log_login; // whether to log login server actions or not - char date_format[32]; // date format used in messages - bool new_account_flag,new_acc_length_limit; // auto-registration via _M/_F ? / if yes minimum length is 4? - int start_limited_time; // new account expiration time (-1: unlimited) - bool use_md5_passwds; // work with password hashes instead of plaintext passwords? - int group_id_to_connect; // required group id to connect - 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 ? - unsigned int dynamic_pass_failure_ban_interval; // how far to scan the loginlog for password failures - unsigned int dynamic_pass_failure_ban_limit; // number of failures needed to trigger the ipban - unsigned int dynamic_pass_failure_ban_duration; // duration of the ipban - bool use_dnsbl; // dns blacklist blocking ? - char dnsbl_servs[1024]; // comma-separated list of dnsbl servers - - 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] + uint32 login_ip; ///< the address to bind to + uint16 login_port; ///< the port to bind to + unsigned int ipban_cleanup_interval; ///< interval (in seconds) to clean up expired IP bans + unsigned int ip_sync_interval; ///< interval (in minutes) to execute a DNS/IP update (for dynamic IPs) + bool log_login; ///< whether to log login server actions or not + char date_format[32]; ///< date format used in messages + bool new_account_flag,new_acc_length_limit; ///< auto-registration via _M/_F ? / if yes minimum length is 4? + int start_limited_time; ///< new account expiration time (-1: unlimited) + bool use_md5_passwds; ///< work with password hashes instead of plaintext passwords? + int group_id_to_connect; ///< required group id to connect + 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 ? + unsigned int dynamic_pass_failure_ban_interval; ///< how far to scan the loginlog for password failures + unsigned int dynamic_pass_failure_ban_limit; ///< number of failures needed to trigger the ipban + unsigned int dynamic_pass_failure_ban_duration; ///< duration of the ipban + bool use_dnsbl; ///< dns blacklist blocking ? + char dnsbl_servs[1024]; ///< comma-separated list of dnsbl servers + + 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; |