2 * IRC - Internet Relay Chat, ircd/gline.c
3 * Copyright (C) 1990 Jarkko Oikarinen and
4 * University of Oulu, Finland
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 1, or (at your option)
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "ircd_alloc.h"
28 #include "ircd_features.h"
30 #include "ircd_reply.h"
31 #include "ircd_snprintf.h"
32 #include "ircd_string.h"
45 #include "sys.h" /* FALSE bleah */
52 #include <arpa/inet.h> /* for inet_ntoa */
54 #define CHECK_APPROVED 0 /* Mask is acceptable */
55 #define CHECK_OVERRIDABLE 1 /* Mask is acceptable, but not by default */
56 #define CHECK_REJECTED 2 /* Mask is totally unacceptable */
58 #define MASK_WILD_0 0x01 /* Wildcards in the last position */
59 #define MASK_WILD_1 0x02 /* Wildcards in the next-to-last position */
61 #define MASK_WILD_MASK 0x03 /* Mask out the positional wildcards */
63 #define MASK_WILDS 0x10 /* Mask contains wildcards */
64 #define MASK_IP 0x20 /* Mask is an IP address */
65 #define MASK_HALT 0x40 /* Finished processing mask */
67 struct Gline* GlobalGlineList = 0;
68 struct Gline* BadChanGlineList = 0;
71 canon_userhost(char *userhost, char **user_p, char **host_p, char *def_user)
75 if (*userhost == '$') {
81 if (!(tmp = strchr(userhost, '@'))) {
92 make_gline(char *user, char *host, char *reason, time_t expire, time_t lastmod,
95 struct Gline *gline, *sgline, *after = 0;
97 if (!(flags & GLINE_BADCHAN)) { /* search for overlapping glines first */
99 for (gline = GlobalGlineList; gline; gline = sgline) {
100 sgline = gline->gl_next;
102 if (gline->gl_expire <= CurrentTime)
104 else if (((gline->gl_flags & GLINE_LOCAL) != (flags & GLINE_LOCAL)) ||
105 (gline->gl_host && !host) || (!gline->gl_host && host))
107 else if (!mmatch(gline->gl_user, user) /* gline contains new mask */
108 && (gline->gl_host == NULL || !mmatch(gline->gl_host, host))) {
109 if (expire <= gline->gl_expire) /* will expire before wider gline */
112 after = gline; /* stick new gline after this one */
113 } else if (!mmatch(user, gline->gl_user) /* new mask contains gline */
114 && (gline->gl_host==NULL || !mmatch(host, gline->gl_host))
115 && gline->gl_expire <= expire) /* old expires before new */
116 gline_free(gline); /* save some memory */
120 gline = (struct Gline *)MyMalloc(sizeof(struct Gline)); /* alloc memory */
123 DupString(gline->gl_reason, reason); /* initialize gline... */
124 gline->gl_expire = expire;
125 gline->gl_lastmod = lastmod;
126 gline->gl_flags = flags & GLINE_MASK;
128 if (flags & GLINE_BADCHAN) { /* set a BADCHAN gline */
129 DupString(gline->gl_user, user); /* first, remember channel */
132 gline->gl_next = BadChanGlineList; /* then link it into list */
133 gline->gl_prev_p = &BadChanGlineList;
134 if (BadChanGlineList)
135 BadChanGlineList->gl_prev_p = &gline->gl_next;
136 BadChanGlineList = gline;
138 DupString(gline->gl_user, user); /* remember them... */
140 DupString(gline->gl_host, host);
142 gline->gl_host = NULL;
144 if (*user != '$' && ipmask_parse(host, &gline->gl_addr, &gline->gl_bits)) {
145 Debug((DEBUG_DEBUG,"IP gline: %s/%u", ircd_ntoa(&gline->gl_addr), gline->gl_bits));
146 gline->gl_flags |= GLINE_IPMASK;
150 gline->gl_next = after->gl_next;
151 gline->gl_prev_p = &after->gl_next;
153 after->gl_next->gl_prev_p = &gline->gl_next;
154 after->gl_next = gline;
156 gline->gl_next = GlobalGlineList; /* then link it into list */
157 gline->gl_prev_p = &GlobalGlineList;
159 GlobalGlineList->gl_prev_p = &gline->gl_next;
160 GlobalGlineList = gline;
168 do_gline(struct Client *cptr, struct Client *sptr, struct Gline *gline)
170 struct Client *acptr;
171 int fd, retval = 0, tval;
173 if (!GlineIsActive(gline)) /* no action taken on inactive glines */
176 for (fd = HighestFd; fd >= 0; --fd) {
180 if ((acptr = LocalClientArray[fd])) {
181 if (!cli_user(acptr))
184 if (GlineIsRealName(gline)) { /* Realname Gline */
185 Debug((DEBUG_DEBUG,"Realname Gline: %s %s",(cli_info(acptr)),
187 if (match(gline->gl_user+2, cli_info(acptr)) != 0)
189 Debug((DEBUG_DEBUG,"Matched!"));
190 } else { /* Host/IP gline */
191 if (cli_user(acptr)->username &&
192 match(gline->gl_user, (cli_user(acptr))->username) != 0)
195 if (GlineIsIpMask(gline)) {
197 char tbuf1[SOCKIPLEN], tbuf2[SOCKIPLEN];
198 Debug((DEBUG_DEBUG,"IP gline: %s %s/%u", ircd_ntoa_r(tbuf1, &cli_ip(cptr)), ircd_ntoa_r(tbuf2, &gline->gl_addr), gline->gl_bits));
200 if (!ipmask_check(&cli_ip(cptr), &gline->gl_addr, gline->gl_bits))
204 if (match(gline->gl_host, cli_sockhost(acptr)) != 0)
209 /* ok, here's one that got G-lined */
210 send_reply(acptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s",
213 /* let the ops know about it */
214 sendto_opmask_butone(0, SNO_GLINE, "G-line active for %s",
215 get_client_name(acptr, TRUE));
217 /* and get rid of him */
218 if ((tval = exit_client_msg(cptr, acptr, &me, "G-lined (%s)",
220 retval = tval; /* retain killed status */
227 * This routine implements the mask checking applied to local
228 * G-lines. Basically, host masks must have a minimum of two non-wild
229 * domain fields, and IP masks must have a minimum of 16 bits. If the
230 * mask has even one wild-card, OVERRIDABLE is returned, assuming the
231 * other check doesn't fail.
234 gline_checkmask(char *mask)
236 unsigned int flags = MASK_IP;
237 unsigned int dots = 0;
238 unsigned int ipmask = 0;
240 for (; *mask; mask++) { /* go through given mask */
241 if (*mask == '.') { /* it's a separator; advance positional wilds */
242 flags = (flags & ~MASK_WILD_MASK) | ((flags << 1) & MASK_WILD_MASK);
245 if ((flags & (MASK_IP | MASK_WILDS)) == MASK_IP)
246 ipmask += 8; /* It's an IP with no wilds, count bits */
247 } else if (*mask == '*' || *mask == '?')
248 flags |= MASK_WILD_0 | MASK_WILDS; /* found a wildcard */
249 else if (*mask == '/') { /* n.n.n.n/n notation; parse bit specifier */
251 ipmask = strtoul(mask, &mask, 10);
253 /* sanity-check to date */
254 if (*mask || (flags & (MASK_WILDS | MASK_IP)) != MASK_IP)
255 return CHECK_REJECTED;
258 return CHECK_REJECTED;
262 if (dots != 3 || ipmask > 3)
263 return CHECK_REJECTED;
268 flags |= MASK_HALT; /* Halt the ipmask calculation */
269 break; /* get out of the loop */
270 } else if (!IsIP6Char(*mask)) {
271 flags &= ~MASK_IP; /* not an IP anymore! */
276 /* Sanity-check quads */
277 if (dots > 3 || (!(flags & MASK_WILDS) && dots < 3)) {
282 /* update bit count if necessary */
283 if ((flags & (MASK_IP | MASK_WILDS | MASK_HALT)) == MASK_IP)
286 /* Check to see that it's not too wide of a mask */
287 if (flags & MASK_WILDS &&
288 ((!(flags & MASK_IP) && (dots < 2 || flags & MASK_WILD_MASK)) ||
289 (flags & MASK_IP && ipmask < 16)))
290 return CHECK_REJECTED; /* to wide, reject */
292 /* Ok, it's approved; require override if it has wildcards, though */
293 return flags & MASK_WILDS ? CHECK_OVERRIDABLE : CHECK_APPROVED;
297 gline_propagate(struct Client *cptr, struct Client *sptr, struct Gline *gline)
299 if (GlineIsLocal(gline) || (IsUser(sptr) && !gline->gl_lastmod))
302 if (gline->gl_lastmod)
303 sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
304 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
305 gline->gl_host ? "@" : "",
306 gline->gl_host ? gline->gl_host : "",
307 gline->gl_expire - CurrentTime, gline->gl_lastmod,
310 sendcmdto_serv_butone(sptr, CMD_GLINE, cptr,
311 (GlineIsRemActive(gline) ?
312 "* +%s%s%s %Tu :%s" : "* -%s%s%s"),
314 gline->gl_host ? "@" : "",
315 gline->gl_host ? gline->gl_host : "",
316 gline->gl_expire - CurrentTime, gline->gl_reason);
322 gline_add(struct Client *cptr, struct Client *sptr, char *userhost,
323 char *reason, time_t expire, time_t lastmod, unsigned int flags)
325 struct Gline *agline;
326 char uhmask[USERLEN + HOSTLEN + 2];
330 assert(0 != userhost);
333 if (*userhost == '#' || *userhost == '&') {
334 if ((flags & GLINE_LOCAL) && !HasPriv(sptr, PRIV_LOCAL_BADCHAN))
335 return send_reply(sptr, ERR_NOPRIVILEGES);
337 flags |= GLINE_BADCHAN;
340 } else if (*userhost == '$') {
341 switch (*userhost == '$' ? userhost[1] : userhost[3]) {
342 case 'R': flags |= GLINE_REALNAME; break;
344 /* uh, what to do here? */
345 /* The answer, my dear Watson, is we throw a protocol_violation()
347 return protocol_violation(sptr,"%s has been smoking the sweet leaf and sent me a whacky gline",cli_name(sptr));
350 user = (*userhost =='$' ? userhost : userhost+2);
353 canon_userhost(userhost, &user, &host, "*");
355 ircd_snprintf(0, uhmask, sizeof(uhmask), "%s@%s", user, host))
356 return send_reply(sptr, ERR_LONGMASK);
357 else if (MyUser(sptr) || (IsUser(sptr) && flags & GLINE_LOCAL)) {
358 switch (gline_checkmask(host)) {
359 case CHECK_OVERRIDABLE: /* oper overrided restriction */
360 if (flags & GLINE_OPERFORCE)
364 return send_reply(sptr, ERR_MASKTOOWIDE, uhmask);
368 if ((tmp = count_users(uhmask)) >=
369 feature_int(FEAT_GLINEMAXUSERCOUNT) && !(flags & GLINE_OPERFORCE))
370 return send_reply(sptr, ERR_TOOMANYUSERS, tmp);
375 * You cannot set a negative (or zero) expire time, nor can you set an
376 * expiration time for greater than GLINE_MAX_EXPIRE.
378 if (!(flags & GLINE_FORCE) && (expire <= 0 || expire > GLINE_MAX_EXPIRE)) {
379 if (!IsServer(sptr) && MyConnect(sptr))
380 send_reply(sptr, ERR_BADEXPIRE, expire);
384 expire += CurrentTime; /* convert from lifetime to timestamp */
387 sendto_opmask_butone(0, ircd_strncmp(reason, "AUTO", 4) ? SNO_GLINE :
388 SNO_AUTO, "%s adding %s %s for %s%s%s, expiring at "
390 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
392 cli_name((cli_user(sptr))->server),
393 (flags & GLINE_LOCAL) ? "local" : "global",
394 (flags & GLINE_BADCHAN) ? "BADCHAN" : "GLINE", user,
395 (flags & (GLINE_BADCHAN|GLINE_REALNAME)) ? "" : "@",
396 (flags & (GLINE_BADCHAN|GLINE_REALNAME)) ? "" : host,
397 expire + TSoffset, reason);
400 log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
401 "%#C adding %s %s for %s, expiring at %Tu: %s", sptr,
402 flags & GLINE_LOCAL ? "local" : "global",
403 flags & GLINE_BADCHAN ? "BADCHAN" : "GLINE", userhost,
404 expire + TSoffset, reason);
407 agline = make_gline(user, host, reason, expire, lastmod, flags);
409 if (!agline) /* if it overlapped, silently return */
412 gline_propagate(cptr, sptr, agline);
414 if (GlineIsBadChan(agline))
417 return do_gline(cptr, sptr, agline); /* knock off users if necessary */
421 gline_activate(struct Client *cptr, struct Client *sptr, struct Gline *gline,
422 time_t lastmod, unsigned int flags)
424 unsigned int saveflags = 0;
428 saveflags = gline->gl_flags;
430 if (flags & GLINE_LOCAL)
431 gline->gl_flags &= ~GLINE_LDEACT;
433 gline->gl_flags |= GLINE_ACTIVE;
435 if (gline->gl_lastmod) {
436 if (gline->gl_lastmod >= lastmod) /* force lastmod to increase */
439 gline->gl_lastmod = lastmod;
443 if ((saveflags & GLINE_ACTMASK) == GLINE_ACTIVE)
444 return 0; /* was active to begin with */
446 /* Inform ops and log it */
447 sendto_opmask_butone(0, SNO_GLINE, "%s activating global %s for %s%s%s, "
448 "expiring at %Tu: %s",
449 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
451 cli_name((cli_user(sptr))->server),
452 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
453 gline->gl_user, gline->gl_host ? "@" : "",
454 gline->gl_host ? gline->gl_host : "",
455 gline->gl_expire + TSoffset, gline->gl_reason);
457 log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
458 "%#C activating global %s for %s%s%s, expiring at %Tu: %s", sptr,
459 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", gline->gl_user,
460 gline->gl_host ? "@" : "",
461 gline->gl_host ? gline->gl_host : "",
462 gline->gl_expire + TSoffset, gline->gl_reason);
464 if (!(flags & GLINE_LOCAL)) /* don't propagate local changes */
465 gline_propagate(cptr, sptr, gline);
467 return GlineIsBadChan(gline) ? 0 : do_gline(cptr, sptr, gline);
471 gline_deactivate(struct Client *cptr, struct Client *sptr, struct Gline *gline,
472 time_t lastmod, unsigned int flags)
474 unsigned int saveflags = 0;
479 saveflags = gline->gl_flags;
481 if (GlineIsLocal(gline))
482 msg = "removing local";
483 else if (!gline->gl_lastmod && !(flags & GLINE_LOCAL)) {
484 msg = "removing global";
485 gline->gl_flags &= ~GLINE_ACTIVE; /* propagate a -<mask> */
487 msg = "deactivating global";
489 if (flags & GLINE_LOCAL)
490 gline->gl_flags |= GLINE_LDEACT;
492 gline->gl_flags &= ~GLINE_ACTIVE;
494 if (gline->gl_lastmod) {
495 if (gline->gl_lastmod >= lastmod)
498 gline->gl_lastmod = lastmod;
502 if ((saveflags & GLINE_ACTMASK) != GLINE_ACTIVE)
503 return 0; /* was inactive to begin with */
506 /* Inform ops and log it */
507 sendto_opmask_butone(0, SNO_GLINE, "%s %s %s for %s%s%s, expiring at %Tu: "
509 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
511 cli_name((cli_user(sptr))->server),
512 msg, GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
513 gline->gl_user, gline->gl_host ? "@" : "",
514 gline->gl_host ? gline->gl_host : "",
515 gline->gl_expire + TSoffset, gline->gl_reason);
517 log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
518 "%#C %s %s for %s%s%s, expiring at %Tu: %s", sptr, msg,
519 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", gline->gl_user,
520 gline->gl_host ? "@" : "",
521 gline->gl_host ? gline->gl_host : "",
522 gline->gl_expire + TSoffset, gline->gl_reason);
524 if (!(flags & GLINE_LOCAL)) /* don't propagate local changes */
525 gline_propagate(cptr, sptr, gline);
527 /* if it's a local gline or a Uworld gline (and not locally deactivated).. */
528 if (GlineIsLocal(gline) || (!gline->gl_lastmod && !(flags & GLINE_LOCAL)))
529 gline_free(gline); /* get rid of it */
535 gline_find(char *userhost, unsigned int flags)
538 struct Gline *sgline;
539 char *user, *host, *t_uh;
541 if (flags & (GLINE_BADCHAN | GLINE_ANY)) {
542 for (gline = BadChanGlineList; gline; gline = sgline) {
543 sgline = gline->gl_next;
545 if (gline->gl_expire <= CurrentTime)
547 else if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) ||
548 (flags & GLINE_LASTMOD && !gline->gl_lastmod))
550 else if ((flags & GLINE_EXACT ? ircd_strcmp(gline->gl_user, userhost) :
551 match(gline->gl_user, userhost)) == 0)
556 if ((flags & (GLINE_BADCHAN | GLINE_ANY)) == GLINE_BADCHAN ||
557 *userhost == '#' || *userhost == '&')
560 DupString(t_uh, userhost);
561 canon_userhost(t_uh, &user, &host, 0);
566 for (gline = GlobalGlineList; gline; gline = sgline) {
567 sgline = gline->gl_next;
569 if (gline->gl_expire <= CurrentTime)
571 else if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) ||
572 (flags & GLINE_LASTMOD && !gline->gl_lastmod))
574 else if (flags & GLINE_EXACT) {
575 if (((gline->gl_host && host && ircd_strcmp(gline->gl_host, host) == 0)
576 || (!gline->gl_host && !host)) &&
577 ((!user && ircd_strcmp(gline->gl_user, "*") == 0) ||
578 ircd_strcmp(gline->gl_user, user) == 0))
581 if (((gline->gl_host && host && ircd_strcmp(gline->gl_host, host) == 0)
582 || (!gline->gl_host && !host)) &&
583 ((!user && ircd_strcmp(gline->gl_user, "*") == 0) ||
584 match(gline->gl_user, user) == 0))
595 gline_lookup(struct Client *cptr, unsigned int flags)
598 struct Gline *sgline;
600 for (gline = GlobalGlineList; gline; gline = sgline) {
601 sgline = gline->gl_next;
603 if (gline->gl_expire <= CurrentTime) {
608 if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) ||
609 (flags & GLINE_LASTMOD && !gline->gl_lastmod))
612 if (GlineIsRealName(gline)) {
613 Debug((DEBUG_DEBUG,"realname gline: '%s' '%s'",gline->gl_user,cli_info(cptr)));
614 if (match(gline->gl_user+2, cli_info(cptr)) != 0)
616 if (!GlineIsActive(gline))
621 if (match(gline->gl_user, (cli_user(cptr))->username) != 0)
624 if (GlineIsIpMask(gline)) {
626 char tbuf1[SOCKIPLEN], tbuf2[SOCKIPLEN];
627 Debug((DEBUG_DEBUG,"IP gline: %s %s/%u", ircd_ntoa_r(tbuf1, &cli_ip(cptr)), ircd_ntoa_r(tbuf2, &gline->gl_addr), gline->gl_bits));
629 if (!ipmask_check(&cli_ip(cptr), &gline->gl_addr, gline->gl_bits))
633 if (match(gline->gl_host, (cli_user(cptr))->realhost) != 0)
637 if (GlineIsActive(gline))
647 gline_free(struct Gline *gline)
651 *gline->gl_prev_p = gline->gl_next; /* squeeze this gline out */
653 gline->gl_next->gl_prev_p = gline->gl_prev_p;
655 MyFree(gline->gl_user); /* free up the memory */
657 MyFree(gline->gl_host);
658 MyFree(gline->gl_reason);
663 gline_burst(struct Client *cptr)
666 struct Gline *sgline;
668 for (gline = GlobalGlineList; gline; gline = sgline) { /* all glines */
669 sgline = gline->gl_next;
671 if (gline->gl_expire <= CurrentTime) /* expire any that need expiring */
673 else if (!GlineIsLocal(gline) && gline->gl_lastmod)
674 sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
675 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
676 gline->gl_host ? "@" : "",
677 gline->gl_host ? gline->gl_host : "",
678 gline->gl_expire - CurrentTime, gline->gl_lastmod,
682 for (gline = BadChanGlineList; gline; gline = sgline) { /* all glines */
683 sgline = gline->gl_next;
685 if (gline->gl_expire <= CurrentTime) /* expire any that need expiring */
687 else if (!GlineIsLocal(gline) && gline->gl_lastmod)
688 sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s %Tu %Tu :%s",
689 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
690 gline->gl_expire - CurrentTime, gline->gl_lastmod,
696 gline_resend(struct Client *cptr, struct Gline *gline)
698 if (GlineIsLocal(gline) || !gline->gl_lastmod)
701 sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
702 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
703 gline->gl_host ? "@" : "",
704 gline->gl_host ? gline->gl_host : "",
705 gline->gl_expire - CurrentTime, gline->gl_lastmod,
712 gline_list(struct Client *sptr, char *userhost)
715 struct Gline *sgline;
718 if (!(gline = gline_find(userhost, GLINE_ANY))) /* no such gline */
719 return send_reply(sptr, ERR_NOSUCHGLINE, userhost);
721 /* send gline information along */
722 send_reply(sptr, RPL_GLIST, gline->gl_user,
723 gline->gl_host ? "@" : "",
724 gline->gl_host ? gline->gl_host : "",
725 gline->gl_expire + TSoffset,
726 GlineIsLocal(gline) ? cli_name(&me) : "*",
727 GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
729 for (gline = GlobalGlineList; gline; gline = sgline) {
730 sgline = gline->gl_next;
732 if (gline->gl_expire <= CurrentTime)
735 send_reply(sptr, RPL_GLIST, gline->gl_user,
736 gline->gl_host ? "@" : "",
737 gline->gl_host ? gline->gl_host : "",
738 gline->gl_expire + TSoffset,
739 GlineIsLocal(gline) ? cli_name(&me) : "*",
740 GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
743 for (gline = BadChanGlineList; gline; gline = sgline) {
744 sgline = gline->gl_next;
746 if (gline->gl_expire <= CurrentTime)
749 send_reply(sptr, RPL_GLIST, gline->gl_user, "", "",
750 gline->gl_expire + TSoffset,
751 GlineIsLocal(gline) ? cli_name(&me) : "*",
752 GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
756 /* end of gline information */
757 return send_reply(sptr, RPL_ENDOFGLIST);
761 gline_stats(struct Client *sptr, struct StatDesc *sd, int stat,
765 struct Gline *sgline;
767 for (gline = GlobalGlineList; gline; gline = sgline) {
768 sgline = gline->gl_next;
770 if (gline->gl_expire <= CurrentTime)
773 send_reply(sptr, RPL_STATSGLINE, 'G', gline->gl_user,
774 gline->gl_host ? "@" : "",
775 gline->gl_host ? gline->gl_host : "",
776 gline->gl_expire + TSoffset, gline->gl_reason);
781 gline_memory_count(size_t *gl_size)
786 for (gline = GlobalGlineList; gline; gline = gline->gl_next)
789 *gl_size += sizeof(struct Gline);
790 *gl_size += gline->gl_user ? (strlen(gline->gl_user) + 1) : 0;
791 *gl_size += gline->gl_host ? (strlen(gline->gl_host) + 1) : 0;
792 *gl_size += gline->gl_reason ? (strlen(gline->gl_reason) + 1) : 0;