Explorar o código

Add chansets 'flood-mchan', 'flood-mbytes', 'flood-mctcp' to control reactions to mass floods (#37)

Bryan Drewery %!s(int64=14) %!d(string=hai) anos
pai
achega
56e6a51f35

+ 1 - 0
doc/UPDATES

@@ -2,6 +2,7 @@
 * Add chanset 'flood-bytes' to count how many bytes:second a user sends before getting kicked for flood. (#42)
 * Add chanset 'flood-bytes' to count how many bytes:second a user sends before getting kicked for flood. (#42)
 * Bot will now lockdown channel (+im) if banlist becomes full (#37)
 * Bot will now lockdown channel (+im) if banlist becomes full (#37)
 * Bot will now lockdown channel (+im) if a drone flood is detected (#37)
 * Bot will now lockdown channel (+im) if a drone flood is detected (#37)
+  * Add chansets 'flood-mchan', 'flood-mbytes', 'flood-mctcp' to control reactions to mass floods (#37)
 
 
 1.4.0 - http://wraith.botpack.net/milestone/1.4.0
 1.4.0 - http://wraith.botpack.net/milestone/1.4.0
   * Updated server list, 'set -yes servers -' and 'set -yes servers6 -' to get new list.
   * Updated server list, 'set -yes servers -' and 'set -yes servers6 -' to get new list.

+ 13 - 1
doc/help.txt

@@ -559,8 +559,20 @@ See also: link%{+a}, newhub%{-}
         $bflood-nick$b   Set here how many nick changes in how many seconds from
         $bflood-nick$b   Set here how many nick changes in how many seconds from
                     one host constitutes a flood. Setting this to 0 or 0:0
                     one host constitutes a flood. Setting this to 0 or 0:0
                     disables nick flood protection for the channel.
                     disables nick flood protection for the channel.
+   The following settings will trigger a lockdown (chanmode +mi) for 'flood-lock-time'
+   seconds.
         $bflood-mjoin$b  Set how many joins in how many seconds before triggering
         $bflood-mjoin$b  Set how many joins in how many seconds before triggering
-                    a lockdown for mass join. ($bnomassjoin$b must be set).
+                    a lockdown for mass join. ($bnomassjoin$b must be set). Setting
+                    this to 0 or 0:0 disables mass join protection for the channel.
+        $bflood-mchan$b  Set here how many channel messages in how many seconds
+                    from any host constitutes a flood. Setting this to 0 or 0:0
+                    disables text flood protection for the channel.
+        $bflood-mbytes$b  Set here how many bytes in how many seconds from any
+                    host constitutes a flood. Setting this to 0 or 0:0
+                    disables text flood protection for the channel.
+        $bflood-mctcp$b  Set here how many channel ctcps in how many seconds from
+                    any host constitutes a flood. Setting this to 0 or 0:0
+                    disables ctcp flood protection for the channel.
    These can all be changed simultaneously with $bflood-*$b
    These can all be changed simultaneously with $bflood-*$b
  
  
 See also: %{-}%{+n}+chan, -chan%{-}%{+m|m}, chanset%{-}
 See also: %{-}%{+n}+chan, -chan%{-}%{+m|m}, chanset%{-}

+ 6 - 0
src/chan.h

@@ -168,8 +168,12 @@ struct chanset_t {
   uint32_t ircnet_status;
   uint32_t ircnet_status;
   int flood_pub_thr;
   int flood_pub_thr;
   interval_t flood_pub_time;
   interval_t flood_pub_time;
+  int flood_mpub_thr;
+  interval_t flood_mpub_time;
   int flood_bytes_thr;
   int flood_bytes_thr;
   interval_t flood_bytes_time;
   interval_t flood_bytes_time;
+  int flood_mbytes_thr;
+  interval_t flood_mbytes_time;
   int flood_join_thr;
   int flood_join_thr;
   interval_t flood_join_time;
   interval_t flood_join_time;
   int flood_deop_thr;
   int flood_deop_thr;
@@ -178,6 +182,8 @@ struct chanset_t {
   interval_t flood_kick_time;
   interval_t flood_kick_time;
   int flood_ctcp_thr;
   int flood_ctcp_thr;
   interval_t flood_ctcp_time;
   interval_t flood_ctcp_time;
+  int flood_mctcp_thr;
+  interval_t flood_mctcp_time;
   int flood_nick_thr;
   int flood_nick_thr;
   interval_t flood_nick_time;
   interval_t flood_nick_time;
   interval_t flood_lock_time;
   interval_t flood_lock_time;

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

@@ -767,12 +767,18 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
 
 
         chan->flood_pub_thr = thr;
         chan->flood_pub_thr = thr;
         chan->flood_pub_time = time;
         chan->flood_pub_time = time;
+        chan->flood_mpub_thr = thr;
+        chan->flood_mpub_time = time;
         chan->flood_bytes_thr = thr;
         chan->flood_bytes_thr = thr;
         chan->flood_bytes_time = time;
         chan->flood_bytes_time = time;
+        chan->flood_mbytes_thr = thr;
+        chan->flood_mbytes_time = time;
         chan->flood_join_thr = thr;
         chan->flood_join_thr = thr;
         chan->flood_join_time = time;
         chan->flood_join_time = time;
         chan->flood_ctcp_thr = thr;
         chan->flood_ctcp_thr = thr;
         chan->flood_ctcp_time = time;
         chan->flood_ctcp_time = time;
+        chan->flood_mctcp_thr = thr;
+        chan->flood_mctcp_time = time;
         chan->flood_kick_thr = thr;
         chan->flood_kick_thr = thr;
         chan->flood_kick_time = time;
         chan->flood_kick_time = time;
         chan->flood_deop_thr = thr;
         chan->flood_deop_thr = thr;
@@ -805,6 +811,15 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
       } else if (!strcmp(item[i] + 6, "mjoin")) {
       } else if (!strcmp(item[i] + 6, "mjoin")) {
 	pthr = &chan->flood_mjoin_thr;
 	pthr = &chan->flood_mjoin_thr;
 	ptime = &chan->flood_mjoin_time;
 	ptime = &chan->flood_mjoin_time;
+      } else if (!strcmp(item[i] + 6, "mpub")) {
+	pthr = &chan->flood_mpub_thr;
+	ptime = &chan->flood_mpub_time;
+      } else if (!strcmp(item[i] + 6, "mbytes")) {
+	pthr = &chan->flood_mbytes_thr;
+	ptime = &chan->flood_mbytes_time;
+      } else if (!strcmp(item[i] + 6, "mctcp")) {
+	pthr = &chan->flood_mctcp_thr;
+	ptime = &chan->flood_mctcp_time;
       } else { /* Ignore for optimal forward compatibility */
       } else { /* Ignore for optimal forward compatibility */
         i++;
         i++;
         continue;
         continue;
@@ -1056,6 +1071,12 @@ int channel_add(char *result, const char *newname, char *options, bool isdefault
     chan->flood_nick_time = gfld_nick_time;
     chan->flood_nick_time = gfld_nick_time;
     chan->flood_mjoin_thr = 6;
     chan->flood_mjoin_thr = 6;
     chan->flood_mjoin_time = 1;
     chan->flood_mjoin_time = 1;
+    chan->flood_mpub_thr = 10;
+    chan->flood_mpub_time = 1;
+    chan->flood_mbytes_thr = 500;
+    chan->flood_mbytes_time = 1;
+    chan->flood_mctcp_thr = 7;
+    chan->flood_mctcp_time = 1;
     chan->limitraise = 20;
     chan->limitraise = 20;
     chan->ban_time = global_ban_time;
     chan->ban_time = global_ban_time;
     chan->exempt_time = global_exempt_time;
     chan->exempt_time = global_exempt_time;

+ 7 - 5
src/mod/channels.mod/cmdschan.c

@@ -1257,17 +1257,19 @@ static void cmd_chaninfo(int idx, char *par)
     SHOW_INT("Protect-backup: ", chan->protect_backup, "Do!", "Don't!");
     SHOW_INT("Protect-backup: ", chan->protect_backup, "Do!", "Don't!");
     SHOW_INT("Voice-non-ident: ", chan->voice_non_ident, "Do!", "Don't!");
     SHOW_INT("Voice-non-ident: ", chan->voice_non_ident, "Do!", "Don't!");
 
 
-    dprintf(idx, "Flood settings:   chan bytes ctcp join kick deop nick mjoin\n");
-    dprintf(idx, "  number:          %3d  %4d  %3d  %3d  %3d  %3d  %3d  %3d\n",
+    dprintf(idx, "Flood settings:   chan bytes ctcp join kick deop nick mjoin mpub mbytes mctcp\n");
+    dprintf(idx, "  number:          %3d  %4d  %3d  %3d  %3d  %3d  %3d   %3d  %3d   %4d   %3d\n",
 	    chan->flood_pub_thr, chan->flood_bytes_thr, chan->flood_ctcp_thr,
 	    chan->flood_pub_thr, chan->flood_bytes_thr, chan->flood_ctcp_thr,
 	    chan->flood_join_thr, chan->flood_kick_thr,
 	    chan->flood_join_thr, chan->flood_kick_thr,
 	    chan->flood_deop_thr, chan->flood_nick_thr,
 	    chan->flood_deop_thr, chan->flood_nick_thr,
-            chan->flood_mjoin_thr);
-    dprintf(idx, "  time  :          %3u  %4u  %3u  %3u  %3u  %3u  %3u  %3u\n",
+            chan->flood_mjoin_thr, chan->flood_mpub_thr,
+            chan->flood_mbytes_thr, chan->flood_mctcp_thr);
+    dprintf(idx, "  time  :          %3u  %4u  %3u  %3u  %3u  %3u  %3u   %3u  %3u   %4u  %4u\n",
 	    chan->flood_pub_time, chan->flood_bytes_time, chan->flood_ctcp_time,
 	    chan->flood_pub_time, chan->flood_bytes_time, chan->flood_ctcp_time,
 	    chan->flood_join_time, chan->flood_kick_time,
 	    chan->flood_join_time, chan->flood_kick_time,
 	    chan->flood_deop_time, chan->flood_nick_time,
 	    chan->flood_deop_time, chan->flood_nick_time,
-            chan->flood_mjoin_time);
+            chan->flood_mjoin_time, chan->flood_mpub_time,
+            chan->flood_mbytes_time, chan->flood_mctcp_time);
   }
   }
 }
 }
 
 

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

@@ -717,6 +717,7 @@ bd::String channel_to_string(struct chanset_t* chan, bool force_inactive) {
 chanmode { %s } groups { %s } bad-cookie %d manop %d mdop %d mop %d limit %d revenge %d ban-type %d \
 chanmode { %s } groups { %s } bad-cookie %d manop %d mdop %d mop %d limit %d revenge %d ban-type %d \
 flood-chan %d:%d flood-bytes %d:%d flood-ctcp %d:%d flood-join %d:%d \
 flood-chan %d:%d flood-bytes %d:%d flood-ctcp %d:%d flood-join %d:%d \
 flood-kick %d:%d flood-deop %d:%d flood-nick %d:%d flood-mjoin %d:%d \
 flood-kick %d:%d flood-deop %d:%d flood-nick %d:%d flood-mjoin %d:%d \
+flood-mpub %d:%d flood-mbytes %d:%d flood-mctcp %d:%d \
 closed-ban %d closed-invite %d closed-private %d ban-time %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 \
 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 } \
 flood-exempt %d flood-lock-time %d knock %d fish-key { %s } \
@@ -745,6 +746,9 @@ flood-exempt %d flood-lock-time %d knock %d fish-key { %s } \
         chan->flood_deop_thr, chan->flood_deop_time,
         chan->flood_deop_thr, chan->flood_deop_time,
 	chan->flood_nick_thr, chan->flood_nick_time,
 	chan->flood_nick_thr, chan->flood_nick_time,
 	chan->flood_mjoin_thr, chan->flood_mjoin_time,
 	chan->flood_mjoin_thr, chan->flood_mjoin_time,
+	chan->flood_mpub_thr, chan->flood_mpub_time,
+	chan->flood_mbytes_thr, chan->flood_mbytes_time,
+	chan->flood_mctcp_thr, chan->flood_mctcp_time,
         chan->closed_ban,
         chan->closed_ban,
 /* Chanint template
 /* Chanint template
  *      chan->temp,
  *      chan->temp,

+ 6 - 0
src/mod/irc.mod/chan.c

@@ -585,17 +585,23 @@ static bool detect_chan_flood(memberlist* m, const char *from, struct chanset_t
   case FLOOD_NOTICE:
   case FLOOD_NOTICE:
     thr = chan->flood_pub_thr;
     thr = chan->flood_pub_thr;
     lapse = chan->flood_pub_time;
     lapse = chan->flood_pub_time;
+    mthr = chan->flood_mpub_thr;
+    mlapse = chan->flood_mpub_time;
     strlcpy(ftype, "pub", sizeof(ftype));
     strlcpy(ftype, "pub", sizeof(ftype));
     break;
     break;
   case FLOOD_BYTES:
   case FLOOD_BYTES:
     thr = chan->flood_bytes_thr;
     thr = chan->flood_bytes_thr;
     lapse = chan->flood_bytes_time;
     lapse = chan->flood_bytes_time;
+    mthr = chan->flood_mbytes_thr;
+    mlapse = chan->flood_mbytes_time;
     strlcpy(ftype, "bytes", sizeof(ftype));
     strlcpy(ftype, "bytes", sizeof(ftype));
     increment = static_cast<int>(strlen(msg));
     increment = static_cast<int>(strlen(msg));
     break;
     break;
   case FLOOD_CTCP:
   case FLOOD_CTCP:
     thr = chan->flood_ctcp_thr;
     thr = chan->flood_ctcp_thr;
     lapse = chan->flood_ctcp_time;
     lapse = chan->flood_ctcp_time;
+    mthr = chan->flood_mctcp_thr;
+    mlapse = chan->flood_mctcp_time;
     strlcpy(ftype, "pub", sizeof(ftype));
     strlcpy(ftype, "pub", sizeof(ftype));
     break;
     break;
   case FLOOD_NICK:
   case FLOOD_NICK: