Explorar el Código

* Port [3341] to 1.2.14
* Add BOT flag +f for handling cpu intensive floods (none supported yet)


svn: 3342

Bryan Drewery hace 19 años
padre
commit
3a44b8bb3d
Se han modificado 4 ficheros con 25 adiciones y 5 borrados
  1. 1 0
      doc/UPDATES
  2. 1 0
      misc/help.txt
  3. 18 4
      src/flags.c
  4. 5 1
      src/flags.h

+ 1 - 0
doc/UPDATES

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

+ 1 - 0
misc/help.txt

@@ -1835,6 +1835,7 @@ See also: whom
    Valid bot-only flags:
    Valid bot-only flags:
       $bB$b = backup-bot (bot will only join chans marked +backup, see '%dhelp chaninfo')
       $bB$b = backup-bot (bot will only join chans marked +backup, see '%dhelp chaninfo')
       $bc$b = chat-bot (bot accepts DCC chat on irc)
       $bc$b = chat-bot (bot accepts DCC chat on irc)
+      $bf$b = flood-bot (bot reacts to floods based on [cpu intensive] flood settings)
       $bl$b = limit-bot (bot sets limit in all channels, see '%dhelp chaninfo') [$bCPU INTENSIVE$b]
       $bl$b = limit-bot (bot sets limit in all channels, see '%dhelp chaninfo') [$bCPU INTENSIVE$b]
       $br$b = resolve (bot resolves clients in to match against userlist) [$bCPU INTENSIVE+$b]
       $br$b = resolve (bot resolves clients in to match against userlist) [$bCPU INTENSIVE+$b]
       $bu$b - update-bot (see doc/UPGRADING)
       $bu$b - update-bot (see doc/UPGRADING)

+ 18 - 4
src/flags.c

@@ -43,8 +43,8 @@ sanity_check(flag_t atr, int bot)
   if (bot && (atr & (USER_PARTY | USER_MASTER | USER_OWNER | USER_ADMIN | USER_HUBA | USER_CHUBA)))
   if (bot && (atr & (USER_PARTY | USER_MASTER | USER_OWNER | USER_ADMIN | USER_HUBA | USER_CHUBA)))
     atr &= ~(USER_PARTY | USER_MASTER | USER_OWNER | USER_ADMIN | USER_HUBA | USER_CHUBA);
     atr &= ~(USER_PARTY | USER_MASTER | USER_OWNER | USER_ADMIN | USER_HUBA | USER_CHUBA);
 /* only bots should be there: */
 /* only bots should be there: */
-  if (!bot && (atr & (BOT_DOLIMIT | BOT_DOVOICE | BOT_UPDATEHUB | BOT_CHANHUB)))
-    atr &= ~(BOT_DOLIMIT | BOT_DOVOICE | BOT_UPDATEHUB | BOT_CHANHUB);
+  if (!bot && (atr & (BOT_DOLIMIT | BOT_DOVOICE | BOT_UPDATEHUB | BOT_CHANHUB | BOT_FLOODBOT )))
+    atr &= ~(BOT_DOLIMIT | BOT_DOVOICE | BOT_UPDATEHUB | BOT_CHANHUB | BOT_FLOODBOT );
   if (atr & USER_AUTOOP)
   if (atr & USER_AUTOOP)
     atr |= USER_OP;
     atr |= USER_OP;
   if ((atr & USER_OP) && (atr & USER_DEOP))
   if ((atr & USER_OP) && (atr & USER_DEOP))
@@ -81,8 +81,8 @@ chan_sanity_check(flag_t chatr, int bot)
   if (chatr & (USER_PARTY | USER_ADMIN | USER_HUBA | USER_CHUBA | BOT_UPDATEHUB))
   if (chatr & (USER_PARTY | USER_ADMIN | USER_HUBA | USER_CHUBA | BOT_UPDATEHUB))
     chatr &= ~(USER_PARTY | USER_ADMIN | USER_HUBA | USER_CHUBA | BOT_UPDATEHUB);
     chatr &= ~(USER_PARTY | USER_ADMIN | USER_HUBA | USER_CHUBA | BOT_UPDATEHUB);
   /* these should only be set on bots */
   /* these should only be set on bots */
-  if (!bot && (chatr & (BOT_DOLIMIT | BOT_DOVOICE | BOT_CHANHUB)))
-    chatr &= ~(BOT_DOLIMIT | BOT_DOVOICE | BOT_CHANHUB);
+  if (!bot && (chatr & (BOT_DOLIMIT | BOT_DOVOICE | BOT_CHANHUB | BOT_FLOODBOT )))
+    chatr &= ~(BOT_DOLIMIT | BOT_DOVOICE | BOT_CHANHUB | BOT_FLOODBOT );
 
 
   if ((chatr & USER_OP) && (chatr & USER_DEOP))
   if ((chatr & USER_OP) && (chatr & USER_DEOP))
     chatr &= ~(USER_OP | USER_DEOP);
     chatr &= ~(USER_OP | USER_DEOP);
@@ -547,6 +547,20 @@ dovoice(struct chanset_t *chan)
   return 0;
   return 0;
 }
 }
 
 
+int
+doflood(struct chanset_t *chan)
+{
+  if (!chan)
+    return 0;
+
+  struct flag_record fr = { FR_GLOBAL | FR_CHAN | FR_BOT, 0, 0, 0 };
+
+  get_user_flagrec(conf.bot->u, &fr, chan->dname);
+  if (glob_doflood(fr) || chan_doflood(fr))
+    return 1;
+  return 0;
+}
+
 int
 int
 dolimit(struct chanset_t *chan)
 dolimit(struct chanset_t *chan)
 {
 {

+ 5 - 1
src/flags.h

@@ -85,12 +85,13 @@ struct flag_record {
 
 
 #define BOT_BACKUP	FLAG[(int) 'B']
 #define BOT_BACKUP	FLAG[(int) 'B']
 #define BOT_CHANHUB	FLAG[(int) 'c']
 #define BOT_CHANHUB	FLAG[(int) 'c']
+#define BOT_FLOODBOT	FLAG[(int) 'f'] 
 #define BOT_UPDATEHUB	FLAG[(int) 'u']
 #define BOT_UPDATEHUB	FLAG[(int) 'u']
 #define BOT_DORESOLV	FLAG[(int) 'r']
 #define BOT_DORESOLV	FLAG[(int) 'r']
 #define BOT_DOLIMIT	FLAG[(int) 'l']
 #define BOT_DOLIMIT	FLAG[(int) 'l']
 #define BOT_DOVOICE	FLAG[(int) 'y']
 #define BOT_DOVOICE	FLAG[(int) 'y']
 
 
-#define BOT_CHAN_VALID (flag_t) CHAN_VALID|BOT_CHANHUB|BOT_DOLIMIT|BOT_DOVOICE|BOT_DORESOLV|BOT_BACKUP
+#define BOT_CHAN_VALID (flag_t) CHAN_VALID|BOT_CHANHUB|BOT_DOLIMIT|BOT_DOVOICE|BOT_DORESOLV|BOT_BACKUP|BOT_FLOODBOT
 #define BOT_VALID  (flag_t) BOT_CHAN_VALID|BOT_UPDATEHUB
 #define BOT_VALID  (flag_t) BOT_CHAN_VALID|BOT_UPDATEHUB
 
 
 
 
@@ -137,6 +138,8 @@ struct flag_record {
 #define chan_doresolv(x)                        ((x).chan & BOT_DORESOLV)
 #define chan_doresolv(x)                        ((x).chan & BOT_DORESOLV)
 #define glob_backup(x)				((x).global & BOT_BACKUP)
 #define glob_backup(x)				((x).global & BOT_BACKUP)
 #define chan_backup(x)				((x).chan & BOT_BACKUP)
 #define chan_backup(x)				((x).chan & BOT_BACKUP)
+#define glob_doflood(x)				((x).global & BOT_FLOODBOT)
+#define chan_doflood(x)				((x).chan & BOT_FLOODBOT)
 
 
 void init_flags(void);
 void init_flags(void);
 void get_user_flagrec(struct userrec *, struct flag_record *, const char *);
 void get_user_flagrec(struct userrec *, struct flag_record *, const char *);
@@ -161,6 +164,7 @@ int ischanhub(void);
 int isupdatehub(void);
 int isupdatehub(void);
 int doresolv(struct chanset_t *);
 int doresolv(struct chanset_t *);
 int dovoice(struct chanset_t *);
 int dovoice(struct chanset_t *);
+int doflood(struct chanset_t *);
 int dolimit(struct chanset_t *);
 int dolimit(struct chanset_t *);
 int whois_access(struct userrec *, struct userrec *);
 int whois_access(struct userrec *, struct userrec *);
 void deflag_user(struct userrec *, int, char *, struct chanset_t *);
 void deflag_user(struct userrec *, int, char *, struct chanset_t *);