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%s%s, expiring at %Tu: %s", sptr,
402 flags & GLINE_LOCAL ? "local" : "global",
403 flags & GLINE_BADCHAN ? "BADCHAN" : "GLINE", user,
404 flags & (GLINE_BADCHAN|GLINE_REALNAME) ? "" : "@",
405 flags & (GLINE_BADCHAN|GLINE_REALNAME) ? "" : host,
406 expire + TSoffset, reason);
409 agline = make_gline(user, host, reason, expire, lastmod, flags);
411 if (!agline) /* if it overlapped, silently return */
414 gline_propagate(cptr, sptr, agline);
416 if (GlineIsBadChan(agline))
419 return do_gline(cptr, sptr, agline); /* knock off users if necessary */
423 gline_activate(struct Client *cptr, struct Client *sptr, struct Gline *gline,
424 time_t lastmod, unsigned int flags)
426 unsigned int saveflags = 0;
430 saveflags = gline->gl_flags;
432 if (flags & GLINE_LOCAL)
433 gline->gl_flags &= ~GLINE_LDEACT;
435 gline->gl_flags |= GLINE_ACTIVE;
437 if (gline->gl_lastmod) {
438 if (gline->gl_lastmod >= lastmod) /* force lastmod to increase */
441 gline->gl_lastmod = lastmod;
445 if ((saveflags & GLINE_ACTMASK) == GLINE_ACTIVE)
446 return 0; /* was active to begin with */
448 /* Inform ops and log it */
449 sendto_opmask_butone(0, SNO_GLINE, "%s activating global %s for %s%s%s, "
450 "expiring at %Tu: %s",
451 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
453 cli_name((cli_user(sptr))->server),
454 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
455 gline->gl_user, gline->gl_host ? "@" : "",
456 gline->gl_host ? gline->gl_host : "",
457 gline->gl_expire + TSoffset, gline->gl_reason);
459 log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
460 "%#C activating global %s for %s%s%s, expiring at %Tu: %s", sptr,
461 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", gline->gl_user,
462 gline->gl_host ? "@" : "",
463 gline->gl_host ? gline->gl_host : "",
464 gline->gl_expire + TSoffset, gline->gl_reason);
466 if (!(flags & GLINE_LOCAL)) /* don't propagate local changes */
467 gline_propagate(cptr, sptr, gline);
469 return GlineIsBadChan(gline) ? 0 : do_gline(cptr, sptr, gline);
473 gline_deactivate(struct Client *cptr, struct Client *sptr, struct Gline *gline,
474 time_t lastmod, unsigned int flags)
476 unsigned int saveflags = 0;
481 saveflags = gline->gl_flags;
483 if (GlineIsLocal(gline))
484 msg = "removing local";
485 else if (!gline->gl_lastmod && !(flags & GLINE_LOCAL)) {
486 msg = "removing global";
487 gline->gl_flags &= ~GLINE_ACTIVE; /* propagate a -<mask> */
489 msg = "deactivating global";
491 if (flags & GLINE_LOCAL)
492 gline->gl_flags |= GLINE_LDEACT;
494 gline->gl_flags &= ~GLINE_ACTIVE;
496 if (gline->gl_lastmod) {
497 if (gline->gl_lastmod >= lastmod)
500 gline->gl_lastmod = lastmod;
504 if ((saveflags & GLINE_ACTMASK) != GLINE_ACTIVE)
505 return 0; /* was inactive to begin with */
508 /* Inform ops and log it */
509 sendto_opmask_butone(0, SNO_GLINE, "%s %s %s for %s%s%s, expiring at %Tu: "
511 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
513 cli_name((cli_user(sptr))->server),
514 msg, GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
515 gline->gl_user, gline->gl_host ? "@" : "",
516 gline->gl_host ? gline->gl_host : "",
517 gline->gl_expire + TSoffset, gline->gl_reason);
519 log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
520 "%#C %s %s for %s%s%s, expiring at %Tu: %s", sptr, msg,
521 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", gline->gl_user,
522 gline->gl_host ? "@" : "",
523 gline->gl_host ? gline->gl_host : "",
524 gline->gl_expire + TSoffset, gline->gl_reason);
526 if (!(flags & GLINE_LOCAL)) /* don't propagate local changes */
527 gline_propagate(cptr, sptr, gline);
529 /* if it's a local gline or a Uworld gline (and not locally deactivated).. */
530 if (GlineIsLocal(gline) || (!gline->gl_lastmod && !(flags & GLINE_LOCAL)))
531 gline_free(gline); /* get rid of it */
537 gline_find(char *userhost, unsigned int flags)
540 struct Gline *sgline;
541 char *user, *host, *t_uh;
543 if (flags & (GLINE_BADCHAN | GLINE_ANY)) {
544 for (gline = BadChanGlineList; gline; gline = sgline) {
545 sgline = gline->gl_next;
547 if (gline->gl_expire <= CurrentTime)
549 else if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) ||
550 (flags & GLINE_LASTMOD && !gline->gl_lastmod))
552 else if ((flags & GLINE_EXACT ? ircd_strcmp(gline->gl_user, userhost) :
553 match(gline->gl_user, userhost)) == 0)
558 if ((flags & (GLINE_BADCHAN | GLINE_ANY)) == GLINE_BADCHAN ||
559 *userhost == '#' || *userhost == '&')
562 DupString(t_uh, userhost);
563 canon_userhost(t_uh, &user, &host, 0);
568 for (gline = GlobalGlineList; gline; gline = sgline) {
569 sgline = gline->gl_next;
571 if (gline->gl_expire <= CurrentTime)
573 else if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) ||
574 (flags & GLINE_LASTMOD && !gline->gl_lastmod))
576 else if (flags & GLINE_EXACT) {
577 if (((gline->gl_host && host && ircd_strcmp(gline->gl_host, host) == 0)
578 || (!gline->gl_host && !host)) &&
579 ((!user && ircd_strcmp(gline->gl_user, "*") == 0) ||
580 ircd_strcmp(gline->gl_user, user) == 0))
583 if (((gline->gl_host && host && ircd_strcmp(gline->gl_host, host) == 0)
584 || (!gline->gl_host && !host)) &&
585 ((!user && ircd_strcmp(gline->gl_user, "*") == 0) ||
586 match(gline->gl_user, user) == 0))
597 gline_lookup(struct Client *cptr, unsigned int flags)
600 struct Gline *sgline;
602 for (gline = GlobalGlineList; gline; gline = sgline) {
603 sgline = gline->gl_next;
605 if (gline->gl_expire <= CurrentTime) {
610 if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) ||
611 (flags & GLINE_LASTMOD && !gline->gl_lastmod))
614 if (GlineIsRealName(gline)) {
615 Debug((DEBUG_DEBUG,"realname gline: '%s' '%s'",gline->gl_user,cli_info(cptr)));
616 if (match(gline->gl_user+2, cli_info(cptr)) != 0)
618 if (!GlineIsActive(gline))
623 if (match(gline->gl_user, (cli_user(cptr))->username) != 0)
626 if (GlineIsIpMask(gline)) {
628 char tbuf1[SOCKIPLEN], tbuf2[SOCKIPLEN];
629 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));
631 if (!ipmask_check(&cli_ip(cptr), &gline->gl_addr, gline->gl_bits))
635 if (match(gline->gl_host, (cli_user(cptr))->realhost) != 0)
639 if (GlineIsActive(gline))
649 gline_free(struct Gline *gline)
653 *gline->gl_prev_p = gline->gl_next; /* squeeze this gline out */
655 gline->gl_next->gl_prev_p = gline->gl_prev_p;
657 MyFree(gline->gl_user); /* free up the memory */
659 MyFree(gline->gl_host);
660 MyFree(gline->gl_reason);
665 gline_burst(struct Client *cptr)
668 struct Gline *sgline;
670 for (gline = GlobalGlineList; gline; gline = sgline) { /* all glines */
671 sgline = gline->gl_next;
673 if (gline->gl_expire <= CurrentTime) /* expire any that need expiring */
675 else if (!GlineIsLocal(gline) && gline->gl_lastmod)
676 sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
677 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
678 gline->gl_host ? "@" : "",
679 gline->gl_host ? gline->gl_host : "",
680 gline->gl_expire - CurrentTime, gline->gl_lastmod,
684 for (gline = BadChanGlineList; gline; gline = sgline) { /* all glines */
685 sgline = gline->gl_next;
687 if (gline->gl_expire <= CurrentTime) /* expire any that need expiring */
689 else if (!GlineIsLocal(gline) && gline->gl_lastmod)
690 sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s %Tu %Tu :%s",
691 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
692 gline->gl_expire - CurrentTime, gline->gl_lastmod,
698 gline_resend(struct Client *cptr, struct Gline *gline)
700 if (GlineIsLocal(gline) || !gline->gl_lastmod)
703 sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
704 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
705 gline->gl_host ? "@" : "",
706 gline->gl_host ? gline->gl_host : "",
707 gline->gl_expire - CurrentTime, gline->gl_lastmod,
714 gline_list(struct Client *sptr, char *userhost)
717 struct Gline *sgline;
720 if (!(gline = gline_find(userhost, GLINE_ANY))) /* no such gline */
721 return send_reply(sptr, ERR_NOSUCHGLINE, userhost);
723 /* send gline information along */
724 send_reply(sptr, RPL_GLIST, gline->gl_user,
725 gline->gl_host ? "@" : "",
726 gline->gl_host ? gline->gl_host : "",
727 gline->gl_expire + TSoffset,
728 GlineIsLocal(gline) ? cli_name(&me) : "*",
729 GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
731 for (gline = GlobalGlineList; gline; gline = sgline) {
732 sgline = gline->gl_next;
734 if (gline->gl_expire <= CurrentTime)
737 send_reply(sptr, RPL_GLIST, gline->gl_user,
738 gline->gl_host ? "@" : "",
739 gline->gl_host ? gline->gl_host : "",
740 gline->gl_expire + TSoffset,
741 GlineIsLocal(gline) ? cli_name(&me) : "*",
742 GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
745 for (gline = BadChanGlineList; gline; gline = sgline) {
746 sgline = gline->gl_next;
748 if (gline->gl_expire <= CurrentTime)
751 send_reply(sptr, RPL_GLIST, gline->gl_user, "", "",
752 gline->gl_expire + TSoffset,
753 GlineIsLocal(gline) ? cli_name(&me) : "*",
754 GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
758 /* end of gline information */
759 return send_reply(sptr, RPL_ENDOFGLIST);
763 gline_stats(struct Client *sptr, struct StatDesc *sd, int stat,
767 struct Gline *sgline;
769 for (gline = GlobalGlineList; gline; gline = sgline) {
770 sgline = gline->gl_next;
772 if (gline->gl_expire <= CurrentTime)
775 send_reply(sptr, RPL_STATSGLINE, 'G', gline->gl_user,
776 gline->gl_host ? "@" : "",
777 gline->gl_host ? gline->gl_host : "",
778 gline->gl_expire + TSoffset, gline->gl_reason);
783 gline_memory_count(size_t *gl_size)
788 for (gline = GlobalGlineList; gline; gline = gline->gl_next)
791 *gl_size += sizeof(struct Gline);
792 *gl_size += gline->gl_user ? (strlen(gline->gl_user) + 1) : 0;
793 *gl_size += gline->gl_host ? (strlen(gline->gl_host) + 1) : 0;
794 *gl_size += gline->gl_reason ? (strlen(gline->gl_reason) + 1) : 0;