fixed some syntax errors & tidied up code a little bit
authorpk910 <philipp@zoelle1.de>
Fri, 22 Jul 2011 00:47:29 +0000 (02:47 +0200)
committerpk910 <philipp@zoelle1.de>
Fri, 22 Jul 2011 01:56:01 +0000 (03:56 +0200)
src/mod-watchdog.c

index c1143662295e7f8bb2603dc912d81ff601ee9e61..e62bcd003156df78c685472dabfcb3eadaeb59c8 100644 (file)
@@ -37,6 +37,7 @@
 #include "modcmd.h"
 #include "saxdb.h"
 #include "timeq.h"
+#include "gline.h"
 
 #define KEY_BADWORDS "badwords"
 #define KEY_BADWORD_MASK "mask"
@@ -341,6 +342,7 @@ watchdog_detected_badword(struct userNode *user, struct chanNode *chan, struct b
 {
     char *hostmask;
     char *reason = watchdog_conf.punishment_reason;
+    char mask[IRC_NTOP_MAX_SIZE+3] = { '*', '@', '\0' };
     switch(badword->action) {
         case BADACTION_BAN:
             hostmask = generate_hostmask(user, GENMASK_STRICT_HOST | GENMASK_ANY_IDENT);
@@ -349,6 +351,7 @@ watchdog_detected_badword(struct userNode *user, struct chanNode *chan, struct b
                 //registered channel
                 add_channel_ban(chan->channel_info, hostmask, watchdog->nick, now, now, now + watchdog_conf.ban_duration, reason);
             }
+            struct mod_chanmode change;
             mod_chanmode_init(&change);
             change.argc = 1;
             change.args[0].mode = MODE_BAN;
@@ -363,14 +366,13 @@ watchdog_detected_badword(struct userNode *user, struct chanNode *chan, struct b
             DelUser(user, watchdog, 1, reason);
             break;
         case BADACTION_GLINE:
-            int size = strlen(user->hostname) + 3;
-            hostmask = alloca(size);
-            snprintf(hostmask, size, "*@%s", user->hostname);
-            gline_add(watchdog->nick, hostmask, watchdog_conf.gline_duration, reason, now, now, 0, 1);
+            irc_ntop(mask + 2, sizeof(mask) - 2, &user->ip);
+            gline_add(watchdog->nick, mask, watchdog_conf.gline_duration, reason, now, now, 0, 1);
             break;
         default:
             //error?
-    }
+            break;
+        }
 }
 
 static void
@@ -508,7 +510,7 @@ watchdog_saxdb_read_chanlist(const char *name, void *data, UNUSED_ARG(void *extr
     struct record_data *rd = data;
 
      if (rd->type == RECDB_OBJECT) {
-        dict_t obj = GET_RECORD_OBJECT(rd);
+        //dict_t obj = GET_RECORD_OBJECT(rd);
         /* nothing in here, yet */
 
         add_channel(name);
@@ -536,7 +538,6 @@ watchdog_saxdb_read(struct dict *db)
 static int
 watchdog_saxdb_write(struct saxdb_context *ctx)
 {
-    char str[10];
     dict_iterator_t it;
 
     saxdb_write_int(ctx, KEY_BADWORDID, last_badword_id);