summaryrefslogtreecommitdiff
path: root/src/login/ipban_sql.c
diff options
context:
space:
mode:
authorParadox924X <Paradox924X@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-11-22 10:19:44 +0000
committerParadox924X <Paradox924X@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-11-22 10:19:44 +0000
commit4283f7b042db854c4371107918bb64f94498953e (patch)
treeda064ff323d753455596dddb14587893882fbe03 /src/login/ipban_sql.c
parentda17b9b18b29c9dda20ddcd52cc9d6f1c79ae72f (diff)
downloadhercules-4283f7b042db854c4371107918bb64f94498953e.tar.gz
hercules-4283f7b042db854c4371107918bb64f94498953e.tar.bz2
hercules-4283f7b042db854c4371107918bb64f94498953e.tar.xz
hercules-4283f7b042db854c4371107918bb64f94498953e.zip
Added 'ipban_cleanup_interval' option which determines how often expired IP bans are cleaned from the database. (bugreport:3734)
Modified ipban_check() to only include ipbans that haven't already expired. (bugreport:3734) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14161 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/login/ipban_sql.c')
-rw-r--r--src/login/ipban_sql.c18
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);