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.
#
#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)
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)
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);
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 "
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 */
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);
}
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);
}
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,
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;
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);
}
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 "
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 */
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);
}
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);