Преглед изворни кода

* Port [3343] to 1.2.14
* Add chanset 'flood-exempt' to exempt ops/voices from flood controls (see 'help chaninfo')



svn: 3344

Bryan Drewery пре 19 година
родитељ
комит
5e064c25e5

+ 1 - 0
doc/UPDATES

@@ -34,6 +34,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Added 'whois restrictions' to more cmds.
 * Add channel flag 'nomassjoin' 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')
 
 1.2.13 - http://wraith.shatow.net/milestone/1.2.13
 * Fix cmd_chanset accepting invalid flags

+ 7 - 0
misc/help.txt

@@ -379,6 +379,13 @@ See also: link
                           Once the ban is removed, then the exempt will be
                           removed the next time the bot checks. Please note
                           that this is an IRCnet feature.
+        $bflood-exempt$b      Should clients be exempt from flood checks based
+                              on their channel status? (not deop/kick floods)
+                              Valid values are:
+                              None/0         Stick to regular checking (+x)
+                              Op/1           Ops are exempt from flood checks
+                              Voice/2        Voices are exempt from flood checks
+ 
         $binvite-time$b       Set here how long temporary invites will last (in
                           minutes). If you set this setting to 0, the bot will
                           never remove them. The bot will check the invites

+ 4 - 0
src/chan.h

@@ -23,6 +23,9 @@ typedef struct memstruct {
   char userip[UHOSTLEN];
 } memberlist;
 
+#define FLOOD_EXEMPT_OP	1
+#define FLOOD_EXEMPT_VOICE 2
+
 #define CHANMETA "#&!+"
 #define NICKVALID "[{}]^`|\\_-"
 
@@ -169,6 +172,7 @@ struct chanset_t {
 /* Chanint template 
  *int temp;
  */
+  int flood_exempt_mode;
   int idle_kick;
 #ifdef REVENGE
   int revenge_mode;

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

@@ -1149,6 +1149,7 @@ void show_int(int idx, char *work, int *cnt, const char *desc, int state, const
 #define SHOW_FLAG(name, state) show_flag(idx, work, &cnt, name, state)
 #define SHOW_INT(desc, state, yes, no) show_int(idx, work, &cnt, desc, state, yes, no)
 #define P_STR deflag == P_KICK ? "Kick" : (deflag == P_DEOP ? "Deop" : (deflag == P_DELETE ? "Remove" : NULL))
+#define F_STR chan->flood_exempt_mode == FLOOD_EXEMPT_OP ? "Op" : (chan->flood_exempt_mode == FLOOD_EXEMPT_VOICE ? "Voice" : NULL)
 static void cmd_chaninfo(int idx, char *par)
 {
   char *chname = NULL, work[512] = "";
@@ -1244,6 +1245,7 @@ static void cmd_chaninfo(int idx, char *par)
     SHOW_INT("Closed-invite:", chan->closed_invite, NULL, "Don't!");
     SHOW_INT("Closed-Private:", chan->closed_private, NULL, "Don't!");
     SHOW_INT("Exempt-time: ", chan->exempt_time, NULL, "Forever");
+    SHOW_INT("Flood-exempt: ", chan->flood_exempt_mode, F_STR, "None");
     SHOW_INT("Idle Kick after (idle-kick): ", chan->idle_kick, "", "Don't!");
     SHOW_INT("Invite-time: ", chan->invite_time, NULL, "Forever");
     SHOW_INT("Limit raise (limit): ", chan->limitraise, NULL, "Disabled");

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

@@ -462,6 +462,23 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
         return ERROR;
       }
       chan->mop = deflag_translate(item[i]);
+    } else if (!strcmp(item[i], "flood-exempt")) {
+      i++;
+      if (i >= items) {
+        if (result)
+          simple_snprintf(result, RESULT_LEN, "channel flood-exempt needs argument");
+        return ERROR;
+      }
+      if (str_isdigit(item[i])) {
+        if (!egg_strcasecmp("Op", item[i]))
+          chan->flood_exempt_mode = FLOOD_EXEMPT_OP;
+        else if (!egg_strcasecmp("Voice", item[i]))
+          chan->flood_exempt_mode = FLOOD_EXEMPT_VOICE;
+        else if (!egg_strcasecmp("None", item[i]))
+          chan->flood_exempt_mode = 0;
+      } else
+        chan->flood_exempt_mode = atoi(item[i]);
+
 /* Chanint template
  *  } else if (!strcmp(item[i], "temp")) {
  *    i++;
@@ -858,6 +875,7 @@ int channel_add(char *result, char *newname, char *options)
 /* Chanint template
  *  chan->temp = 0;
  */
+    chan->flood_exempt_mode = 0;
     chan->flood_pub_thr = gfld_chan_thr;
     chan->flood_pub_time = gfld_chan_time;
     chan->flood_ctcp_thr = gfld_ctcp_thr;

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

@@ -732,6 +732,7 @@ 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 \
 exempt-time %lu invite-time %lu voice-non-ident %d \
+flood-exempt %d \
 %cenforcebans %cdynamicbans %cuserban %cbitch %cprotectops \
 %cprivate %ccycle %cinactive %cdynamicexempts %cuserexempts \
 %cdynamicinvites %cuserinvites %cnodesynch %cclosed %cvoice \
@@ -767,6 +768,7 @@ exempt-time %lu invite-time %lu voice-non-ident %d \
         chan->exempt_time,
         chan->invite_time,
         chan->voice_non_ident,
+        chan->flood_exempt_mode,
  	PLSMNS(channel_enforcebans(chan)),
 	PLSMNS(channel_dynamicbans(chan)),
 	PLSMNS(!channel_nouserbans(chan)),

+ 4 - 1
src/mod/irc.mod/chan.c

@@ -423,7 +423,10 @@ static bool detect_chan_flood(char *floodnick, char *floodhost, char *from,
       ((which == FLOOD_KICK) &&
        (glob_master(fr) || chan_master(fr))) ||
       ((which != FLOOD_DEOP) && (which != FLOOD_KICK) && 
-       (chk_noflood(fr))))
+       ( (chk_noflood(fr) || 
+         (chan->flood_exempt_mode == FLOOD_EXEMPT_OP && chan_hasop(m)) || 
+         (chan->flood_exempt_mode == FLOOD_EXEMPT_VOICE && chan_hasvoice(m)) )
+      )))
     return 0;
 
   char h[UHOSTLEN] = "", ftype[12] = "", *p = NULL;