Przeglądaj źródła

* Added rate vars 'flood-msg' and 'flood-ctcp' to control how quickly a bot ignores on flood.

svn: 2169
Bryan Drewery 21 lat temu
rodzic
commit
abcd86207d

+ 1 - 0
doc/UPDATES

@@ -150,6 +150,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Fixed cmd_jump/cmd_botjump not parsing 'server:port' correctly.
 * Added var 'auth-obscure': Don't halt on dcc w/dccauth if the pass is wrong; halt at hash (right or wrong). (#100)
 * Added var 'autoaway': How long in seconds until an idle user is set away on dcc auto. (Def: 1800, 30min)
+* Added rate vars 'flood-msg' and 'flood-ctcp' to control how quickly a bot ignores on flood.
 
 1.2.2
 * Don't sanity check flags for users on DCC CHAT if they are on the bot via .botcmd.

+ 3 - 1
misc/help.txt

@@ -1506,7 +1506,9 @@ See also: reload, backup
  
 [N]  $bfork-interval$b   Number of seconds in between each fork() call made by the bot. 
                           (Resets PID/CPU)
- 
+[R]  $bflood-msg$b       Msgs:Secs until a host is ignored. (0:0 to disable) 
+[R]  $bflood-ctcp$b      Ctcps:Secs until a host is ignored. (0:0 to disable) 
+
 [D]  $blogin$b           How to handle someone logging in to the shell.
 [D]  $btrace$b           How to handle someone tracing/debugging the bot.
 [D]  $bpromisc$b         How to handle when a interface is set to promiscuous mode.

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

@@ -2816,7 +2816,7 @@ static int gotmsg(char *from, char *msg)
 
   /* Only check if flood-ctcp is active */
   detect_autokick(nick, uhost, chan, msg);
-  if (flud_ctcp_thr && detect_avalanche(msg)) {
+  if (flood_ctcp.count && detect_avalanche(msg)) {
     memberlist *m = ismember(chan, nick);
 
     u = get_user_by_host(from);
@@ -2905,10 +2905,10 @@ static int gotmsg(char *from, char *msg)
     if (ctcp_mode != 2) {
       dprintf(DP_HELP, "NOTICE %s :%s\n", nick, ctcp_reply);
     } else {
-      if (now - last_ctcp > flud_ctcp_time) {
+      if (now - last_ctcp > flood_ctcp.time) {
 	dprintf(DP_HELP, "NOTICE %s :%s\n", nick, ctcp_reply);
 	count_ctcp = 1;
-      } else if (count_ctcp < flud_ctcp_thr) {
+      } else if (count_ctcp < flood_ctcp.count) {
 	dprintf(DP_HELP, "NOTICE %s :%s\n", nick, ctcp_reply);
 	count_ctcp++;
       }
@@ -2977,7 +2977,7 @@ static int gotnotice(char *from, char *msg)
   strcpy(uhost, from);
   nick = splitnick(&uhost);
   u = get_user_by_host(from);
-  if (flud_ctcp_thr && detect_avalanche(msg)) {
+  if (flood_ctcp.count && detect_avalanche(msg)) {
     memberlist *m = ismember(chan, nick);
 
     get_user_flagrec(u, &fr, chan->dname);

+ 3 - 5
src/mod/server.mod/server.c

@@ -39,10 +39,8 @@ static char serverpass[121] = "";
 static time_t trying_server;	/* trying to connect to a server right now? */
 int curserv = 999;		/* current position in server list: */
 port_t curservport = 0;
-int flud_thr = 5;		/* msg flood threshold */
-time_t flud_time = 60;		/* msg flood time */
-int flud_ctcp_thr = 3;	/* ctcp flood threshold */
-time_t flud_ctcp_time = 60;	/* ctcp flood time */
+rate_t flood_msg = { 5, 60 };
+rate_t flood_ctcp = { 3, 60 };
 char botuserhost[UHOSTLEN] = "";	/* bot's user@host (refreshed whenever the bot joins a channel) */
 					/* may not be correct user@host BUT it's how the server sees it */
 char botuserip[UHOSTLEN] = "";		/* bot's user@host with the ip. */
@@ -1017,7 +1015,7 @@ void server_report(int idx, int details)
            (int) ((float) (hq.tot * 100.0) / (float) maxqmsg), (int) hq.tot);
   if (details) {
     dprintf(idx, "    Flood is: %d msg/%lus, %d ctcp/%lus\n",
-	    flud_thr, flud_time, flud_ctcp_thr, flud_ctcp_time);
+	    flood_msg.count, flood_msg.time, flood_ctcp.count, flood_ctcp.time);
   }
 }
 

+ 4 - 2
src/mod/server.mod/server.h

@@ -8,6 +8,7 @@
 
 #include "src/tclhash.h"
 #include "src/dcc.h"
+#include "src/set.h"
 
 #define DO_LOST 1
 #define NO_LOST 0
@@ -46,13 +47,14 @@ enum {
 extern bind_table_t	*BT_ctcp, *BT_ctcr, *BT_msgc;
 extern size_t		nick_len;
 extern bool		quiet_reject, trigger_on_ignore, floodless;
-extern int 		servidx, ctcp_mode, flud_thr, flud_ctcp_thr, answer_ctcp, serv, curserv;
+extern int 		servidx, ctcp_mode, answer_ctcp, serv, curserv;
 extern port_t		default_port, newserverport, curservport;
-extern time_t		server_online, cycle_time, flud_time, flud_ctcp_time;
+extern time_t		server_online, cycle_time;
 extern char		cursrvname[], botrealname[121], botuserhost[], ctcp_reply[],
 			newserver[], newserverpass[], curnetwork[], botuserip[];
 extern struct server_list *serverlist;
 extern struct dcc_table SERVER_SOCKET;
+extern rate_t		flood_msg, flood_ctcp;
 int check_bind_ctcpr(char *, char *, struct userrec *, char *, char *, char *, bind_table_t *);
 
 #define check_bind_ctcp(a, b, c, d, e, f) check_bind_ctcpr(a, b, c, d, e, f, BT_ctcp)

+ 8 - 8
src/mod/server.mod/servmsg.c

@@ -335,13 +335,13 @@ static bool detect_flood(char *floodnick, char *floodhost, char *from, int which
   switch (which) {
   case FLOOD_PRIVMSG:
   case FLOOD_NOTICE:
-    thr = flud_thr;
-    lapse = flud_time;
+    thr = flood_msg.count;
+    lapse = flood_msg.time;
     strcpy(ftype, "msg");
     break;
   case FLOOD_CTCP:
-    thr = flud_ctcp_thr;
-    lapse = flud_ctcp_time;
+    thr = flood_ctcp.count;
+    lapse = flood_ctcp.time;
     strcpy(ftype, "ctcp");
     break;
   }
@@ -422,7 +422,7 @@ static int gotmsg(char *from, char *msg)
   /* Only check if flood-ctcp is active */
   strcpy(uhost, from);
   nick = splitnick(&uhost);
-  if (flud_ctcp_thr && detect_avalanche(msg)) {
+  if (flood_ctcp.count && detect_avalanche(msg)) {
     if (!ignoring) {
       putlog(LOG_MODES, "*", "Avalanche from %s - ignoring", from);
       p = strchr(uhost, '@');
@@ -514,10 +514,10 @@ static int gotmsg(char *from, char *msg)
     if (ctcp_mode != 2) {
       dprintf(DP_HELP, "NOTICE %s :%s\n", nick, ctcp_reply);
     } else {
-      if (now - last_ctcp > flud_ctcp_time) {
+      if (now - last_ctcp > flood_ctcp.time) {
         dprintf(DP_HELP, "NOTICE %s :%s\n", nick, ctcp_reply);
 	count_ctcp = 1;
-      } else if (count_ctcp < flud_ctcp_thr) {
+      } else if (count_ctcp < flood_ctcp.count) {
         dprintf(DP_HELP, "NOTICE %s :%s\n", nick, ctcp_reply);
 	count_ctcp++;
       }
@@ -598,7 +598,7 @@ static int gotnotice(char *from, char *msg)
   fixcolon(msg);
   strcpy(uhost, from);
   nick = splitnick(&uhost);
-  if (flud_ctcp_thr && detect_avalanche(msg)) {
+  if (flood_ctcp.count && detect_avalanche(msg)) {
     /* Discard -- kick user if it was to the channel */
     if (!ignoring)
       putlog(LOG_MODES, "*", "Avalanche from %s", from);

+ 2 - 0
src/set.c

@@ -59,6 +59,8 @@ static variable_t vars[] = {
  {"cloak-script",	&cloak_script,		0,				VAR_INT|VAR_CLOAK|VAR_NOLHUB, NULL, NULL},
  {"close-threshold",	&close_threshold,	0,				VAR_RATE|VAR_NOLOC, NULL, NULL},
  {"fight-threshold",	&fight_threshold,	0,				VAR_INT|VAR_NOLOC, NULL, NULL},
+ {"flood-msg",		&flood_msg,		0,				VAR_RATE|VAR_NOLHUB, NULL, NULL},
+ {"flood-ctcp",		&flood_ctcp,		0,				VAR_RATE|VAR_NOLHUB, NULL, NULL},
  {"fork-interval",	&fork_interval,		0,				VAR_INT, NULL, NULL},
  {"hijack",		&hijack,		0,				VAR_INT|VAR_DETECTED|VAR_PERM, NULL, NULL},
  {"in-bots",		&in_bots,		0,				VAR_INT|VAR_NOLOC, NULL, NULL},

+ 0 - 1
src/set.h

@@ -2,7 +2,6 @@
 #define _SET_H
 
 #include <sys/types.h>
-#include "set.h"
 
 #define var_type_name(x) (x & VAR_DETECTED) ? "detect" : (x & VAR_INT) ? "int" : (x & VAR_LIST) ? "list" : \
                          (x & VAR_STRING) ? "string" : (x & VAR_RATE) ? "rate" : (x & VAR_BOOL) ? "bool" : ""