[eggheads-patches] PATCH: banbounce.patch

Fabian Knittel fknittel at gmx.de
Tue Oct 12 11:14:33 CST 1999


[ banbounce.patch ]

This patch tries to get rid of the ping-pong playing in
bot-nets, if all place the same invite, ban, exempt or
ignore at the same time.

Normally, if a new ban matches an old ban, the old one
is removed and then the new one added. This is also sent
to all sharing bots. My guess is that under certain
circumstances, this made all bots add and remove tha same
ban over and over again. I couldn't reproduce this though,
as my botnet doesn't lag at all and all bots are on the
same machine.

Old behaviour:

  if oldban->mask = newban->mask
    remove oldban
  add newban

New behaviour:

  if oldban->mask = newban->mask {
    if (newban->type == PERM) && (oldban->type == PERM) {
      return
    }
    if (oldban->type != PERM) {
      return
    }
    remove oldban
  }
  add newban

[ you may replace "ban" with "invite", "exempt" or "ignore" ]

I already posted this to the people who reported the problem
and could reproduce it, as well as to eggheads, but I received
no real feedback yet, so please don't apply the patch right
away..

Fabian
-------------- next part --------------
diff -urN eggdrop1.3~/doc/UPDATES1.3 eggdrop1.3/doc/UPDATES1.3
--- eggdrop1.3~/doc/UPDATES1.3	Mon Oct 11 23:30:30 1999
+++ eggdrop1.3/doc/UPDATES1.3	Tue Oct 12 14:34:10 1999
@@ -4,6 +4,8 @@
 
 1.3.29
 Foundby   Fixedby   What....
+Ben	  Fabian    only removes bans/exempts/invites/ignores if the existing
+		    mask is of lower priority than the newer one
 	  Fabian    the language table is now always first loaded with english
 		    rather than the more preferred languages
 	  drummer   Adds ismodeline macros.
diff -urN eggdrop1.3~/src/mod/channels.mod/userchan.c eggdrop1.3/src/mod/channels.mod/userchan.c
--- eggdrop1.3~/src/mod/channels.mod/userchan.c	Tue Oct 12 17:30:24 1999
+++ eggdrop1.3/src/mod/channels.mod/userchan.c	Tue Oct 12 16:26:59 1999
@@ -381,6 +381,7 @@
   maskrec **u = chan ? &chan->bans : &global_bans;
   char host[1024], s[1024];
   module_entry *me;
+  int type;
 
   strcpy(host, ban);
   /* choke check: fix broken bans (must have '!' and '@') */
@@ -405,8 +406,6 @@
     putlog(LOG_MISC, "*", IRC_IBANNEDME);
     return 0;
   }
-  if (u_equals_mask(*u, host))
-    u_delban(chan, host, 1);	/* remove old ban */
   /* it shouldn't expire and be sticky also */
   if (note[0] == '*') {
     flags |= MASKREC_STICKY;
@@ -416,9 +415,17 @@
     flags |= MASKREC_PERM;
     expire_time = 0L;
   }
+
+  /* We only need to remove the old ban, if it's of lower priority
+   * than the new ban. Else, we just keep the old one and exit */
+  type = u_equals_mask(*u, host);
+  if ((type == 1) && (flags & MASKREC_PERM))
+    u_delban(chan, host, 1);
+  else if (type)
+    return 0;
+
   /* new format: */
   p = user_malloc(sizeof(maskrec));
-
   p->next = *u;
   *u = p;
   p->expire = expire_time;
@@ -453,6 +460,7 @@
   maskrec ** u = chan ? &chan->invites : &global_invites;
   char host[1024], s[1024];
   module_entry * me;
+  int type;
   
   strcpy(host, invite);
   /* choke check: fix broken invites (must have '!' and '@') */
@@ -473,8 +481,6 @@
   else
     simple_sprintf(s, "%s!%s@%s", origbotname, botuser, hostname);
   
-  if (u_equals_mask(*u, host))
-    u_delinvite(chan, host,1);	/* remove old invite */
   /* it shouldn't expire and be sticky also */
   if (note[0] == '*') {
     flags |= MASKREC_STICKY;
@@ -484,6 +490,15 @@
     flags &= ~MASKREC_STICKY;
   else
     flags |= MASKREC_PERM;
+
+  /* We only need to remove the old invite, if it's of lower priority
+   * than the new invite. Else, we just keep the old one and exit */
+  type = u_equals_mask(*u, host);
+  if ((type == 1) && (flags & MASKREC_PERM))
+    u_delinvite(chan, host, 1);
+  else if (type)
+    return 0;
+
   /* new format: */
   p = user_malloc(sizeof(maskrec));
   p->next = *u;
@@ -520,6 +535,7 @@
   maskrec ** u = chan ? &chan->exempts : &global_exempts;
   char host[1024], s[1024];
   module_entry * me;
+  int type;
   
   strcpy(host, exempt);
   /* choke check: fix broken exempts (must have '!' and '@') */
@@ -540,8 +556,6 @@
   else
     simple_sprintf(s, "%s!%s@%s", origbotname, botuser, hostname);
   
-  if (u_equals_mask(*u, host))
-    u_delexempt(chan, host,1);	/* remove old exempt */
   /* it shouldn't expire and be sticky also */
   if (note[0] == '*') {
     flags |= MASKREC_STICKY;
@@ -551,6 +565,15 @@
     flags &= ~MASKREC_STICKY;
   else
     flags |= MASKREC_PERM;
+
+  /* We only need to remove the old invite, if it's of lower priority
+   * than the new invite. Else, we just keep the old one and exit */
+  type = u_equals_mask(*u, host);
+  if ((type == 1) && (flags & MASKREC_PERM))
+    u_delexempt(chan, host, 1);
+  else if (type)
+    return 0;
+
   /* new format: */
   p = user_malloc(sizeof(maskrec));
   p->next = *u;
diff -urN eggdrop1.3~/src/users.c eggdrop1.3/src/users.c
--- eggdrop1.3~/src/users.c	Tue Oct 12 17:30:24 1999
+++ eggdrop1.3/src/users.c	Tue Oct 12 16:26:59 1999
@@ -112,9 +112,15 @@
 void addignore(char *ign, char *from, char *mnote, time_t expire_time)
 {
   struct igrec *p;
+  int type;
 
-  if (equals_ignore(ign))
+  /* if the old ignore is not permanent and the new one is,
+   * remove the old one and add the new one, else quit.*/
+  type = equals_ignore(ign);
+  if ((type == 1) && !expire_time)
     delignore(ign);		/* remove old ignore */
+  else if (type)
+    return;
   p = user_malloc(sizeof(struct igrec));
 
   p->next = global_ign;


More information about the Patches mailing list