Răsfoiți Sursa

* Added rate var 'flood-g' which will set +g for 60 seconds after this many msgs:sec has been detected. (#74)

svn: 2172
Bryan Drewery 21 ani în urmă
părinte
comite
0f0d37bbd8
5 a modificat fișierele cu 41 adăugiri și 1 ștergeri
  1. 1 0
      doc/UPDATES
  2. 1 0
      misc/help.txt
  3. 2 1
      src/mod/server.mod/server.h
  4. 36 0
      src/mod/server.mod/servmsg.c
  5. 1 0
      src/set.c

+ 1 - 0
doc/UPDATES

@@ -153,6 +153,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Added rate vars 'flood-msg' and 'flood-ctcp' to control how quickly a bot ignores on flood.
 * Fixed cosmetic bug with removing ignores.
 * cmd_dump now has a substitution. '$n' is replaced with the bot's current IRC nick.
+* Added rate var 'flood-g' which will set +g for 60 seconds after this many msgs:sec has been detected. (#74)
 
 1.2.2
 * Don't sanity check flags for users on DCC CHAT if they are on the bot via .botcmd.

+ 1 - 0
misc/help.txt

@@ -1509,6 +1509,7 @@ See also: reload, backup
                           (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) 
+[R]  $bflood-g$b         Msgs:Secs until triggering to set +g for 60 seconds (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.

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

@@ -54,7 +54,8 @@ 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;
+extern rate_t		flood_msg, flood_ctcp, flood_g;
+
 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)

+ 36 - 0
src/mod/server.mod/servmsg.c

@@ -316,6 +316,18 @@ char ctcp_reply[1024] = "";
 static int lastmsgs[FLOOD_GLOBAL_MAX];
 static char lastmsghost[FLOOD_GLOBAL_MAX][128];
 static time_t lastmsgtime[FLOOD_GLOBAL_MAX];
+static int dronemsgs;
+static time_t dronemsgtime;
+static bool set_pls_g;
+static time_t flood_g_time = 60;
+
+rate_t flood_g = { 6, 2 };
+
+void unset_g(int data)
+{
+  dprintf(DP_MODE, "MODE %s :-g\n", botname);
+  set_pls_g = 0;
+}
 
 /* Do on NICK, PRIVMSG, NOTICE and JOIN.
  */
@@ -352,6 +364,30 @@ static bool detect_flood(char *floodnick, char *floodhost, char *from, int which
     return 0;
   if (!egg_strcasecmp(floodhost, botuserhost))
     return 0;			/* My user@host (?) */
+
+  //FIXME: hack for +g 
+
+  if (dronemsgtime < now - flood_g.time) {	//expired, reset counter
+    dronemsgs = 0;
+//    dronemsgtime = now;
+  }
+
+  dronemsgs++;
+  dronemsgtime = now;
+
+  if (!set_pls_g && dronemsgs >= flood_g.count) {  //flood from dronenet, let's attempt to set +g
+    egg_timeval_t howlong;
+
+    set_pls_g = 1;
+    dronemsgs = 0;
+    dronemsgtime = 0;
+    dprintf(DP_DUMP, "MODE %s :+g\n", botname);
+    howlong.sec = flood_g_time;
+    howlong.usec = 0;
+    timer_create(&howlong, "Unset umode +g", (Function) unset_g);
+    putlog(LOG_MISC, "*", "Drone flood detected! Setting +g for %li seconds.", flood_g_time);
+  }
+
   p = strchr(floodhost, '@');
   if (p) {
     p++;

+ 1 - 0
src/set.c

@@ -61,6 +61,7 @@ static variable_t vars[] = {
  {"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},
+ {"flood-g",		&flood_g,		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},