[eggheads-patches] PATCH:expired.patch

Axel Franke eule at berlin.snafu.de
Sun Oct 22 19:44:00 CST 2000


Hi,

This patch should fix the force-expire-problem
(bug 118 found by Abraham).
Before this patch was the force-expire set complete missing for 
permanent(bans/exempts/invites) with expire-time. Only present was 
this set in check_expired_chanstuff, ie. for modes the in the channel 
present. I don't like, if in all expired-functions the same 
force-expire-code present, therefore only one new function for this 
and remove the old-checks. But this is not a simple move the 
old-forceexpire check to a new function, because the oldcheck was 
buugy (missing check for nickchange, m->user==NULL...)

And other points:
-in check_expired_chanstuff move all the expired-sections in only one 
for (chan = chanset;...-loop
-check for channel +i now before the invite-loop, remove the logline:
...Channel invitation %s NOT expired. Invite still set!...

and in check_expired_invites:
    if (!((*u)->flags & MASKREC_PERM) && (now >= (*u)->expire)
      && !(chan->channel.mode & CHANINV))
This was not in a channel-loop, if this channel always +i will the 
global-invites-expired never work, therefore remove 
!(chan->channel.mode & CHANINV).
Still present is this check before call add_mode, ie. the expired for 
permanentinvites will always work, but the bot will sent a mode -I 
only if this channel not +i (and see force-expire).

Greeting Eule

-------------- next part --------------
diff -ur eggdrop1.5/src/mod/channels.mod/channels.c eggneu/src/mod/channels.mod/channels.c
--- eggdrop1.5/src/mod/channels.mod/channels.c	Mon Oct 23 00:34:12 2000
+++ eggneu/src/mod/channels.mod/channels.c	Mon Oct 23 00:36:57 2000
@@ -862,6 +862,7 @@
   (Function) initudef,
   (Function) ngetudef,
   /* 44 - 47 */
+  (Function) expired_mask,
 };
 
 char *channels_start(Function * global_funcs)
diff -ur eggdrop1.5/src/mod/channels.mod/channels.h eggneu/src/mod/channels.mod/channels.h
--- eggdrop1.5/src/mod/channels.mod/channels.h	Wed Oct 18 03:12:26 2000
+++ eggneu/src/mod/channels.mod/channels.h	Wed Oct 18 14:36:52 2000
@@ -106,6 +106,7 @@
 static void setudef(struct udef_struct *, char *, int);
 static void remove_channel(struct chanset_t *);
 static int ngetudef(char *, char *);
+static int expired_mask(struct chanset_t *chan, char *who);
 
 #else
 
@@ -160,6 +161,7 @@
 #define initudef ((void(*)(int, char *,int))channels_funcs[42])
 #define ngetudef ((int(*)(char *, char *))channels_funcs[43])
 /* 44 - 47 */
+#define expired_mask ((int (*)(struct chanset_t *, char *))channels_funcs[44])
 
 #endif				/* MAKING_CHANNELS */
 
diff -ur eggdrop1.5/src/mod/channels.mod/userchan.c eggneu/src/mod/channels.mod/userchan.c
--- eggdrop1.5/src/mod/channels.mod/userchan.c	Wed Oct 18 03:12:26 2000
+++ eggneu/src/mod/channels.mod/userchan.c	Sun Oct 22 23:30:46 2000
@@ -1234,23 +1234,62 @@
   write_channels();
 }
 
+static int expired_mask(struct chanset_t *chan, char *who)
+{
+  memberlist *m, *m2;
+  char s[UHOSTLEN], *snick, *sfrom;
+  struct userrec *u;
+
+  strcpy(s, who);
+  sfrom = s;
+  snick = splitnick(&sfrom);
+	  
+  if (force_expire || !snick[0])
+    return 1;
+  
+  m = ismember(chan, snick);
+  if (!m)
+    for (m2 = chan->channel.member; m2 && m2->nick[0]; m2 = m2->next)
+      if (!egg_strcasecmp(sfrom, m2->userhost)) {
+	m = m2;
+	break;
+      }
+
+  if (!m || !chan_hasop(m) || !rfc_casecmp(m->nick, botname))
+    return 1;
+
+  if (m->user)
+    u = m->user;
+  else {
+    simple_sprintf(s, "%s!%s", m->nick, m->userhost);
+    u = get_user_by_host(s);
+  }
+  if (u->flags & USER_BOT)
+    return 0;
+  else
+    return 1;
+}
+
 /* Check for expired timed-bans.
  */
 static void check_expired_bans(void)
 {
   maskrec **u;
   struct chanset_t *chan;
+  masklist *b;
 
   u = &global_bans;
   while (*u) {
     if (!((*u)->flags & MASKREC_PERM) && (now >= (*u)->expire)) {
       putlog(LOG_MISC, "*", "%s %s (%s)", BANS_NOLONGER,
 	     (*u)->mask, MISC_EXPIRED);
-      chan = chanset;
-      while (chan != NULL) {
-	add_mode(chan, '-', 'b', (*u)->mask);
-	chan = chan->next;
-      }
+      for (chan = chanset; chan; chan = chan->next)
+	for (b = chan->channel.ban; b->mask[0]; b = b->next)
+	  if (!rfc_casecmp(b->mask, (*u)->mask) &&
+	      expired_mask(chan, b->who) && b->timer != now) {
+	    add_mode(chan, '-', 'b', (*u)->mask);
+	    b->timer = now;
+	  }
       u_delban(NULL, (*u)->mask, 1);
     } else
       u = &((*u)->next);
@@ -1262,7 +1301,12 @@
       if (!((*u)->flags & MASKREC_PERM) && (now >= (*u)->expire)) {
 	putlog(LOG_MISC, "*", "%s %s %s %s (%s)", BANS_NOLONGER,
 	       (*u)->mask, MISC_ONLOCALE, chan->dname, MISC_EXPIRED);
-	add_mode(chan, '-', 'b', (*u)->mask);
+	for (b = chan->channel.ban; b->mask[0]; b = b->next)
+	  if (!rfc_casecmp(b->mask, (*u)->mask) &&
+	      expired_mask(chan, b->who) && b->timer != now) {
+	    add_mode(chan, '-', 'b', (*u)->mask);
+	    b->timer = now;
+	  }
 	u_delban(chan, (*u)->mask, 1);
       } else
 	u = &((*u)->next);
@@ -1276,7 +1320,7 @@
 {
   maskrec **u;
   struct chanset_t *chan;
-  masklist *b;
+  masklist *b, *e;
   int match;
   
   if (!use_exempts)
@@ -1286,8 +1330,7 @@
     if (!((*u)->flags & MASKREC_PERM) && (now >= (*u)->expire)) {
       putlog(LOG_MISC, "*", "%s %s (%s)", EXEMPTS_NOLONGER,
 	     (*u)->mask, MISC_EXPIRED);
-      chan = chanset;
-      while (chan != NULL) {
+      for (chan = chanset; chan; chan = chan->next) {
         match = 0;
         b = chan->channel.ban;
         while (b->mask[0] && !match) {
@@ -1301,9 +1344,13 @@
           putlog(LOG_MISC, chan->dname,
             "Exempt not expired on channel %s. Ban still set!",
             chan->dname);
-        else
-          add_mode(chan, '-', 'e', (*u)->mask);
-	    chan = chan->next;
+	else
+	  for (e = chan->channel.exempt; e->mask[0]; e = e->next)
+	    if (!rfc_casecmp(e->mask, (*u)->mask) &&
+		expired_mask(chan, e->who) && e->timer != now) {
+	      add_mode(chan, '-', 'e', (*u)->mask);
+	      e->timer = now;
+	    }
       }
       u_delexempt(NULL,(*u)->mask,1);
     } else
@@ -1330,7 +1377,12 @@
         else {
           putlog(LOG_MISC, "*", "%s %s %s %s (%s)", EXEMPTS_NOLONGER,
 		 (*u)->mask, MISC_ONLOCALE, chan->dname, MISC_EXPIRED);
-          add_mode(chan, '-', 'e', (*u)->mask);
+	  for (e = chan->channel.exempt; e->mask[0]; e = e->next)
+	    if (!rfc_casecmp(e->mask, (*u)->mask) &&
+		expired_mask(chan, e->who) && e->timer != now) {
+	      add_mode(chan, '-', 'e', (*u)->mask);
+	      e->timer = now;
+	    }
           u_delexempt(chan,(*u)->mask,1);
         }
       }
@@ -1344,21 +1396,24 @@
 static void check_expired_invites(void)
 {
   maskrec **u;
-  struct chanset_t *chan = chanset;
+  struct chanset_t *chan;
+  masklist *b;
 
   if (!use_invites)
     return;
   u = &global_invites;
   while (*u) {
-    if (!((*u)->flags & MASKREC_PERM) && (now >= (*u)->expire)
-      && !(chan->channel.mode & CHANINV)) {
+    if (!((*u)->flags & MASKREC_PERM) && (now >= (*u)->expire)) {
       putlog(LOG_MISC, "*", "%s %s (%s)", INVITES_NOLONGER,
 	     (*u)->mask, MISC_EXPIRED);
-      chan = chanset;
-      while (chan != NULL && !(chan->channel.mode & CHANINV)) {
- 	add_mode(chan, '-', 'I', (*u)->mask);
- 	chan = chan->next;
-      }
+      for (chan = chanset; chan; chan = chan->next)
+	if (!(chan->channel.mode & CHANINV))
+	  for (b = chan->channel.invite; b->mask[0]; b = b->next)
+	    if (!rfc_casecmp(b->mask, (*u)->mask) &&
+		expired_mask(chan, b->who) && b->timer != now) {
+	      add_mode(chan, '-', 'I', (*u)->mask);
+	      b->timer = now;
+	    }
       u_delinvite(NULL,(*u)->mask,1);
     } else
       u = &((*u)->next);
@@ -1370,7 +1425,13 @@
       if (!((*u)->flags & MASKREC_PERM) && (now >= (*u)->expire)) {
 	putlog(LOG_MISC, "*", "%s %s %s %s (%s)", INVITES_NOLONGER,
 	       (*u)->mask, MISC_ONLOCALE, chan->dname, MISC_EXPIRED);
-        add_mode(chan, '-', 'I', (*u)->mask);
+	if (!(chan->channel.mode & CHANINV))
+	  for (b = chan->channel.invite; b->mask[0]; b = b->next)
+	    if (!rfc_casecmp(b->mask, (*u)->mask) &&
+		expired_mask(chan, b->who) && b->timer != now) {
+	      add_mode(chan, '-', 'I', (*u)->mask);
+	      b->timer = now;
+	    }
 	u_delinvite(chan, (*u)->mask,1);
       } else
 	u = &((*u)->next);
diff -ur eggdrop1.5/src/mod/irc.mod/irc.c eggneu/src/mod/irc.mod/irc.c
--- eggdrop1.5/src/mod/irc.mod/irc.c	Wed Oct 18 03:16:10 2000
+++ eggneu/src/mod/irc.mod/irc.c	Sat Oct 21 21:58:23 2000
@@ -580,7 +580,7 @@
 {
   masklist *b, *e;
   memberlist *m, *n;
-  char s[UHOSTLEN], *snick, *sfrom;
+  char s[UHOSTLEN];
   struct chanset_t *chan;
   struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
   static int count = 4;
@@ -589,159 +589,111 @@
   if (!server_online)
     return;
   for (chan = chanset; chan; chan = chan->next) {
-    if (!(chan->status & (CHAN_ACTIVE | CHAN_PEND)) &&
-	!channel_inactive(chan) &&
-	server_online)
-      dprintf(DP_MODE, "JOIN %s %s\n",
-              (chan->name[0]) ? chan->name : chan->dname,
-              chan->channel.key[0] ? chan->channel.key : chan->key_prot);      
-    if ((chan->status & (CHAN_ACTIVE | CHAN_PEND)) &&
-	channel_inactive(chan))
-      dprintf(DP_MODE, "PART %s\n", chan->name);
-    if (channel_dynamicbans(chan) &&
-	me_op(chan) &&
-	!channel_inactive(chan) &&
-	ismember(chan, botname)) {
-      for (b = chan->channel.ban; b->mask[0]; b = b->next) {
-	if (ban_time != 0 && (((now - b->timer) > (60 * ban_time)) &&
-				!u_sticky_mask(chan->bans, b->mask) &&
-				!u_sticky_mask(global_bans, b->mask))) {
-	  strcpy(s, b->who);
-	  sfrom = s;
-	  snick = splitnick(&sfrom);
-	  
-	  if (force_expire ||
-	      !(snick[0] && egg_strcasecmp(sfrom, botuserhost) &&
-		(m = ismember(chan, snick)) &&
-		m->user && (m->user->flags & USER_BOT) && chan_hasop(m))) {
-	    putlog(LOG_MODES, chan->dname,
-		   "(%s) Channel ban on %s expired.",
-		   chan->dname, b->mask);
-	    add_mode(chan, '-', 'b', b->mask);
-	    b->timer = now;
-	  }
-	}
-      }
-    }
-    if (use_exempts == 1 && channel_dynamicexempts(chan) && me_op(chan))
-      for (e = chan->channel.exempt; e->mask[0]; e = e->next) {
-	if (exempt_time != 0 && ((now - e->timer) > (60 * exempt_time) &&
-	    !u_sticky_mask(chan->exempts, e->mask) && 
-	    !u_sticky_mask(global_exempts, e->mask))) {
-	  strcpy(s, e->who);
-	  sfrom = s;
-	  snick = splitnick(&sfrom);
-	  if (force_expire ||
-	      !(snick[0] && egg_strcasecmp(sfrom, botuserhost) &&
-		(m = ismember(chan, snick)) &&
-		m->user && (m->user->flags & USER_BOT) && chan_hasop(m))) {
-	    /* Check to see if it matches a ban */
-	    int match = 0;
-
-	    for (b = chan->channel.ban; b->mask[0]; b = b->next) {
-	      if (wild_match(b->mask, e->mask) ||
-		  wild_match(e->mask, b->mask)) {
-		match = 1;
-		break;
-	      }
-	    }
-	    /* Leave this extra logging in for now. Can be removed later
-	     * Jason
-	     */
-	    if (match) {
+    if (channel_active(chan)) {
+      if (me_op(chan)) {
+	if (channel_dynamicbans(chan) && ban_time)
+	  for (b = chan->channel.ban; b->mask[0]; b = b->next)
+	    if (now - b->timer > 60 * ban_time &&
+		!u_sticky_mask(chan->bans, b->mask) &&
+		!u_sticky_mask(global_bans, b->mask) &&
+		expired_mask(chan, b->who)) {
 	      putlog(LOG_MODES, chan->dname,
-		     "(%s) Channel exemption %s NOT expired. Exempt still set!",
-		     chan->dname, e->mask);
-	    } else {
-	      putlog(LOG_MODES, chan->dname,
-		     "(%s) Channel exemption on %s expired.",
-		     chan->dname, e->mask);
-	      add_mode(chan, '-', 'e', e->mask);
+		     "(%s) Channel ban on %s expired.",
+		     chan->dname, b->mask);
+	      add_mode(chan, '-', 'b', b->mask);
+	      b->timer = now;
 	    }
-	    e->timer = now;
-	  }
-	}
-      }
 
-    if (use_invites == 1 && channel_dynamicinvites(chan) && me_op(chan))
-      for (b = chan->channel.invite; b->mask[0]; b = b->next) {
-	if ((invite_time != 0) &&
-	    (((now - b->timer) > (60 * invite_time)) &&
-	     !u_sticky_mask(chan->invites, b->mask) && 
-	     !u_sticky_mask(global_invites, b->mask))) {
- 	  strcpy(s, b->who);
-	  sfrom = s;
-	  snick = splitnick(&sfrom);
+	if (use_exempts && channel_dynamicexempts(chan) && exempt_time)
+	  for (e = chan->channel.exempt; e->mask[0]; e = e->next)
+	    if (now - e->timer > 60 * exempt_time &&
+		!u_sticky_mask(chan->exempts, e->mask) && 
+		!u_sticky_mask(global_exempts, e->mask) &&
+		expired_mask(chan, e->who)) {
+	      /* Check to see if it matches a ban */
+	      int match = 0;
 
-	  if (force_expire ||
-	      !(snick[0] && egg_strcasecmp(sfrom, botuserhost) &&
-		(m = ismember(chan, snick)) &&
-		m->user && (m->user->flags & USER_BOT) && chan_hasop(m))) {
-	    if ((chan->channel.mode & CHANINV) &&
-		isinvited(chan, b->mask)) {
+	      for (b = chan->channel.ban; b->mask[0]; b = b->next)
+		if (wild_match(b->mask, e->mask) ||
+		    wild_match(e->mask, b->mask)) {
+		  match = 1;
+		  break;
+	      }
 	      /* Leave this extra logging in for now. Can be removed later
 	       * Jason
 	       */
-	      putlog(LOG_MODES, chan->dname,
-                    "(%s) Channel invitation %s NOT expired. Invite still set!",
-		     chan->dname, b->mask);
-	    } else {
+	      if (match) {
+		putlog(LOG_MODES, chan->dname,
+		       "(%s) Channel exemption %s NOT expired. Exempt still set!",
+		       chan->dname, e->mask);
+	      } else {
+		putlog(LOG_MODES, chan->dname,
+		       "(%s) Channel exemption on %s expired.",
+		       chan->dname, e->mask);
+		add_mode(chan, '-', 'e', e->mask);
+	      }
+	      e->timer = now;
+	    }
+
+	if (use_invites && channel_dynamicinvites(chan) &&
+	    invite_time && !(chan->channel.mode & CHANINV))
+	  for (b = chan->channel.invite; b->mask[0]; b = b->next)
+	    if (now - b->timer > 60 * invite_time &&
+		!u_sticky_mask(chan->invites, b->mask) && 
+		!u_sticky_mask(global_invites, b->mask) &&
+		expired_mask(chan, b->who)) {
 	      putlog(LOG_MODES, chan->dname,
 		     "(%s) Channel invitation on %s expired.",
 		     chan->dname, b->mask);
 	      add_mode(chan, '-', 'I', b->mask);
+	      b->timer = now;
+	    }
+
+	if (chan->idle_kick)
+	  for (m = chan->channel.member; m && m->nick[0]; m = m->next)
+	    if (now - m->last >= chan->idle_kick * 60 &&
+		!match_my_nick(m->nick) && !chan_issplit(m)) {
+	      sprintf(s, "%s!%s", m->nick, m->userhost);
+	      get_user_flagrec(m->user ? m->user : get_user_by_host(s),
+			       &fr, chan->dname);
+	      if (!(glob_bot(fr) || glob_friend(fr) ||
+		    (glob_op(fr) && !chan_deop(fr)) ||
+		    chan_friend(fr) || chan_op(fr))) {
+		dprintf(DP_SERVER, "KICK %s %s :idle %d min\n", chan->name,
+			m->nick, chan->idle_kick);
+		m->flags |= SENTKICK;
+	      }
 	    }
-	    b->timer = now;
-	  }
-	}
       }
-    m = chan->channel.member;
-    while (m && m->nick[0]) {
-      if (m->split) {
+      m = chan->channel.member;
+      while (m && m->nick[0]) {
 	n = m->next;
-	if (!channel_active(chan))
-	  killmember(chan, m->nick);
-	else if ((now - m->split) > wait_split) {
+	if (m->split && now - m->split > wait_split) {
 	  sprintf(s, "%s!%s", m->nick, m->userhost);
-	  m->user = get_user_by_host(s);
-	  check_tcl_sign(m->nick, m->userhost, m->user, chan->dname,
-			 "lost in the netsplit");
+	  check_tcl_sign(m->nick, m->userhost,
+			 m->user ? m->user : get_user_by_host(s),
+			 chan->dname, "lost in the netsplit");
 	  putlog(LOG_JOIN, chan->dname,
 		 "%s (%s) got lost in the net-split.",
 		 m->nick, m->userhost);
 	  killmember(chan, m->nick);
 	}
 	m = n;
-      } else
-	m = m->next;
+      }
+      check_lonely_channel(chan);
+      if (chan->channel.members == 1)
+	ok = 1;
     }
-    if (channel_active(chan) && me_op(chan) && chan->idle_kick)
-      for (m = chan->channel.member; m && m->nick[0]; m = m->next)
-	if ((now - m->last) >= (chan->idle_kick * 60) &&
-	    !match_my_nick(m->nick) && !chan_issplit(m)) {
-	  sprintf(s, "%s!%s", m->nick, m->userhost);
-	  m->user = get_user_by_host(s);
-	  get_user_flagrec(m->user, &fr, chan->dname);
-	  if (!(glob_bot(fr) || glob_friend(fr) ||
-		(glob_op(fr) && !glob_deop(fr)) ||
-		chan_friend(fr) || chan_op(fr))) {
-	    dprintf(DP_SERVER, "KICK %s %s :idle %d min\n", chan->name,
-		    m->nick, chan->idle_kick);
-	    m->flags |= SENTKICK;
-	  }
-	}
-    check_lonely_channel(chan);
+    else if (!channel_inactive(chan) && !channel_pending(chan))
+      dprintf(DP_MODE, "JOIN %s %s\n",
+              (chan->name[0]) ? chan->name : chan->dname,
+              chan->channel.key[0] ? chan->channel.key : chan->key_prot);
   }
-  if (min_servs > 0) {
-    for (chan = chanset; chan; chan = chan->next)
-      if (channel_active(chan) && (chan->channel.members == 1))
-	ok = 1;
-    if (ok) {
-      count++;
-      if (count >= 5) {
-	dprintf(DP_SERVER, "LUSERS\n");
-	count = 0;
-      }
+  if (min_servs && ok) {
+    count++;
+    if (count >= 5) {
+      dprintf(DP_SERVER, "LUSERS\n");
+      count = 0;
     }
   }
 }


More information about the Patches mailing list