Ver código fonte

Merge branch 'ducch-flood-ban'

* ducch-flood-ban:
  Mention new (+|-)floodban in doc/help.txt
  Make bots actually consider chanint floodban
  Add chanint (+|-)floodban to ban flooders
Bryan Drewery 14 anos atrás
pai
commit
31215d9f4b

+ 2 - 1
doc/help.txt

@@ -459,7 +459,8 @@ See also: link%{+a}, newhub%{-}
                        more secure and the chances of someone hijacking the bot
                        for ops in your channel are much less. This is
                        highly recommeneded to always be set.
-                       
+        $bfloodban$b   If a channel flood (public, notice or ctcp) is detected, the
+                       flooder will also be banned, in accordance with ban-type.
         $binactive$b       This prevents the bot from joining the channel (or
                        makes it leave the channel if it is already there). It
                        can be useful to make the bot leave a channel without

+ 2 - 0
src/chan.h

@@ -258,6 +258,7 @@ struct chanset_t {
 #define CHAN_AUTOOP         BIT23
 #define CHAN_MEANKICKS      BIT24	/* use mean/offensive kicks/bans */
 #define CHAN_VOICEBITCH     BIT25
+#define CHAN_FLOODBAN       BIT26
 
 #define CHAN_ASKED_EXEMPTS  BIT0
 #define CHAN_ASKED_INVITES  BIT1
@@ -293,6 +294,7 @@ struct chanset_t *findchan_by_dname(const char *name);
 #define channel_backup(chan) (chan->status & CHAN_BACKUP)
 #define channel_bitch(chan) (chan->status & CHAN_BITCH)
 #define chan_bitch(chan) (chan->status & (CHAN_BITCH|CHAN_BOTBITCH))
+#define channel_floodban(chan) (chan->status & CHAN_FLOODBAN)
 #define channel_botbitch(chan) (chan->status & CHAN_BOTBITCH)
 #define channel_nodesynch(chan) (chan->status & CHAN_NODESYNCH)
 #define channel_enforcebans(chan) (chan->status & CHAN_ENFORCEBANS)

+ 4 - 0
src/mod/channels.mod/chanmisc.c

@@ -589,6 +589,10 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
  *    chan->temp = atoi(item[i]);
  */
 
+    else if (!strcmp(item[i], "+floodban"))
+      chan->status |= CHAN_FLOODBAN;
+    else if (!strcmp(item[i], "-floodban"))
+      chan->status &= ~CHAN_FLOODBAN;
     else if (!strcmp(item[i], "+enforcebans"))
       chan->status |= CHAN_ENFORCEBANS;
     else if (!strcmp(item[i], "-enforcebans"))

+ 1 - 0
src/mod/channels.mod/cmdschan.c

@@ -1200,6 +1200,7 @@ static void cmd_chaninfo(int idx, char *par)
     SHOW_FLAG("cycle",		channel_cycle(chan));
     SHOW_FLAG("enforcebans", 	channel_enforcebans(chan));
     SHOW_FLAG("fastop",		channel_fastop(chan));
+    SHOW_FLAG("floodban", channel_floodban(chan));
     SHOW_FLAG("inactive",	channel_inactive(chan));
     SHOW_FLAG("meankicks",	channel_meankicks(chan));
     SHOW_FLAG("nodesynch",	channel_nodesynch(chan));

+ 2 - 1
src/mod/channels.mod/userchan.c

@@ -720,7 +720,7 @@ flood-kick %d:%d flood-deop %d:%d flood-nick %d:%d flood-mjoin %d:%d \
 closed-ban %d closed-invite %d closed-private %d ban-time %d \
 exempt-time %d invite-time %d voice-non-ident %d auto-delay %d \
 flood-exempt %d flood-lock-time %d knock %d fish-key { %s } \
-%cmeankicks %cenforcebans %cdynamicbans %cuserbans %cbitch \
+%cmeankicks %cenforcebans %cdynamicbans %cuserbans %cbitch %cfloodban \
 %cprivate %ccycle %cinactive %cdynamicexempts %cuserexempts \
 %cdynamicinvites %cuserinvites %cnodesynch %cclosed %cvoice \
 %cfastop %cautoop %cbotbitch %cbackup %cnomassjoin %crbl %cvoicebitch %cprotect protect-backup %d %c%s",
@@ -764,6 +764,7 @@ flood-exempt %d flood-lock-time %d knock %d fish-key { %s } \
 	PLSMNS(channel_dynamicbans(chan)),
 	PLSMNS(!channel_nouserbans(chan)),
 	PLSMNS(channel_bitch(chan)),
+	PLSMNS(channel_floodban(chan)),
 	PLSMNS(channel_privchan(chan)),
 	PLSMNS(channel_cycle(chan)),
         force_inactive ? '+' : PLSMNS(channel_inactive(chan)),

+ 11 - 3
src/mod/irc.mod/chan.c

@@ -665,9 +665,17 @@ static bool detect_chan_flood(char *floodnick, char *floodhost, char *from,
     case FLOOD_CTCP:
       /* Flooding chan! either by public or notice */
       if (!chan_sentkick(m) && me_op(chan)) {
-	putlog(LOG_MODES, chan->dname, "Channel flood from %s -- kicking", floodnick);
-        dprintf(DP_MODE, "KICK %s %s :%s%s\n", chan->name, floodnick, kickprefix, response(RES_FLOOD));
-	m->flags |= SENTKICK;
+        if (channel_floodban(chan)) {
+          putlog(LOG_MODES, chan->dname, "Channel flood from %s -- banning", floodnick);
+          char s[UHOSTLEN] = "", *s1 = NULL;
+          simple_snprintf(s, sizeof(s), "%s!%s", floodnick, floodhost);
+          s1 = quickban(chan, s);
+          u_addmask('b', chan, s1, conf.bot->nick, "channel flood", now + (60 * chan->ban_time), 0);
+        } else {
+          putlog(LOG_MODES, chan->dname, "Channel flood from %s -- kicking", floodnick);
+          dprintf(DP_MODE, "KICK %s %s :%s%s\n", chan->name, floodnick, kickprefix, response(RES_FLOOD));
+          m->flags |= SENTKICK;
+        }
       }
       return 1;
     case FLOOD_JOIN: