]>
Commit | Line | Data |
---|---|---|
1 | # HG changeset patch | |
2 | # Parent e5696ca6af7ca3b62663f4891d4f570b3e66356e | |
3 | ||
4 | Add % prefix for gline allowing a global gline to be destroyed (removed from memory) | |
5 | instead of being kept in memory in a deactivated state until it expires. | |
6 | ||
7 | This prefix should only be used when there are no servers split that have the gline, | |
8 | because during a netmerge, if the other end has this gline, | |
9 | it will be reintroduced to our side of the network. | |
10 | ||
11 | Syntax: | |
12 | ||
13 | P10 (Uworld gline, no lastmod) | |
14 | "<source numeric> GL * %-<mask>" | |
15 | ||
16 | P10 (normal gline, lastmod) | |
17 | "<source numeric> GL * %-<mask> <expire> <lastmod> :<reason>" | |
18 | ||
19 | Oper | |
20 | "GLINE %-<mask> * <expire> :<reason>" | |
21 | ||
22 | diff -r e5696ca6af7c include/gline.h | |
23 | --- a/include/gline.h Sun Jul 21 09:54:48 2013 +0200 | |
24 | +++ b/include/gline.h Sun Jul 21 10:10:30 2013 +0200 | |
25 | @@ -83,6 +83,7 @@ | |
26 | #define GLINE_LASTMOD 0x0200 /**< Find only G-lines with non-zero lastmod. */ | |
27 | #define GLINE_OPERFORCE 0x0400 /**< Oper forcing G-line to be set. */ | |
28 | #define GLINE_REALNAME 0x0800 /**< G-line matches only the realname field. */ | |
29 | +#define GLINE_DESTROY 0x1000 /**< G-line is to be destroyed, removed from memory - snircd */ | |
30 | ||
31 | #define GLINE_EXPIRE 0x1000 /**< Expiration time update */ | |
32 | #define GLINE_LIFETIME 0x2000 /**< Record lifetime update */ | |
33 | @@ -110,6 +111,8 @@ | |
34 | #define GlineIsBadChan(g) ((g)->gl_flags & GLINE_BADCHAN) | |
35 | /** Test whether \a g is local to this server. */ | |
36 | #define GlineIsLocal(g) ((g)->gl_flags & GLINE_LOCAL) | |
37 | +/** Test whether \a g is to be destroyed - snircd */ | |
38 | +#define GlineIsDestroy(g) ((g)->gl_flags & GLINE_DESTROY) | |
39 | ||
40 | /** Return nick mask of a G-line. */ | |
41 | #define GlineNick(g) ((g)->gl_nick) | |
42 | diff -r e5696ca6af7c ircd/gline.c | |
43 | --- a/ircd/gline.c Sun Jul 21 09:54:48 2013 +0200 | |
44 | +++ b/ircd/gline.c Sun Jul 21 10:10:30 2013 +0200 | |
45 | @@ -388,7 +388,8 @@ | |
46 | ||
47 | assert(gline->gl_lastmod); | |
48 | ||
49 | - sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s%s%s%s%s %Tu %Tu %Tu :%s", | |
50 | + sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %s%c%s%s%s%s%s %Tu %Tu %Tu :%s", | |
51 | + GlineIsDestroy(gline) ? "%" : "", | |
52 | GlineIsRemActive(gline) ? '+' : '-', | |
53 | GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick, | |
54 | GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!", | |
55 | @@ -725,7 +726,14 @@ | |
56 | msg = "removing global"; | |
57 | gline->gl_flags &= ~GLINE_ACTIVE; /* propagate a -<mask> */ | |
58 | } else { | |
59 | - msg = "deactivating global"; | |
60 | + | |
61 | + /* destroy gline - snircd */ | |
62 | + if (flags & GLINE_DESTROY) { | |
63 | + msg = "destroying global"; | |
64 | + gline->gl_flags |= GLINE_DESTROY; | |
65 | + } | |
66 | + else | |
67 | + msg = "deactivating global"; | |
68 | ||
69 | if (flags & GLINE_LOCAL) | |
70 | gline->gl_flags |= GLINE_LDEACT; | |
71 | @@ -740,7 +748,7 @@ | |
72 | } | |
73 | } | |
74 | ||
75 | - if ((saveflags & GLINE_ACTMASK) != GLINE_ACTIVE) | |
76 | + if ((saveflags & GLINE_ACTMASK) != GLINE_ACTIVE && !(flags & GLINE_DESTROY)) | |
77 | return 0; /* was inactive to begin with */ | |
78 | } | |
79 | ||
80 | @@ -771,7 +779,8 @@ | |
81 | gline_propagate(cptr, sptr, gline); | |
82 | ||
83 | /* if it's a local gline or a Uworld gline (and not locally deactivated).. */ | |
84 | - if (GlineIsLocal(gline) || (!gline->gl_lastmod && !(flags & GLINE_LOCAL))) | |
85 | + if (GlineIsLocal(gline) || (!gline->gl_lastmod && !(flags & GLINE_LOCAL)) || | |
86 | + (flags & GLINE_DESTROY)) /* destroy gline - snircd */ | |
87 | gline_free(gline); /* get rid of it */ | |
88 | ||
89 | return 0; | |
90 | diff -r e5696ca6af7c ircd/m_gline.c | |
91 | --- a/ircd/m_gline.c Sun Jul 21 09:54:48 2013 +0200 | |
92 | +++ b/ircd/m_gline.c Sun Jul 21 10:10:30 2013 +0200 | |
93 | @@ -143,6 +143,9 @@ | |
94 | if (*mask == '!') { | |
95 | mask++; | |
96 | flags |= GLINE_OPERFORCE; /* assume oper had WIDE_GLINE */ | |
97 | + } else if (*mask == '%') { /* destroy gline - snircd */ | |
98 | + mask++; | |
99 | + flags |= GLINE_DESTROY; | |
100 | } | |
101 | ||
102 | switch (*mask) { /* handle +, -, <, and > */ | |
103 | @@ -238,8 +241,17 @@ | |
104 | lifetime, flags | GLINE_ACTIVE); | |
105 | } | |
106 | } else if (IsMe(acptr)) { /* destroying a local G-line */ | |
107 | - if (!agline) /* G-line doesn't exist, so let's complain... */ | |
108 | - return send_reply(sptr, ERR_NOSUCHGLINE, mask); | |
109 | + if (!agline) { | |
110 | + /* manually propagate destroy for a global gline we dont have - snircd */ | |
111 | + if ((flags & GLINE_DESTROY) && !(flags & (GLINE_ACTIVE|GLINE_LOCAL))) { | |
112 | + sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %%-%s %Tu %Tu %Tu :%s", | |
113 | + mask, expire, lastmod, lifetime, reason); | |
114 | + return 0; | |
115 | + } else { | |
116 | + /* G-line doesn't exist, so let's complain... */ | |
117 | + return send_reply(sptr, ERR_NOSUCHGLINE, mask); | |
118 | + } | |
119 | + } | |
120 | ||
121 | /* Let's now destroy the G-line */; | |
122 | Debug((DEBUG_DEBUG, "I am destroying a local G-line here; target %s, " | |
123 | @@ -398,6 +410,9 @@ | |
124 | ||
125 | if (HasPriv(sptr, PRIV_WIDE_GLINE)) | |
126 | flags |= GLINE_OPERFORCE; | |
127 | + } else if (*mask == '%') { /* destroy gline - snircd */ | |
128 | + mask++; | |
129 | + flags |= GLINE_DESTROY; | |
130 | } | |
131 | ||
132 | switch (*mask) { /* handle +, -, <, and > */ |