summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/login/ipban_sql.c18
-rw-r--r--src/login/login.c3
2 files changed, 15 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);
diff --git a/src/login/login.c b/src/login/login.c
index d31408fac..7cb00c888 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -1474,6 +1474,7 @@ void login_set_defaults()
{
login_config.login_ip = INADDR_ANY;
login_config.login_port = 6900;
+ login_config.ipban_cleanup_interval = 60;
login_config.ip_sync_interval = 0;
login_config.log_login = true;
safestrncpy(login_config.date_format, "%Y-%m-%d %H:%M:%S", sizeof(login_config.date_format));
@@ -1559,6 +1560,8 @@ int login_config_read(const char* cfgName)
login_config.use_dnsbl = (bool)config_switch(w2);
else if(!strcmpi(w1, "dnsbl_servers"))
safestrncpy(login_config.dnsbl_servs, w2, sizeof(login_config.dnsbl_servs));
+ else if(!strcmpi(w1, "ipban_cleanup_interval"))
+ login_config.ipban_cleanup_interval = (unsigned int)atoi(w2);
else if(!strcmpi(w1, "ip_sync_interval"))
login_config.ip_sync_interval = (unsigned int)1000*60*atoi(w2); //w2 comes in minutes.