summaryrefslogtreecommitdiff
path: root/src/login/ipban_sql.c
diff options
context:
space:
mode:
authorhemagx <hemagx2@gmail.com>2015-12-26 09:45:48 +0200
committerHaru <haru@dotalux.com>2016-01-10 02:56:57 +0100
commit93dd228452fd107df3cc00ef4c9445e3712ecaca (patch)
tree8b29d71d6a2dd3481dec43070e90bb69b6e213da /src/login/ipban_sql.c
parent4e4ecd0c82291a40dc7a70da76a93c58dc6dba81 (diff)
downloadhercules-93dd228452fd107df3cc00ef4c9445e3712ecaca.tar.gz
hercules-93dd228452fd107df3cc00ef4c9445e3712ecaca.tar.bz2
hercules-93dd228452fd107df3cc00ef4c9445e3712ecaca.tar.xz
hercules-93dd228452fd107df3cc00ef4c9445e3712ecaca.zip
Move declaration of login config struct to login interface
Closes #1030 as merged Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/login/ipban_sql.c')
-rw-r--r--src/login/ipban_sql.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c
index 090886e93..9d059ccd2 100644
--- a/src/login/ipban_sql.c
+++ b/src/login/ipban_sql.c
@@ -68,7 +68,7 @@ void ipban_init(void)
ipban_inited = true;
- if( !login_config.ipban )
+ if (!login->config->ipban)
return;// ipban disabled
if( ipban_db_hostname[0] != '\0' )
@@ -101,10 +101,10 @@ void ipban_init(void)
if( codepage[0] != '\0' && SQL_ERROR == SQL->SetEncoding(sql_handle, codepage) )
Sql_ShowDebug(sql_handle);
- if( login_config.ipban_cleanup_interval > 0 )
+ if (login->config->ipban_cleanup_interval > 0)
{ // set up periodic cleanup of connection history and active bans
timer->add_func_list(ipban_cleanup, "ipban_cleanup");
- cleanup_timer_id = timer->add_interval(timer->gettick()+10, ipban_cleanup, 0, 0, login_config.ipban_cleanup_interval*1000);
+ cleanup_timer_id = timer->add_interval(timer->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);
}
@@ -112,10 +112,10 @@ void ipban_init(void)
// finalize
void ipban_final(void)
{
- if( !login_config.ipban )
+ if (!login->config->ipban)
return;// ipban disabled
- if( login_config.ipban_cleanup_interval > 0 )
+ if (login->config->ipban_cleanup_interval > 0)
// release data
timer->delete(cleanup_timer_id, ipban_cleanup);
@@ -196,19 +196,19 @@ bool ipban_config_read(const char* key, const char* value)
{
key += strlen(signature);
if( strcmpi(key, "enable") == 0 )
- login_config.ipban = (bool)config_switch(value);
+ login->config->ipban = (bool)config_switch(value);
else
if( strcmpi(key, "dynamic_pass_failure_ban") == 0 )
- login_config.dynamic_pass_failure_ban = (bool)config_switch(value);
+ login->config->dynamic_pass_failure_ban = (bool)config_switch(value);
else
if( strcmpi(key, "dynamic_pass_failure_ban_interval") == 0 )
- login_config.dynamic_pass_failure_ban_interval = atoi(value);
+ login->config->dynamic_pass_failure_ban_interval = atoi(value);
else
if( strcmpi(key, "dynamic_pass_failure_ban_limit") == 0 )
- login_config.dynamic_pass_failure_ban_limit = atoi(value);
+ login->config->dynamic_pass_failure_ban_limit = atoi(value);
else
if( strcmpi(key, "dynamic_pass_failure_ban_duration") == 0 )
- login_config.dynamic_pass_failure_ban_duration = atoi(value);
+ login->config->dynamic_pass_failure_ban_duration = atoi(value);
else
return false;// not found
return true;
@@ -224,7 +224,7 @@ bool ipban_check(uint32 ip)
char* data = NULL;
int matches;
- if( !login_config.ipban )
+ if (!login->config->ipban)
return false;// ipban disabled
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')",
@@ -250,17 +250,17 @@ void ipban_log(uint32 ip)
{
unsigned long failures;
- if( !login_config.ipban )
+ if (!login->config->ipban)
return;// ipban disabled
- failures = loginlog_failedattempts(ip, login_config.dynamic_pass_failure_ban_interval);// how many times failed account? in one ip.
+ failures = loginlog_failedattempts(ip, login->config->dynamic_pass_failure_ban_interval);// how many times failed account? in one ip.
// if over the limit, add a temporary ban entry
- if( failures >= login_config.dynamic_pass_failure_ban_limit )
+ if (failures >= login->config->dynamic_pass_failure_ban_limit)
{
uint8* p = (uint8*)&ip;
if (SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s`(`list`,`btime`,`rtime`,`reason`) VALUES ('%u.%u.%u.*', NOW() , NOW() + INTERVAL %d MINUTE ,'Password error ban')",
- ipban_table, p[3], p[2], p[1], login_config.dynamic_pass_failure_ban_duration))
+ ipban_table, p[3], p[2], p[1], login->config->dynamic_pass_failure_ban_duration))
{
Sql_ShowDebug(sql_handle);
}
@@ -269,7 +269,7 @@ void ipban_log(uint32 ip)
// remove expired bans
int ipban_cleanup(int tid, int64 tick, int id, intptr_t data) {
- if( !login_config.ipban )
+ if (!login->config->ipban)
return 0;// ipban disabled
if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `rtime` <= NOW()", ipban_table) )