Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Mon, 17 Apr 2000 19:01:35 +0000 (19:01 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Mon, 17 Apr 2000 19:01:35 +0000 (19:01 +0000)
Log message:

local deactivation of jupes and glines

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@186 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/gline.h
include/jupe.h
ircd/gline.c
ircd/jupe.c

index b1ec2e7678d7018a42b694b34ddab79b2edbb1e6..df57877bcbe12f1eb4822ea081b5396803ee0e39 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2000-04-17  Kevin L. Mitchell  <klmitch@mit.edu>
 
+       * ircd/jupe.c: support local deactivations of jupes
+
+       * ircd/gline.c: support local deactivations of glines
+
+       * include/jupe.h: JUPE_LDEACT allows jupes to be locally
+       deactivated; if they aren't locally deactivated, then it slaves to
+       the net-wide activation status; JupeIsRemActive() tests only
+       whether the jupe is active everywhere else
+
+       * include/gline.h: GLINE_LDEACT allows glines to be locally
+       deactivated; if they aren't locally deactivated, then it slaves to
+       the net-wide activation status; GlineIsRemActive() tests only
+       whether the gline is active everywhere else
+
        * ircd/gline.c: detect overlapping G-lines; if an existing, wider
        gline expires after the new one will, we drop the new one,
        otherwise we add the G-line after that one (so the wide one will
 #
 # ChangeLog for ircu2.10.11
 #
-# $Id: ChangeLog,v 1.93 2000-04-17 17:07:01 kev Exp $
+# $Id: ChangeLog,v 1.94 2000-04-17 19:01:35 kev Exp $
 #
 # Insert new changes at beginning of the change list.
 #
index 7763063eadc4320054674ebb940bd3384e0c0c67..24090168b0502ad96423292f8aa496282cfe6dc1 100644 (file)
@@ -53,10 +53,14 @@ struct Gline {
 #define GLINE_ANY      0x0010
 #define GLINE_FORCE    0x0020
 #define GLINE_EXACT    0x0040
+#define GLINE_LDEACT   0x0080  /* locally deactivated */
 
 #define GLINE_MASK     (GLINE_ACTIVE | GLINE_BADCHAN | GLINE_LOCAL)
+#define GLINE_ACTMASK  (GLINE_ACTIVE | GLINE_LDEACT)
 
-#define GlineIsActive(g)       ((g)->gl_flags & GLINE_ACTIVE)
+#define GlineIsActive(g)       (((g)->gl_flags & GLINE_ACTMASK) == \
+                                GLINE_ACTIVE)
+#define GlineIsRemActive(g)    ((g)->gl_flags & GLINE_ACTIVE)
 #define GlineIsIpMask(g)       ((g)->gl_flags & GLINE_IPMASK)
 #define GlineIsBadChan(g)      ((g)->gl_flags & GLINE_BADCHAN)
 #define GlineIsLocal(g)                ((g)->gl_flags & GLINE_LOCAL)
index 4aeda46fd942611e9f1c8a9c5c48fe093c410c78..f5efe9deebd2fbc9ea7baef1f4e4fe080a6cb87b 100644 (file)
@@ -45,10 +45,15 @@ struct Jupe {
   unsigned int   ju_flags;
 };
 
-#define JUPE_ACTIVE    1
-#define JUPE_LOCAL     2
+#define JUPE_ACTIVE    0x0001
+#define JUPE_LOCAL     0x0002
+#define JUPE_LDEACT    0x0004  /* locally deactivated */
 
-#define JupeIsActive(j)                ((j)->ju_flags & JUPE_ACTIVE)
+#define JUPE_MASK      (JUPE_ACTIVE | JUPE_LOCAL)
+#define JUPE_ACTMASK   (JUPE_ACTIVE | JUPE_LDEACT)
+
+#define JupeIsActive(j)                (((j)->ju_flags & JUPE_ACTMASK) == JUPE_ACTIVE)
+#define JupeIsRemActive(j)     ((j)->ju_flags & JUPE_ACTIVE)
 #define JupeIsLocal(j)         ((j)->ju_flags & JUPE_LOCAL)
 
 #define JupeServer(j)          ((j)->ju_server)
index bdc50dfe9b0b8ae88e0f5e6115f4ba5ef6e370ef..06524614e82b0b2f53d6f2e8d769be6c623eec83 100644 (file)
@@ -178,14 +178,14 @@ propagate_gline(struct Client *cptr, struct Client *sptr, struct Gline *gline)
 
   if (gline->gl_lastmod)
     sendcmdto_serv_butone(cptr, CMD_GLINE, sptr, "* %c%s%s%s %Tu %Tu :%s",
-                         GlineIsActive(gline) ? '+' : '-', gline->gl_user,
+                         GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
                          GlineIsBadChan(gline) ? "" : "@",
                          GlineIsBadChan(gline) ? "" : gline->gl_host,
                          gline->gl_expire - CurrentTime, gline->gl_lastmod,
                          gline->gl_reason);
   else
     sendcmdto_serv_butone(cptr, CMD_GLINE, sptr, "* %c%s%s%s %Tu :%s",
-                         GlineIsActive(gline) ? '+' : '-', gline->gl_user,
+                         GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
                          GlineIsBadChan(gline) ? "" : "@",
                          GlineIsBadChan(gline) ? "" : gline->gl_host,
                          gline->gl_expire - CurrentTime, gline->gl_reason);
@@ -276,15 +276,29 @@ int
 gline_activate(struct Client *cptr, struct Client *sptr, struct Gline *gline,
               time_t lastmod, unsigned int flags)
 {
+  unsigned int saveflags = 0;
+
   assert(0 != gline);
   assert(!GlineIsLocal(gline));
 
-  gline->gl_flags |= GLINE_ACTIVE;
+  if (flags & GLINE_LOCAL)
+    sendto_ops("gline_activate called with GLINE_LOCAL");
 
-  if (gline->gl_lastmod >= lastmod) /* force lastmod to increase */
-    gline->gl_lastmod++;
-  else
-    gline->gl_lastmod = lastmod;
+  saveflags = gline->gl_flags;
+
+  if (flags & GLINE_LOCAL)
+    gline->gl_flags &= ~GLINE_LDEACT;
+  else {
+    gline->gl_flags |= GLINE_ACTIVE;
+
+    if (gline->gl_lastmod >= lastmod) /* force lastmod to increase */
+      gline->gl_lastmod++;
+    else
+      gline->gl_lastmod = lastmod;
+  }
+
+  if ((saveflags & GLINE_ACTMASK) == GLINE_ACTIVE)
+    return 0; /* was active to begin with */
 
   /* Inform ops and log it */
   sendto_op_mask(SNO_GLINE, "%s activating global %s for %s%s%s, expiring at "
@@ -322,15 +336,29 @@ int
 gline_deactivate(struct Client *cptr, struct Client *sptr, struct Gline *gline,
                 time_t lastmod, unsigned int flags)
 {
+  unsigned int saveflags = 0;
+
   assert(0 != gline);
 
+  if (flags & GLINE_LOCAL)
+    sendto_ops("gline_deactivate called with GLINE_LOCAL");
+
+  saveflags = gline->gl_flags;
+
   if (!GlineIsLocal(gline)) {
-    gline->gl_flags &= ~GLINE_ACTIVE;
+    if (flags & GLINE_LOCAL)
+      gline->gl_flags |= GLINE_LDEACT;
+    else {
+      gline->gl_flags &= ~GLINE_ACTIVE;
 
-    if (gline->gl_lastmod >= lastmod)
-      gline->gl_lastmod++;
-    else
-      gline->gl_lastmod = lastmod;
+      if (gline->gl_lastmod >= lastmod)
+       gline->gl_lastmod++;
+      else
+       gline->gl_lastmod = lastmod;
+    }
+
+    if ((saveflags & GLINE_ACTMASK) != GLINE_ACTIVE)
+      return 0; /* was inactive to begin with */
   }
 
   /* Inform ops and log it */
@@ -475,7 +503,7 @@ gline_burst(struct Client *cptr)
       gline_free(gline);
     else if (!GlineIsLocal(gline) && gline->gl_lastmod)
       sendcmdto_one(cptr, CMD_GLINE, &me, "* %c%s@%s %Tu %Tu :%s",
-                   GlineIsActive(gline) ? '+' : '-', gline->gl_user,
+                   GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
                    gline->gl_host, gline->gl_expire - CurrentTime,
                    gline->gl_lastmod, gline->gl_reason);
   }
@@ -487,7 +515,7 @@ gline_burst(struct Client *cptr)
       gline_free(gline);
     else if (!GlineIsLocal(gline) && gline->gl_lastmod)
       sendcmdto_one(cptr, CMD_GLINE, &me, "* %c%s %Tu %Tu :%s",
-                   GlineIsActive(gline) ? '+' : '-', gline->gl_user,
+                   GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
                    gline->gl_expire - CurrentTime, gline->gl_lastmod,
                    gline->gl_reason);
   }
@@ -500,7 +528,7 @@ gline_resend(struct Client *cptr, struct Gline *gline)
     return 0;
 
   sendcmdto_one(cptr, CMD_GLINE, &me, "* %c%s%s%s %Tu %Tu :%s",
-               GlineIsActive(gline) ? '+' : '-', gline->gl_user,
+               GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
                GlineIsBadChan(gline) ? "" : "@",
                GlineIsBadChan(gline) ? "" : gline->gl_host,
                gline->gl_expire - CurrentTime, gline->gl_lastmod,
index 61db6cb897d68d8137bf610435bac1ca4ca35865..0ebc5979e10ec78a1caed5f97f06ae0b47a981f3 100644 (file)
@@ -51,13 +51,13 @@ make_jupe(char *server, char *reason, time_t expire, time_t lastmod,
   ajupe = (struct Jupe*) MyMalloc(sizeof(struct Jupe)); /* alloc memory */
   assert(0 != ajupe);
 
-  DupString(ajupe->ju_server, server);        /* copy vital information */
+  DupString(ajupe->ju_server, server); /* copy vital information */
   DupString(ajupe->ju_reason, reason);
   ajupe->ju_expire = expire;
   ajupe->ju_lastmod = lastmod;
-  ajupe->ju_flags = flags;        /* set jupe flags */
+  ajupe->ju_flags = flags & JUPE_MASK; /* set jupe flags */
 
-  ajupe->ju_next = GlobalJupeList;       /* link it into the list */
+  ajupe->ju_next = GlobalJupeList; /* link it into the list */
   ajupe->ju_prev_p = &GlobalJupeList;
   if (GlobalJupeList)
     GlobalJupeList->ju_prev_p = &ajupe->ju_next;
@@ -90,7 +90,7 @@ propagate_jupe(struct Client *cptr, struct Client *sptr, struct Jupe *jupe)
     return;
 
   sendcmdto_serv_butone(cptr, CMD_JUPE, sptr, "* %c%s %Tu %Tu :%s",
-                       JupeIsActive(jupe) ? '+' : '-', jupe->ju_server,
+                       JupeIsRemActive(jupe) ? '+' : '-', jupe->ju_server,
                        jupe->ju_expire - CurrentTime, jupe->ju_lastmod,
                        jupe->ju_reason);
 }
@@ -148,15 +148,26 @@ int
 jupe_activate(struct Client *cptr, struct Client *sptr, struct Jupe *jupe,
              time_t lastmod, unsigned int flags)
 {
+  unsigned int saveflags = 0;
+
   assert(0 != jupe);
   assert(!JupeIsLocal(jupe));
 
-  jupe->ju_flags |= JUPE_ACTIVE;
+  saveflags = jupe->ju_flags;
 
-  if (jupe->ju_lastmod >= lastmod) /* force lastmod to increase */
-    jupe->ju_lastmod++;
-  else
-    jupe->ju_lastmod = lastmod;
+  if (flags & JUPE_LOCAL)
+    jupe->ju_flags &= ~JUPE_LDEACT;
+  else {
+    jupe->ju_flags |= JUPE_ACTIVE;
+
+    if (jupe->ju_lastmod >= lastmod) /* force lastmod to increase */
+      jupe->ju_lastmod++;
+    else
+      jupe->ju_lastmod = lastmod;
+  }
+
+  if ((saveflags & JUPE_ACTMASK) == JUPE_ACTIVE)
+    return 0; /* was active to begin with */
 
   /* Inform ops and log it */
   sendto_op_mask(SNO_NETWORK, "%s activating JUPE for %s, expiring at "
@@ -185,15 +196,26 @@ int
 jupe_deactivate(struct Client *cptr, struct Client *sptr, struct Jupe *jupe,
                time_t lastmod, unsigned int flags)
 {
+  unsigned int saveflags = 0;
+
   assert(0 != jupe);
 
+  saveflags = jupe->ju_flags;
+
   if (!JupeIsLocal(jupe)) {
-    jupe->ju_flags &= ~JUPE_ACTIVE;
+    if (flags & JUPE_LOCAL)
+      jupe->ju_flags |= JUPE_LDEACT;
+    else {
+      jupe->ju_flags &= ~JUPE_ACTIVE;
+
+      if (jupe->ju_lastmod >= lastmod) /* force lastmod to increase */
+       jupe->ju_lastmod++;
+      else
+       jupe->ju_lastmod = lastmod;
+    }
 
-    if (jupe->ju_lastmod >= lastmod) /* force lastmod to increase */
-      jupe->ju_lastmod++;
-    else
-      jupe->ju_lastmod = lastmod;
+    if ((saveflags & JUPE_ACTMASK) != JUPE_ACTIVE)
+      return 0; /* was inactive to begin with */
   }
 
   /* Inform ops and log it */
@@ -270,7 +292,7 @@ jupe_burst(struct Client *cptr)
       jupe_free(jupe);
     else if (!JupeIsLocal(jupe)) /* forward global jupes */
       sendcmdto_one(cptr, CMD_JUPE, &me, "* %c%s %Tu %Tu :%s",
-                   JupeIsActive(jupe) ? '+' : '-', jupe->ju_server,
+                   JupeIsRemActive(jupe) ? '+' : '-', jupe->ju_server,
                    jupe->ju_expire - CurrentTime, jupe->ju_lastmod,
                    jupe->ju_reason);
   }
@@ -283,7 +305,7 @@ jupe_resend(struct Client *cptr, struct Jupe *jupe)
     return 0;
 
   sendcmdto_one(cptr, CMD_JUPE, &me, "* %c%s %Tu %Tu :%s",
-               JupeIsActive(jupe) ? '+' : '-', jupe->ju_server,
+               JupeIsRemActive(jupe) ? '+' : '-', jupe->ju_server,
                jupe->ju_expire - CurrentTime, jupe->ju_lastmod,
                jupe->ju_reason);