Explorar o código

Add chanset 'flood-bytes' (#42)

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

+ 1 - 0
doc/UPDATES

@@ -1,4 +1,5 @@
 * Fix flood kicking not properly tracking multiple clients at once (#43)
 * Fix flood kicking not properly tracking multiple clients at once (#43)
+* Add chanset 'flood-bytes' to count how many bytes:second a user sends before getting kicked for flood. (#42)
 
 
 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.

+ 3 - 0
doc/help.txt

@@ -541,6 +541,9 @@ See also: link%{+a}, newhub%{-}
         $bflood-chan$b  Set here how many channel messages in how many seconds
         $bflood-chan$b  Set here how many channel messages in how many seconds
                     from one host constitutes a flood. Setting this to 0 or 0:0
                     from one host constitutes a flood. Setting this to 0 or 0:0
                     disables text flood protection for the channel.
                     disables text flood protection for the channel.
+        $bflood-bytes$b  Set here how many bytes in how many seconds from one
+                    host constitutes a flood. Setting this to 0 or 0:0
+                    disables text flood protection for the channel.
         $bflood-ctcp$b  Set here how many channel ctcps in how many seconds from
         $bflood-ctcp$b  Set here how many channel ctcps 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 ctcp flood protection for the channel.
                     disables ctcp flood protection for the channel.

+ 2 - 0
src/chan.h

@@ -168,6 +168,8 @@ 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_bytes_thr;
+  interval_t flood_bytes_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;

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

@@ -767,6 +767,8 @@ 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_bytes_thr = thr;
+        chan->flood_bytes_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;
@@ -782,6 +784,9 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
       } else if (!strcmp(item[i] + 6, "chan")) {
       } else if (!strcmp(item[i] + 6, "chan")) {
 	pthr = &chan->flood_pub_thr;
 	pthr = &chan->flood_pub_thr;
 	ptime = &chan->flood_pub_time;
 	ptime = &chan->flood_pub_time;
+      } else if (!strcmp(item[i] + 6, "bytes")) {
+	pthr = &chan->flood_bytes_thr;
+	ptime = &chan->flood_bytes_time;
       } else if (!strcmp(item[i] + 6, "join")) {
       } else if (!strcmp(item[i] + 6, "join")) {
 	pthr = &chan->flood_join_thr;
 	pthr = &chan->flood_join_thr;
 	ptime = &chan->flood_join_time;
 	ptime = &chan->flood_join_time;
@@ -1037,6 +1042,8 @@ int channel_add(char *result, const char *newname, char *options, bool isdefault
     chan->flood_exempt_mode = 0;
     chan->flood_exempt_mode = 0;
     chan->flood_pub_thr = gfld_chan_thr;
     chan->flood_pub_thr = gfld_chan_thr;
     chan->flood_pub_time = gfld_chan_time;
     chan->flood_pub_time = gfld_chan_time;
+    chan->flood_bytes_thr = gfld_bytes_thr;
+    chan->flood_bytes_time = gfld_bytes_time;
     chan->flood_ctcp_thr = gfld_ctcp_thr;
     chan->flood_ctcp_thr = gfld_ctcp_thr;
     chan->flood_ctcp_time = gfld_ctcp_time;
     chan->flood_ctcp_time = gfld_ctcp_time;
     chan->flood_join_thr = gfld_join_thr;
     chan->flood_join_thr = gfld_join_thr;

+ 2 - 0
src/mod/channels.mod/channels.c

@@ -64,6 +64,8 @@ static char *lastdeletedmask = NULL;
 /* Global flood settings */
 /* Global flood settings */
 static int 			gfld_chan_thr;
 static int 			gfld_chan_thr;
 static interval_t 		gfld_chan_time;
 static interval_t 		gfld_chan_time;
+static int 			gfld_bytes_thr;
+static interval_t 		gfld_bytes_time;
 static int 			gfld_deop_thr = 8;
 static int 			gfld_deop_thr = 8;
 static interval_t 		gfld_deop_time = 10;
 static interval_t 		gfld_deop_time = 10;
 static int 			gfld_kick_thr;
 static int 			gfld_kick_thr;

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

@@ -1257,14 +1257,14 @@ 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 ctcp join kick deop nick mjoin\n");
-    dprintf(idx, "  number:          %3d  %3d  %3d  %3d  %3d  %3d  %3d\n",
-	    chan->flood_pub_thr, chan->flood_ctcp_thr,
+    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",
+	    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);
             chan->flood_mjoin_thr);
-    dprintf(idx, "  time  :          %3u  %3u  %3u  %3u  %3u  %3u  %3u\n",
-	    chan->flood_pub_time, chan->flood_ctcp_time,
+    dprintf(idx, "  time  :          %3u  %4u  %3u  %3u  %3u  %3u  %3u  %3u\n",
+	    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);

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

@@ -715,7 +715,7 @@ bd::String channel_to_string(struct chanset_t* chan, bool force_inactive) {
   get_mode_protect(chan, w, sizeof(w));
   get_mode_protect(chan, w, sizeof(w));
   return bd::String::printf("\
   return bd::String::printf("\
 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-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 \
 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 \
@@ -738,6 +738,7 @@ flood-exempt %d flood-lock-time %d knock %d fish-key { %s } \
         chan->limitraise,
         chan->limitraise,
         chan->ban_type,
         chan->ban_type,
 	chan->flood_pub_thr, chan->flood_pub_time,
 	chan->flood_pub_thr, chan->flood_pub_time,
+	chan->flood_bytes_thr, chan->flood_bytes_time,
         chan->flood_ctcp_thr, chan->flood_ctcp_time,
         chan->flood_ctcp_thr, chan->flood_ctcp_time,
         chan->flood_join_thr, chan->flood_join_time,
         chan->flood_join_thr, chan->flood_join_time,
         chan->flood_kick_thr, chan->flood_kick_time,
         chan->flood_kick_thr, chan->flood_kick_time,