diff options
Diffstat (limited to 'src/login/ipban_sql.c')
-rw-r--r-- | src/login/ipban_sql.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c index db383b908..ef463905e 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban_sql.c @@ -83,9 +83,12 @@ void ipban_init(void) if( codepage[0] != '\0' && SQL_ERROR == Sql_SetEncoding(sql_handle, codepage) ) Sql_ShowDebug(sql_handle); - // set up periodic cleanup of connection history and active bans - add_timer_func_list(ipban_cleanup, "ipban_cleanup"); - cleanup_timer_id = add_timer_interval(gettick()+10, ipban_cleanup, 0, 0, 60*1000); + if( login_config.ipban_cleanup_interval > 0 ) + { // set up periodic cleanup of connection history and active bans + add_timer_func_list(ipban_cleanup, "ipban_cleanup"); + cleanup_timer_id = add_timer_interval(gettick()+10, ipban_cleanup, 0, 0, login_config.ipban_cleanup_interval*1000); + } else // make sure it gets cleaned up on login-server start regardless of interval-based cleanups + ipban_cleanup(0,0,0,0); } // finalize @@ -94,8 +97,11 @@ void ipban_final(void) if( !login_config.ipban ) return;// ipban disabled - // release data - delete_timer(cleanup_timer_id, ipban_cleanup); + if( login_config.ipban_cleanup_interval > 0 ) + // release data + delete_timer(cleanup_timer_id, ipban_cleanup); + + ipban_cleanup(0,0,0,0); // always clean up on login-server stop // close connections Sql_Free(sql_handle); @@ -201,7 +207,7 @@ bool ipban_check(uint32 ip) if( !login_config.ipban ) return false;// ipban disabled - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT count(*) FROM `%s` WHERE `list` = '%u.*.*.*' OR `list` = '%u.%u.*.*' OR `list` = '%u.%u.%u.*' OR `list` = '%u.%u.%u.%u'", + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT count(*) FROM `%s` WHERE `rtime` > NOW() AND (`list` = '%u.*.*.*' OR `list` = '%u.%u.*.*' OR `list` = '%u.%u.%u.*' OR `list` = '%u.%u.%u.%u')", ipban_table, p[3], p[3], p[2], p[3], p[2], p[1], p[3], p[2], p[1], p[0]) ) { Sql_ShowDebug(sql_handle); |