From: Kevin L. Mitchell Date: Mon, 17 Apr 2000 19:01:35 +0000 (+0000) Subject: Author: Kev X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=commitdiff_plain;h=d2dcfaa2073d0f22ecd927d5ab0d5d3094372ad6 Author: Kev 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 --- diff --git a/ChangeLog b/ChangeLog index b1ec2e7..df57877 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2000-04-17 Kevin L. Mitchell + * 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 @@ -598,7 +612,7 @@ # # 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. # diff --git a/include/gline.h b/include/gline.h index 7763063..2409016 100644 --- a/include/gline.h +++ b/include/gline.h @@ -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) diff --git a/include/jupe.h b/include/jupe.h index 4aeda46..f5efe9d 100644 --- a/include/jupe.h +++ b/include/jupe.h @@ -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) diff --git a/ircd/gline.c b/ircd/gline.c index bdc50df..0652461 100644 --- a/ircd/gline.c +++ b/ircd/gline.c @@ -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, diff --git a/ircd/jupe.c b/ircd/jupe.c index 61db6cb..0ebc597 100644 --- a/ircd/jupe.c +++ b/ircd/jupe.c @@ -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);