]> jfr.im git - irc/quakenet/snircd-patchqueue.git/blob - glinesnomask.patch
glinesnomask.patch - updated for ircu merge plus a few minor fixes
[irc/quakenet/snircd-patchqueue.git] / glinesnomask.patch
1 SNO_GLINE and SNO_AUTO
2
3 Add = mask prefix to glines to be used by services
4 so their gline actions end up in SNO_AUTO,
5 freeing SNO_GLINE from spam
6
7 Services can do add this prefix before the mask for
8 automated hits, but not add them for glines manually
9 set by an oper on the service.
10
11 <source> GL <target> [=][!][+-<>]<mask> ..
12
13 Oper is not allowed to use = prefix in /GLINE,
14 as that would be cheating :-)
15
16 *** important ***
17 This prefix must not be used until the entire network
18 and services are upgraded to handle it!
19
20 diff -r 8dcf56ed67b9 include/gline.h
21 --- a/include/gline.h Sun Feb 15 15:31:50 2009 +0100
22 +++ b/include/gline.h Sun Feb 15 15:59:10 2009 +0100
23 @@ -88,8 +88,10 @@
24 #define GLINE_LIFETIME 0x2000 /**< Record lifetime update */
25 #define GLINE_REASON 0x4000 /**< Reason update */
26
27 +#define GLINE_AUTO 0x8000 /**< G-line set auto by service */
28 +
29 /** Controllable flags that can be set on an actual G-line. */
30 -#define GLINE_MASK (GLINE_ACTIVE | GLINE_BADCHAN | GLINE_LOCAL | GLINE_REALNAME)
31 +#define GLINE_MASK (GLINE_ACTIVE | GLINE_BADCHAN | GLINE_LOCAL | GLINE_REALNAME | GLINE_AUTO)
32 /** Mask for G-line activity flags. */
33 #define GLINE_ACTMASK (GLINE_ACTIVE | GLINE_LDEACT)
34
35 @@ -110,6 +112,8 @@
36 #define GlineIsBadChan(g) ((g)->gl_flags & GLINE_BADCHAN)
37 /** Test whether \a g is local to this server. */
38 #define GlineIsLocal(g) ((g)->gl_flags & GLINE_LOCAL)
39 +/** Test whether \a g is auto set by service */
40 +#define GlineIsAuto(g) ((g)->gl_flags & GLINE_AUTO)
41
42 /** Return nick mask of a G-line. */
43 #define GlineNick(g) ((g)->gl_nick)
44 diff -r 8dcf56ed67b9 ircd/gline.c
45 --- a/ircd/gline.c Sun Feb 15 15:31:50 2009 +0100
46 +++ b/ircd/gline.c Sun Feb 15 15:59:10 2009 +0100
47 @@ -278,7 +278,7 @@
48 gline->gl_reason);
49
50 /* let the ops know about it */
51 - sendto_opmask_butone(0, SNO_GLINE, "G-line active for %s",
52 + sendto_opmask_butone(0, GlineIsAuto(gline) ? SNO_AUTO : SNO_GLINE, "G-line active for %s",
53 get_client_name(acptr, SHOW_IP));
54
55 /* and get rid of him */
56 @@ -378,7 +378,8 @@
57 return 0;
58
59 assert(gline->gl_lastmod);
60 - sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s%s%s%s%s %Tu %Tu %Tu :%s",
61 + sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %s%c%s%s%s%s%s %Tu %Tu %Tu :%s",
62 + GlineIsAuto(gline) ? "=" : "",
63 GlineIsRemActive(gline) ? '+' : '-',
64 GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
65 GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
66 @@ -555,9 +556,8 @@
67 /* lifetime is already an absolute timestamp */
68
69 /* Inform ops... */
70 - sendto_opmask_butone(0, ircd_strncmp(reason, "AUTO", 4) ? SNO_GLINE :
71 - SNO_AUTO, "%s adding %s%s %s for %s%s%s%s%s, expiring at "
72 - "%Tu: %s",
73 + sendto_opmask_butone(0, (flags & GLINE_AUTO) ? SNO_AUTO : SNO_GLINE,
74 + "%s adding %s%s %s for %s%s%s%s%s, expiring at %Tu: %s",
75 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
76 cli_name(sptr) :
77 cli_name((cli_user(sptr))->server),
78 @@ -631,7 +631,8 @@
79 return 0; /* was active to begin with */
80
81 /* Inform ops and log it */
82 - sendto_opmask_butone(0, SNO_GLINE, "%s activating global %s for %s%s%s%s%s, "
83 + sendto_opmask_butone(0, GlineIsAuto(gline) ? SNO_AUTO : SNO_GLINE,
84 + "%s activating global %s for %s%s%s%s%s, "
85 "expiring at %Tu: %s",
86 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
87 cli_name(sptr) :
88 @@ -704,8 +705,8 @@
89 }
90
91 /* Inform ops and log it */
92 - sendto_opmask_butone(0, SNO_GLINE, "%s %s %s for %s%s%s%s%s, expiring at %Tu: "
93 - "%s",
94 + sendto_opmask_butone(0, GlineIsAuto(gline) ? SNO_AUTO : SNO_GLINE,
95 + "%s %s %s for %s%s%s%s%s, expiring at %Tu: %s",
96 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
97 cli_name(sptr) :
98 cli_name((cli_user(sptr))->server),
99 @@ -877,6 +878,12 @@
100 break;
101 }
102
103 + /* Handle the change of auto or manual G-line */
104 + if ((flags & GLINE_AUTO) && !GlineIsAuto(gline))
105 + gline->gl_flags |= GLINE_AUTO; /* mark as auto */
106 + else if (!(flags & GLINE_AUTO) && GlineIsAuto(gline))
107 + gline->gl_flags &= ~GLINE_AUTO; /* mark as manual */
108 +
109 /* Handle expiration changes... */
110 if (flags & GLINE_EXPIRE) {
111 gline->gl_expire = expire; /* save new expiration time */
112 @@ -909,7 +916,8 @@
113 }
114
115 /* All right, inform ops... */
116 - sendto_opmask_butone(0, SNO_GLINE, "%s modifying global %s for %s%s%s%s%s:%s",
117 + sendto_opmask_butone(0, GlineIsAuto(gline) ? SNO_AUTO : SNO_GLINE,
118 + "%s modifying global %s for %s%s%s%s%s:%s",
119 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
120 cli_name(sptr) : cli_name((cli_user(sptr))->server),
121 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
122 @@ -930,7 +938,8 @@
123 */
124 if (action != GLINE_LOCAL_ACTIVATE && action != GLINE_LOCAL_DEACTIVATE)
125 sendcmdto_serv_butone(sptr, CMD_GLINE, cptr,
126 - "* %s%s%s%s%s%s%s %Tu %Tu %Tu :%s",
127 + "* %s%s%s%s%s%s%s%s %Tu %Tu %Tu :%s",
128 + GlineIsAuto(gline) ? "=" : "",
129 flags & GLINE_OPERFORCE ? "!" : "", op,
130 GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
131 GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
132 @@ -956,7 +965,8 @@
133 assert(GlineIsLocal(gline));
134
135 /* Inform ops and log it */
136 - sendto_opmask_butone(0, SNO_GLINE, "%s removing local %s for %s%s%s%s%s",
137 + sendto_opmask_butone(0, GlineIsAuto(gline) ? SNO_AUTO : SNO_GLINE,
138 + "%s removing local %s for %s%s%s%s%s",
139 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
140 cli_name(sptr) : cli_name((cli_user(sptr))->server),
141 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
142 @@ -1144,8 +1154,9 @@
143
144 gliter(GlobalGlineList, gline, sgline) {
145 if (!GlineIsLocal(gline) && gline->gl_lastmod)
146 - sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s%s%s %Tu %Tu %Tu :%s",
147 - GlineIsRemActive(gline) ? '+' : '-',
148 + sendcmdto_one(&me, CMD_GLINE, cptr, "* %s%c%s%s%s%s%s %Tu %Tu %Tu :%s",
149 + GlineIsAuto(gline) ? "=" : "",
150 + GlineIsRemActive(gline) ? '+' : '-',
151 gline->gl_nick ? gline->gl_nick : "",
152 gline->gl_nick ? "!" : "",
153 gline->gl_user,
154 @@ -1157,7 +1168,8 @@
155
156 gliter(BadChanGlineList, gline, sgline) {
157 if (!GlineIsLocal(gline) && gline->gl_lastmod)
158 - sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s %Tu %Tu %Tu :%s",
159 + sendcmdto_one(&me, CMD_GLINE, cptr, "* %s%c%s %Tu %Tu %Tu :%s",
160 + GlineIsAuto(gline) ? "=" : "",
161 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
162 gline->gl_expire - CurrentTime, gline->gl_lastmod,
163 gline->gl_lifetime, gline->gl_reason);
164 @@ -1175,7 +1187,8 @@
165 if (GlineIsLocal(gline) || !gline->gl_lastmod)
166 return 0;
167
168 - sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s%s%s %Tu %Tu %Tu :%s",
169 + sendcmdto_one(&me, CMD_GLINE, cptr, "* %s%c%s%s%s%s%s %Tu %Tu %Tu :%s",
170 + GlineIsAuto(gline) ? "=" : "",
171 GlineIsRemActive(gline) ? '+' : '-',
172 GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : gline->gl_nick,
173 GlineIsBadChan(gline)|GlineIsRealName(gline) ? "" : "!",
174 @@ -1214,6 +1227,7 @@
175 gline->gl_expire + TSoffset, gline->gl_lastmod,
176 gline->gl_lifetime + TSoffset,
177 GlineIsLocal(gline) ? cli_name(&me) : "*",
178 + GlineIsAuto(gline) && IsAnOper(sptr) ? "=" : "",
179 gline->gl_state == GLOCAL_ACTIVATED ? ">" :
180 (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""),
181 GlineIsRemActive(gline) ? '+' : '-', gline->gl_reason);
182 @@ -1228,6 +1242,7 @@
183 gline->gl_expire + TSoffset, gline->gl_lastmod,
184 gline->gl_lifetime + TSoffset,
185 GlineIsLocal(gline) ? cli_name(&me) : "*",
186 + GlineIsAuto(gline) && IsAnOper(sptr) ? "=" : "",
187 gline->gl_state == GLOCAL_ACTIVATED ? ">" :
188 (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""),
189 GlineIsRemActive(gline) ? '+' : '-', gline->gl_reason);
190 @@ -1238,6 +1253,7 @@
191 gline->gl_expire + TSoffset, gline->gl_lastmod,
192 gline->gl_lifetime + TSoffset,
193 GlineIsLocal(gline) ? cli_name(&me) : "*",
194 + GlineIsAuto(gline) && IsAnOper(sptr) ? "=" : "",
195 gline->gl_state == GLOCAL_ACTIVATED ? ">" :
196 (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""),
197 GlineIsRemActive(gline) ? '+' : '-', gline->gl_reason);
198 @@ -1273,6 +1289,7 @@
199 gline->gl_host ? gline->gl_host : "",
200 gline->gl_expire + TSoffset, gline->gl_lastmod,
201 gline->gl_lifetime + TSoffset,
202 + GlineIsAuto(gline) && IsAnOper(sptr) ? "=" : "",
203 gline->gl_state == GLOCAL_ACTIVATED ? ">" :
204 (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""),
205 GlineIsRemActive(gline) ? '+' : '-',
206 @@ -1283,6 +1300,7 @@
207 send_reply(sptr, RPL_STATSGLINE, 'G', gline->gl_user, "", "", "", "",
208 gline->gl_expire + TSoffset, gline->gl_lastmod,
209 gline->gl_lifetime + TSoffset,
210 + GlineIsAuto(gline) && IsAnOper(sptr) ? "=" : "",
211 gline->gl_state == GLOCAL_ACTIVATED ? ">" :
212 (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""),
213 GlineIsRemActive(gline) ? '+' : '-', gline->gl_reason);
214 diff -r 8dcf56ed67b9 ircd/m_gline.c
215 --- a/ircd/m_gline.c Sun Feb 15 15:31:50 2009 +0100
216 +++ b/ircd/m_gline.c Sun Feb 15 15:59:10 2009 +0100
217 @@ -140,6 +140,11 @@
218 if (IsServer(sptr))
219 flags |= GLINE_FORCE;
220
221 + if (*mask == '=') {
222 + mask++;
223 + flags |= GLINE_AUTO; /* auto G-line action by service */
224 + }
225 +
226 if (*mask == '!') {
227 mask++;
228 flags |= GLINE_OPERFORCE; /* assume oper had WIDE_GLINE */
229 @@ -183,11 +188,14 @@
230 if ((action == GLINE_LOCAL_ACTIVATE || action == GLINE_LOCAL_DEACTIVATE) &&
231 !IsMe(acptr)) {
232 Debug((DEBUG_DEBUG, "I am forwarding a local change to a global gline "
233 - "to a remote server; target %s, mask %s, operforce %s, action %c",
234 - target, mask, flags & GLINE_OPERFORCE ? "YES" : "NO",
235 + "to a remote server; target %s, mask %s, auto %s, operforce %s, action %c",
236 + target, mask,
237 + flags & GLINE_AUTO ? "YES" : "NO",
238 + flags & GLINE_OPERFORCE ? "YES" : "NO",
239 action == GLINE_LOCAL_ACTIVATE ? '>' : '<'));
240
241 - sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%c%s", acptr,
242 + sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%s%c%s", acptr,
243 + flags & GLINE_AUTO ? "=" : "",
244 flags & GLINE_OPERFORCE ? "!" : "",
245 action == GLINE_LOCAL_ACTIVATE ? '>' : '<', mask);
246
247 @@ -226,8 +234,10 @@
248
249 /* OK, create the local G-line */
250 Debug((DEBUG_DEBUG, "I am creating a local G-line here; target %s, "
251 - "mask %s, operforce %s, action %s, expire %Tu, reason: %s",
252 - target, mask, flags & GLINE_OPERFORCE ? "YES" : "NO",
253 + "mask %s, auto %s, operforce %s, action %s, expire %Tu, reason: %s",
254 + target, mask,
255 + flags & GLINE_AUTO ? "YES" : "NO",
256 + flags & GLINE_OPERFORCE ? "YES" : "NO",
257 action == GLINE_ACTIVATE ? "+" : "-", expire, reason));
258
259 return gline_add(cptr, sptr, mask, reason, expire, lastmod,
260 @@ -239,7 +249,8 @@
261
262 /* Let's now destroy the G-line */;
263 Debug((DEBUG_DEBUG, "I am destroying a local G-line here; target %s, "
264 - "mask %s, operforce %s, action %s", target, mask,
265 + "mask %s, auto %s, operforce %s, action %s", target, mask,
266 + flags & GLINE_AUTO ? "YES" : "NO",
267 flags & GLINE_OPERFORCE ? "YES" : "NO",
268 action == GLINE_ACTIVATE ? "+" : "-"));
269
270 @@ -255,14 +266,17 @@
271 assert(!IsMe(acptr));
272
273 Debug((DEBUG_DEBUG, "I am forwarding a local G-line to a remote server; "
274 - "target %s, mask %s, operforce %s, action %c, expire %Tu, "
275 + "target %s, mask %s, auto %s, operforce %s, action %c, expire %Tu, "
276 "lastmod %Tu, reason: %s", target, mask,
277 + flags & GLINE_AUTO ? "YES" : "NO",
278 flags & GLINE_OPERFORCE ? "YES" : "NO",
279 action == GLINE_ACTIVATE ? '+' : '-', expire, CurrentTime,
280 reason));
281
282 - sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%c%s %Tu %Tu :%s",
283 - acptr, flags & GLINE_OPERFORCE ? "!" : "",
284 + sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%s%c%s %Tu %Tu :%s",
285 + acptr,
286 + flags & GLINE_AUTO ? "=" : "",
287 + flags & GLINE_OPERFORCE ? "!" : "",
288 action == GLINE_ACTIVATE ? '+' : '-', mask,
289 expire - CurrentTime, CurrentTime, reason);
290
291 @@ -323,9 +337,10 @@
292 return need_more_params(sptr, "GLINE");
293
294 Debug((DEBUG_DEBUG, "I have a global G-line I am acting upon now; "
295 - "target %s, mask %s, operforce %s, action %s, expire %Tu, "
296 + "target %s, mask %s, auto %s, operforce %s, action %s, expire %Tu, "
297 "lastmod %Tu, lifetime %Tu, reason: %s; gline %s! (fields "
298 "present: %s %s %s)", target, mask,
299 + flags & GLINE_AUTO ? "YES" : "NO",
300 flags & GLINE_OPERFORCE ? "YES" : "NO",
301 action == GLINE_ACTIVATE ? "+" :
302 (action == GLINE_DEACTIVATE ? "-" :
303 @@ -353,7 +368,8 @@
304 action == GLINE_ACTIVATE ? "activation" : "deactivation"));
305
306 /* propagate the G-line, even though we don't have it */
307 - sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s %Tu",
308 + sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %s%c%s %Tu",
309 + flags & GLINE_AUTO ? "=" : "",
310 action == GLINE_ACTIVATE ? '+' : '-',
311 mask, lastmod);
312
313 @@ -389,6 +405,10 @@
314 return gline_list(sptr, 0);
315 }
316
317 + /* ignore auto prefix from oper */
318 + if (*mask == '=')
319 + mask++;
320 +
321 if (*mask == '!') {
322 mask++;
323
324 diff -r 8dcf56ed67b9 ircd/s_err.c
325 --- a/ircd/s_err.c Sun Feb 15 15:31:50 2009 +0100
326 +++ b/ircd/s_err.c Sun Feb 15 15:59:10 2009 +0100
327 @@ -526,7 +526,7 @@
328 /* 246 */
329 { RPL_STATSTLINE, "%c %s %s", "246" },
330 /* 247 */
331 - { RPL_STATSGLINE, "%c %s%s%s%s%s %Tu %Tu %Tu %s%c :%s", "247" },
332 + { RPL_STATSGLINE, "%c %s%s%s%s%s %Tu %Tu %Tu %s%s%c :%s", "247" },
333 /* 248 */
334 { RPL_STATSULINE, "U %s", "248" },
335 /* 249 */
336 @@ -592,7 +592,7 @@
337 /* 279 */
338 { 0 },
339 /* 280 */
340 - { RPL_GLIST, "%s%s%s%s%s %Tu %Tu %Tu %s %s%c :%s", "280" },
341 + { RPL_GLIST, "%s%s%s%s%s %Tu %Tu %Tu %s %s%s%c :%s", "280" },
342 /* 281 */
343 { RPL_ENDOFGLIST, ":End of G-line List", "281" },
344 /* 282 */