summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt4
-rw-r--r--src/login/ipban_sql.c25
2 files changed, 27 insertions, 2 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index bc520c7cb..744f6da3e 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -3,8 +3,10 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
+2008/10/15
+ * Fixed ipban sql connecting to the sql server when disabled. [FlavioJS]
2008/10/11
- * Using Kaizel in conjunction with Osiris Card should now work. (bugreport:2251) [SketchyPhoenix]
+ * Using Kaizel in conjunction with Osiris Card should now work. (bugreport:2251) [SketchyPhoenix]
* #monsterignore should turn off now. (bugreport:2306) [SketchyPhoenix]
2008/10/09
* Rev. 13272 Updated NPC_REBIRTH. Has it's own values, and no longer leeches off SL_KAIZEL. [L0ne_W0lf]
diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c
index aec74e06b..db383b908 100644
--- a/src/login/ipban_sql.c
+++ b/src/login/ipban_sql.c
@@ -33,6 +33,7 @@ static char ipban_table[32] = "ipbanlist";
// globals
static Sql* sql_handle = NULL;
static int cleanup_timer_id = INVALID_TIMER;
+static bool ipban_inited = false;
int ipban_cleanup(int tid, unsigned int tick, int id, intptr data);
@@ -47,6 +48,11 @@ void ipban_init(void)
const char* database;
const char* codepage;
+ ipban_inited = true;
+
+ if( !login_config.ipban )
+ return;// ipban disabled
+
if( ipban_db_hostname[0] != '\0' )
{// local settings
username = ipban_db_username;
@@ -85,6 +91,9 @@ void ipban_init(void)
// finalize
void ipban_final(void)
{
+ if( !login_config.ipban )
+ return;// ipban disabled
+
// release data
delete_timer(cleanup_timer_id, ipban_cleanup);
@@ -98,6 +107,9 @@ bool ipban_config_read(const char* key, const char* value)
{
const char* signature;
+ if( ipban_inited )
+ return false;// settings can only be changed before init
+
signature = "sql.";
if( strncmpi(key, signature, strlen(signature)) == 0 )
{
@@ -186,6 +198,9 @@ bool ipban_check(uint32 ip)
char* data = NULL;
int matches;
+ 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'",
ipban_table, p[3], p[3], p[2], p[3], p[2], p[1], p[3], p[2], p[1], p[0]) )
{
@@ -207,7 +222,12 @@ bool ipban_check(uint32 ip)
// log failed attempt
void ipban_log(uint32 ip)
{
- unsigned long failures = loginlog_failedattempts(ip, login_config.dynamic_pass_failure_ban_interval);// how many times failed account? in one ip.
+ unsigned long failures;
+
+ 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.
// if over the limit, add a temporary ban entry
if( failures >= login_config.dynamic_pass_failure_ban_limit )
@@ -222,6 +242,9 @@ void ipban_log(uint32 ip)
// remove expired bans
int ipban_cleanup(int tid, unsigned int tick, int id, intptr data)
{
+ if( !login_config.ipban )
+ return 0;// ipban disabled
+
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `ipbanlist` WHERE `rtime` <= NOW()") )
Sql_ShowDebug(sql_handle);