Просмотр исходного кода

* Port [3351] to 1.2.14
* Add chanset 'flood-mjoin' to handle rate for +nomassjoin



svn: 3352

Bryan Drewery 19 лет назад
Родитель
Сommit
8534bc5128

+ 1 - 1
doc/UPDATES

@@ -32,7 +32,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Fixed +voice flaw where users in channels that were +voice AND +private would only be voiced with |v.
 * Added cmd_clearhosts
 * Added 'whois restrictions' to more cmds.
-* Add channel flag 'nomassjoin' to set +im on a timer during join floods (drones)
+* Add channel flags 'nomassjoin' and 'flood-mjoin' to set +im on a timer during join floods (drones)
 * Add BOT flag +f for handling cpu intensive floods (none supported yet)
 * Add chanset 'flood-exempt' to exempt ops/voices from flood controls (see 'help chaninfo')
 * Add chanset 'flood-lock-time' to control how long to keep the channel locked during drone floods.

+ 2 - 0
misc/help.txt

@@ -515,6 +515,8 @@ See also: link
         $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
                     disables nick flood protection for the channel.
+        $bflood-mjoin$b  Set how many joins in how many seconds before triggering
+                    a lockdown for mass join. ($bnomassjoin$b must be set).
      These can all be changed simultaneously with $bflood-*$b
  
 See also: %{-}%{+n}+chan, -chan%{-}%{+m|m}, chanset%{-}

+ 3 - 1
src/chan.h

@@ -159,7 +159,9 @@ struct chanset_t {
   time_t flood_ctcp_time;
   int flood_nick_thr;
   time_t flood_nick_time;
-  int flood_lock_time;
+  time_t flood_lock_time;
+  time_t flood_mjoin_time;
+  int flood_mjoin_thr;
   int limitraise;
   int checklimit;
   int closed_ban;

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

@@ -1259,15 +1259,17 @@ static void cmd_chaninfo(int idx, char *par)
 //    SHOW_INT("Revenge-mode: ", chan->revenge_mode, NULL, NULL);
     SHOW_INT("Voice-non-ident: ", chan->voice_non_ident, "Do!", "Don't!");
 
-    dprintf(idx, "Flood settings:   chan ctcp join kick deop nick\n");
-    dprintf(idx, "  number:          %3d  %3d  %3d  %3d  %3d  %3d\n",
+    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,
 	    chan->flood_join_thr, chan->flood_kick_thr,
-	    chan->flood_deop_thr, chan->flood_nick_thr);
-    dprintf(idx, "  time  :          %3lu  %3lu  %3lu  %3lu  %3lu  %3lu\n",
+	    chan->flood_deop_thr, chan->flood_nick_thr,
+            chan->flood_mjoin_thr);
+    dprintf(idx, "  time  :          %3lu  %3lu  %3lu  %3lu  %3lu  %3lu  %3lu\n",
 	    chan->flood_pub_time, chan->flood_ctcp_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);
   }
 }
 

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

@@ -679,6 +679,8 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
         chan->flood_deop_time = time;
         chan->flood_nick_thr = thr;
         chan->flood_nick_time = time;
+        chan->flood_mjoin_thr = thr;
+        chan->flood_mjoin_time = time;
       } else if (!strcmp(item[i] + 6, "chan")) {
 	pthr = &chan->flood_pub_thr;
 	ptime = &chan->flood_pub_time;
@@ -697,6 +699,9 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
       } else if (!strcmp(item[i] + 6, "nick")) {
 	pthr = &chan->flood_nick_thr;
 	ptime = &chan->flood_nick_time;
+      } else if (!strcmp(item[i] + 6, "mjoin")) {
+	pthr = &chan->flood_mjoin_thr;
+	ptime = &chan->flood_mjoin_time;
       } else {
 	if (result)
 	  simple_snprintf(result, RESULT_LEN, "illegal channel flood type: %s", item[i]);
@@ -898,6 +903,8 @@ int channel_add(char *result, char *newname, char *options)
     chan->flood_kick_time = gfld_kick_time;
     chan->flood_nick_thr = gfld_nick_thr;
     chan->flood_nick_time = gfld_nick_time;
+    chan->flood_mjoin_thr = 1;
+    chan->flood_mjoin_time = 6;
 //    chan->revenge_mode = global_revenge_mode;
     chan->idle_kick = global_idle_kick;
     chan->limitraise = 20;

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

@@ -727,10 +727,10 @@ bool write_chans(FILE *f, int idx)
 
     if (lfprintf(f, "\
 + channel add %s { chanmode { %s } addedby %s addedts %lu idle-kick %d \
-bad-cookie %d manop %d mdop %d mop %d \
-limit %d flood-chan %d:%lu \
-flood-ctcp %d:%lu flood-join %d:%lu flood-kick %d:%lu flood-deop %d:%lu \
-flood-nick %d:%lu closed-ban %d closed-invite %d closed-private %d ban-time %lu \
+bad-cookie %d manop %d mdop %d mop %d limit %d \
+flood-chan %d:%lu flood-ctcp %d:%lu flood-join %d:%lu \
+flood-kick %d:%lu flood-deop %d:%lu flood-nick %d:%lu flood-mjoin %d:%lu \
+closed-ban %d closed-invite %d closed-private %d ban-time %lu \
 exempt-time %lu invite-time %lu voice-non-ident %d \
 flood-exempt %d flood-lock-time %d \
 %cenforcebans %cdynamicbans %cuserban %cbitch %cprotectops \
@@ -757,6 +757,7 @@ flood-exempt %d flood-lock-time %d \
         chan->flood_kick_thr, chan->flood_kick_time,
         chan->flood_deop_thr, chan->flood_deop_time,
 	chan->flood_nick_thr, chan->flood_nick_time,
+	chan->flood_mjoin_thr, chan->flood_mjoin_time,
         chan->closed_ban,
 /* Chanint template
  *      chan->temp,

+ 2 - 2
src/mod/irc.mod/chan.c

@@ -2434,13 +2434,13 @@ static int gotjoin(char *from, char *chname)
         m->tried_getuser = 1;
 
         if (!chk_op(fr, chan) && channel_nomassjoin(chan) && me_op(chan)) {
-          if (chan->channel.drone_jointime < now - flood_massjoin.time) {      //expired, reset counter
+          if (chan->channel.drone_jointime < now - chan->flood_mjoin_time) {      //expired, reset counter
             chan->channel.drone_joins = 0;
           }
           ++chan->channel.drone_joins;
           chan->channel.drone_jointime = now;
 
-          if (!chan->channel.drone_set_mode && chan->channel.drone_joins >= flood_massjoin.count) {  //flood from dronenet, let's attempt to set +im
+          if (!chan->channel.drone_set_mode && chan->channel.drone_joins >= chan->flood_mjoin_thr) {  //flood from dronenet, let's attempt to set +im
             detected_drone_flood(chan, m);
           }
         }

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

@@ -69,8 +69,6 @@ static bool prevent_mixing = 1;  /* To prevent mixing old/new modes */
 static bool include_lk = 1;      /* For correct calculation
                                  * in real_add_mode. */
 
-rate_t flood_massjoin = { 6, 1 };
-
 #include "chan.c"
 #include "mode.c"
 #include "cmdsirc.c"