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 != '$' && check_if_ipmask(host)) { /* mark if it's an IP mask */
153 /* Sanity check for dodgy IP masks
154 * Any mask featuring a digit after a wildcard will
155 * not behave as expected. */
156 for (seenwild=0,ch=host;*ch;ch++) {
157 if (*ch=='*' || *ch=='?')
159 if (IsDigit(*ch) && seenwild) {
166 /* It's bad - let's make it match 0.0.0.0/32 */
168 gline->ipnum.s_addr=0;
170 c_class = sscanf(host,"%d.%d.%d.%d/%d",
171 &ad[0],&ad[1],&ad[2],&ad[3], &bits2);
173 gline->bits=c_class*8;
176 ircd_snprintf(0, ipname, sizeof(ipname), "%d.%d.%d.%d", ad[0], ad[1],
178 gline->ipnum.s_addr = inet_addr(ipname);
180 Debug((DEBUG_DEBUG,"IP gline: %08x/%i",gline->ipnum.s_addr,gline->bits));
181 gline->gl_flags |= GLINE_IPMASK;
185 gline->gl_next = after->gl_next;
186 gline->gl_prev_p = &after->gl_next;
188 after->gl_next->gl_prev_p = &gline->gl_next;
189 after->gl_next = gline;
191 gline->gl_next = GlobalGlineList; /* then link it into list */
192 gline->gl_prev_p = &GlobalGlineList;
194 GlobalGlineList->gl_prev_p = &gline->gl_next;
195 GlobalGlineList = gline;
203 do_gline(struct Client *cptr, struct Client *sptr, struct Gline *gline)
205 struct Client *acptr;
206 int fd, retval = 0, tval;
208 if (!GlineIsActive(gline)) /* no action taken on inactive glines */
211 for (fd = HighestFd; fd >= 0; --fd) {
215 if ((acptr = LocalClientArray[fd])) {
216 if (!cli_user(acptr))
219 if (GlineIsRealName(gline)) { /* Realname Gline */
220 Debug((DEBUG_DEBUG,"Realname Gline: %s %s",(cli_info(acptr)),
222 if (match(gline->gl_user+2, cli_info(acptr)) != 0)
224 Debug((DEBUG_DEBUG,"Matched!"));
225 } else { /* Host/IP gline */
226 if (cli_user(acptr)->username &&
227 match(gline->gl_user, (cli_user(acptr))->username) != 0)
230 if (GlineIsIpMask(gline)) {
231 Debug((DEBUG_DEBUG,"IP gline: %08x %08x/%i",(cli_ip(cptr)).s_addr,gline->ipnum.s_addr,gline->bits));
232 if (((cli_ip(acptr)).s_addr & NETMASK(gline->bits)) != gline->ipnum.s_addr)
236 if (match(gline->gl_host, cli_sockhost(acptr)) != 0)
241 /* ok, here's one that got G-lined */
242 send_reply(acptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s",
245 /* let the ops know about it */
246 sendto_opmask_butone(0, SNO_GLINE, "G-line active for %s",
247 get_client_name(acptr, TRUE));
249 /* and get rid of him */
250 if ((tval = exit_client_msg(cptr, acptr, &me, "G-lined (%s)",
252 retval = tval; /* retain killed status */
259 * This routine implements the mask checking applied to local
260 * G-lines. Basically, host masks must have a minimum of two non-wild
261 * domain fields, and IP masks must have a minimum of 16 bits. If the
262 * mask has even one wild-card, OVERRIDABLE is returned, assuming the
263 * other check doesn't fail.
266 gline_checkmask(char *mask)
268 unsigned int flags = MASK_IP;
269 unsigned int dots = 0;
270 unsigned int ipmask = 0;
272 for (; *mask; mask++) { /* go through given mask */
273 if (*mask == '.') { /* it's a separator; advance positional wilds */
274 flags = (flags & ~MASK_WILD_MASK) | ((flags << 1) & MASK_WILD_MASK);
277 if ((flags & (MASK_IP | MASK_WILDS)) == MASK_IP)
278 ipmask += 8; /* It's an IP with no wilds, count bits */
279 } else if (*mask == '*' || *mask == '?')
280 flags |= MASK_WILD_0 | MASK_WILDS; /* found a wildcard */
281 else if (*mask == '/') { /* n.n.n.n/n notation; parse bit specifier */
283 ipmask = strtoul(mask, &mask, 10);
285 if (*mask || dots != 3 || ipmask > 32 || /* sanity-check to date */
286 (flags & (MASK_WILDS | MASK_IP)) != MASK_IP)
287 return CHECK_REJECTED; /* how strange... */
289 if (ipmask < 32) /* it's a masked address; mark wilds */
292 flags |= MASK_HALT; /* Halt the ipmask calculation */
294 break; /* get out of the loop */
295 } else if (!IsDigit(*mask)) {
296 flags &= ~MASK_IP; /* not an IP anymore! */
301 /* Sanity-check quads */
302 if (dots > 3 || (!(flags & MASK_WILDS) && dots < 3)) {
307 /* update bit count if necessary */
308 if ((flags & (MASK_IP | MASK_WILDS | MASK_HALT)) == MASK_IP)
311 /* Check to see that it's not too wide of a mask */
312 if (flags & MASK_WILDS &&
313 ((!(flags & MASK_IP) && (dots < 2 || flags & MASK_WILD_MASK)) ||
314 (flags & MASK_IP && ipmask < 16)))
315 return CHECK_REJECTED; /* to wide, reject */
317 /* Ok, it's approved; require override if it has wildcards, though */
318 return flags & MASK_WILDS ? CHECK_OVERRIDABLE : CHECK_APPROVED;
322 gline_propagate(struct Client *cptr, struct Client *sptr, struct Gline *gline)
324 if (GlineIsLocal(gline) || (IsUser(sptr) && !gline->gl_lastmod))
327 if (gline->gl_lastmod)
328 sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
329 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
330 gline->gl_host ? "@" : "",
331 gline->gl_host ? gline->gl_host : "",
332 gline->gl_expire - CurrentTime, gline->gl_lastmod,
335 sendcmdto_serv_butone(sptr, CMD_GLINE, cptr,
336 (GlineIsRemActive(gline) ?
337 "* +%s%s%s %Tu :%s" : "* -%s%s%s"),
339 gline->gl_host ? "@" : "",
340 gline->gl_host ? gline->gl_host : "",
341 gline->gl_expire - CurrentTime, gline->gl_reason);
347 gline_add(struct Client *cptr, struct Client *sptr, char *userhost,
348 char *reason, time_t expire, time_t lastmod, unsigned int flags)
350 struct Gline *agline;
351 char uhmask[USERLEN + HOSTLEN + 2];
355 assert(0 != userhost);
358 /* NO_OLD_GLINE allows *@#channel to work correctly */
359 if (*userhost == '#' || *userhost == '&'
360 # ifndef NO_OLD_GLINE
361 || ((userhost[2] == '#' || userhost[2] == '&') && (userhost[1] == '@'))
362 # endif /* OLD_GLINE */
364 if ((flags & GLINE_LOCAL) && !HasPriv(sptr, PRIV_LOCAL_BADCHAN))
365 return send_reply(sptr, ERR_NOPRIVILEGES);
367 flags |= GLINE_BADCHAN;
368 # ifndef NO_OLD_GLINE
369 if ((userhost[2] == '#' || userhost[2] == '&') && (userhost[1] == '@'))
372 # endif /* OLD_GLINE */
375 } else if (*userhost == '$'
376 # ifndef NO_OLD_GLINE
377 || userhost[2] == '$'
378 # endif /* OLD_GLINE */
380 switch (*userhost == '$' ? userhost[1] : userhost[3]) {
381 case 'R': flags |= GLINE_REALNAME; break;
383 /* uh, what to do here? */
384 /* The answer, my dear Watson, is we throw a protocol_violation()
386 return protocol_violation(sptr,"%s has been smoking the sweet leaf and sent me a whacky gline",cli_name(sptr));
389 user = (*userhost =='$' ? userhost : userhost+2);
392 canon_userhost(userhost, &user, &host, "*");
394 ircd_snprintf(0, uhmask, sizeof(uhmask), "%s@%s", user, host))
395 return send_reply(sptr, ERR_LONGMASK);
396 else if (MyUser(sptr) || (IsUser(sptr) && flags & GLINE_LOCAL)) {
397 switch (gline_checkmask(host)) {
398 case CHECK_OVERRIDABLE: /* oper overrided restriction */
399 if (flags & GLINE_OPERFORCE)
403 return send_reply(sptr, ERR_MASKTOOWIDE, uhmask);
407 if ((tmp = count_users(uhmask)) >=
408 feature_int(FEAT_GLINEMAXUSERCOUNT) && !(flags & GLINE_OPERFORCE))
409 return send_reply(sptr, ERR_TOOMANYUSERS, tmp);
414 * You cannot set a negative (or zero) expire time, nor can you set an
415 * expiration time for greater than GLINE_MAX_EXPIRE.
417 if (!(flags & GLINE_FORCE) && (expire <= 0 || expire > GLINE_MAX_EXPIRE)) {
418 if (!IsServer(sptr) && MyConnect(sptr))
419 send_reply(sptr, ERR_BADEXPIRE, expire);
423 expire += CurrentTime; /* convert from lifetime to timestamp */
426 sendto_opmask_butone(0, ircd_strncmp(reason, "AUTO", 4) ? SNO_GLINE :
427 SNO_AUTO, "%s adding %s %s for %s%s%s, expiring at "
429 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
431 cli_name((cli_user(sptr))->server),
432 (flags & GLINE_LOCAL) ? "local" : "global",
433 (flags & GLINE_BADCHAN) ? "BADCHAN" : "GLINE", user,
434 (flags & (GLINE_BADCHAN|GLINE_REALNAME)) ? "" : "@",
435 (flags & (GLINE_BADCHAN|GLINE_REALNAME)) ? "" : host,
436 expire + TSoffset, reason);
439 log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
440 "%#C adding %s %s for %s, expiring at %Tu: %s", sptr,
441 flags & GLINE_LOCAL ? "local" : "global",
442 flags & GLINE_BADCHAN ? "BADCHAN" : "GLINE", userhost,
443 expire + TSoffset, reason);
446 agline = make_gline(user, host, reason, expire, lastmod, flags);
448 if (!agline) /* if it overlapped, silently return */
451 gline_propagate(cptr, sptr, agline);
453 if (GlineIsBadChan(agline))
456 return do_gline(cptr, sptr, agline); /* knock off users if necessary */
460 gline_activate(struct Client *cptr, struct Client *sptr, struct Gline *gline,
461 time_t lastmod, unsigned int flags)
463 unsigned int saveflags = 0;
467 saveflags = gline->gl_flags;
469 if (flags & GLINE_LOCAL)
470 gline->gl_flags &= ~GLINE_LDEACT;
472 gline->gl_flags |= GLINE_ACTIVE;
474 if (gline->gl_lastmod) {
475 if (gline->gl_lastmod >= lastmod) /* force lastmod to increase */
478 gline->gl_lastmod = lastmod;
482 if ((saveflags & GLINE_ACTMASK) == GLINE_ACTIVE)
483 return 0; /* was active to begin with */
485 /* Inform ops and log it */
486 sendto_opmask_butone(0, SNO_GLINE, "%s activating global %s for %s%s%s, "
487 "expiring at %Tu: %s",
488 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
490 cli_name((cli_user(sptr))->server),
491 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
492 gline->gl_user, gline->gl_host ? "@" : "",
493 gline->gl_host ? gline->gl_host : "",
494 gline->gl_expire + TSoffset, gline->gl_reason);
496 log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
497 "%#C activating global %s for %s%s%s, expiring at %Tu: %s", sptr,
498 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", gline->gl_user,
499 gline->gl_host ? "@" : "",
500 gline->gl_host ? gline->gl_host : "",
501 gline->gl_expire + TSoffset, gline->gl_reason);
503 if (!(flags & GLINE_LOCAL)) /* don't propagate local changes */
504 gline_propagate(cptr, sptr, gline);
506 return GlineIsBadChan(gline) ? 0 : do_gline(cptr, sptr, gline);
510 gline_deactivate(struct Client *cptr, struct Client *sptr, struct Gline *gline,
511 time_t lastmod, unsigned int flags)
513 unsigned int saveflags = 0;
518 saveflags = gline->gl_flags;
520 if (GlineIsLocal(gline))
521 msg = "removing local";
522 else if (!gline->gl_lastmod && !(flags & GLINE_LOCAL)) {
523 msg = "removing global";
524 gline->gl_flags &= ~GLINE_ACTIVE; /* propagate a -<mask> */
526 msg = "deactivating global";
528 if (flags & GLINE_LOCAL)
529 gline->gl_flags |= GLINE_LDEACT;
531 gline->gl_flags &= ~GLINE_ACTIVE;
533 if (gline->gl_lastmod) {
534 if (gline->gl_lastmod >= lastmod)
537 gline->gl_lastmod = lastmod;
541 if ((saveflags & GLINE_ACTMASK) != GLINE_ACTIVE)
542 return 0; /* was inactive to begin with */
545 /* Inform ops and log it */
546 sendto_opmask_butone(0, SNO_GLINE, "%s %s %s for %s%s%s, expiring at %Tu: "
548 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
550 cli_name((cli_user(sptr))->server),
551 msg, GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
552 gline->gl_user, gline->gl_host ? "@" : "",
553 gline->gl_host ? gline->gl_host : "",
554 gline->gl_expire + TSoffset, gline->gl_reason);
556 log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
557 "%#C %s %s for %s%s%s, expiring at %Tu: %s", sptr, msg,
558 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", gline->gl_user,
559 gline->gl_host ? "@" : "",
560 gline->gl_host ? gline->gl_host : "",
561 gline->gl_expire + TSoffset, gline->gl_reason);
563 if (!(flags & GLINE_LOCAL)) /* don't propagate local changes */
564 gline_propagate(cptr, sptr, gline);
566 /* if it's a local gline or a Uworld gline (and not locally deactivated).. */
567 if (GlineIsLocal(gline) || (!gline->gl_lastmod && !(flags & GLINE_LOCAL)))
568 gline_free(gline); /* get rid of it */
574 gline_find(char *userhost, unsigned int flags)
577 struct Gline *sgline;
578 char *user, *host, *t_uh;
580 if (flags & (GLINE_BADCHAN | GLINE_ANY)) {
581 for (gline = BadChanGlineList; gline; gline = sgline) {
582 sgline = gline->gl_next;
584 if (gline->gl_expire <= CurrentTime)
586 else if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) ||
587 (flags & GLINE_LASTMOD && !gline->gl_lastmod))
589 else if ((flags & GLINE_EXACT ? ircd_strcmp(gline->gl_user, userhost) :
590 match(gline->gl_user, userhost)) == 0)
595 if ((flags & (GLINE_BADCHAN | GLINE_ANY)) == GLINE_BADCHAN ||
596 *userhost == '#' || *userhost == '&'
598 || userhost[2] == '#' || userhost[2] == '&'
599 #endif /* NO_OLD_GLINE */
603 DupString(t_uh, userhost);
604 canon_userhost(t_uh, &user, &host, 0);
609 for (gline = GlobalGlineList; gline; gline = sgline) {
610 sgline = gline->gl_next;
612 if (gline->gl_expire <= CurrentTime)
614 else if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) ||
615 (flags & GLINE_LASTMOD && !gline->gl_lastmod))
617 else if (flags & GLINE_EXACT) {
618 if (((gline->gl_host && host && ircd_strcmp(gline->gl_host, host) == 0)
619 || (!gline->gl_host && !host)) &&
620 ((!user && ircd_strcmp(gline->gl_user, "*") == 0) ||
621 ircd_strcmp(gline->gl_user, user) == 0))
624 if (((gline->gl_host && host && ircd_strcmp(gline->gl_host, host) == 0)
625 || (!gline->gl_host && !host)) &&
626 ((!user && ircd_strcmp(gline->gl_user, "*") == 0) ||
627 match(gline->gl_user, user) == 0))
638 gline_lookup(struct Client *cptr, unsigned int flags)
641 struct Gline *sgline;
643 for (gline = GlobalGlineList; gline; gline = sgline) {
644 sgline = gline->gl_next;
646 if (gline->gl_expire <= CurrentTime) {
651 if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) ||
652 (flags & GLINE_LASTMOD && !gline->gl_lastmod))
655 if (GlineIsRealName(gline)) {
656 Debug((DEBUG_DEBUG,"realname gline: '%s' '%s'",gline->gl_user,cli_info(cptr)));
657 if (match(gline->gl_user+2, cli_info(cptr)) != 0)
663 if (match(gline->gl_user, (cli_user(cptr))->username) != 0)
666 if (GlineIsIpMask(gline)) {
667 Debug((DEBUG_DEBUG,"IP gline: %08x %08x/%i",(cli_ip(cptr)).s_addr,gline->ipnum.s_addr,gline->bits));
668 if (((cli_ip(cptr)).s_addr & NETMASK(gline->bits)) != gline->ipnum.s_addr)
672 if (match(gline->gl_host, (cli_user(cptr))->realhost) != 0)
685 gline_free(struct Gline *gline)
689 *gline->gl_prev_p = gline->gl_next; /* squeeze this gline out */
691 gline->gl_next->gl_prev_p = gline->gl_prev_p;
693 MyFree(gline->gl_user); /* free up the memory */
695 MyFree(gline->gl_host);
696 MyFree(gline->gl_reason);
701 gline_burst(struct Client *cptr)
704 struct Gline *sgline;
706 for (gline = GlobalGlineList; gline; gline = sgline) { /* all glines */
707 sgline = gline->gl_next;
709 if (gline->gl_expire <= CurrentTime) /* expire any that need expiring */
711 else if (!GlineIsLocal(gline) && gline->gl_lastmod)
712 sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
713 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
714 gline->gl_host ? "@" : "",
715 gline->gl_host ? gline->gl_host : "",
716 gline->gl_expire - CurrentTime, gline->gl_lastmod,
720 for (gline = BadChanGlineList; gline; gline = sgline) { /* all glines */
721 sgline = gline->gl_next;
723 if (gline->gl_expire <= CurrentTime) /* expire any that need expiring */
725 else if (!GlineIsLocal(gline) && gline->gl_lastmod)
726 sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s %Tu %Tu :%s",
727 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
728 gline->gl_expire - CurrentTime, gline->gl_lastmod,
734 gline_resend(struct Client *cptr, struct Gline *gline)
736 if (GlineIsLocal(gline) || !gline->gl_lastmod)
739 sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
740 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
741 gline->gl_host ? "@" : "",
742 gline->gl_host ? gline->gl_host : "",
743 gline->gl_expire - CurrentTime, gline->gl_lastmod,
750 gline_list(struct Client *sptr, char *userhost)
753 struct Gline *sgline;
756 if (!(gline = gline_find(userhost, GLINE_ANY))) /* no such gline */
757 return send_reply(sptr, ERR_NOSUCHGLINE, userhost);
759 /* send gline information along */
760 send_reply(sptr, RPL_GLIST, gline->gl_user,
761 gline->gl_host ? "@" : "",
762 gline->gl_host ? gline->gl_host : "",
763 gline->gl_expire + TSoffset,
764 GlineIsLocal(gline) ? cli_name(&me) : "*",
765 GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
767 for (gline = GlobalGlineList; gline; gline = sgline) {
768 sgline = gline->gl_next;
770 if (gline->gl_expire <= CurrentTime)
773 send_reply(sptr, RPL_GLIST, gline->gl_user,
774 gline->gl_host ? "@" : "",
775 gline->gl_host ? gline->gl_host : "",
776 gline->gl_expire + TSoffset,
777 GlineIsLocal(gline) ? cli_name(&me) : "*",
778 GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
781 for (gline = BadChanGlineList; gline; gline = sgline) {
782 sgline = gline->gl_next;
784 if (gline->gl_expire <= CurrentTime)
787 send_reply(sptr, RPL_GLIST, gline->gl_user, "", "",
788 gline->gl_expire + TSoffset,
789 GlineIsLocal(gline) ? cli_name(&me) : "*",
790 GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
794 /* end of gline information */
795 return send_reply(sptr, RPL_ENDOFGLIST);
799 gline_stats(struct Client *sptr, struct StatDesc *sd, int stat,
803 struct Gline *sgline;
805 for (gline = GlobalGlineList; gline; gline = sgline) {
806 sgline = gline->gl_next;
808 if (gline->gl_expire <= CurrentTime)
811 send_reply(sptr, RPL_STATSGLINE, 'G', gline->gl_user,
812 gline->gl_host ? "@" : "",
813 gline->gl_host ? gline->gl_host : "",
814 gline->gl_expire + TSoffset, gline->gl_reason);
819 gline_memory_count(size_t *gl_size)
824 for (gline = GlobalGlineList; gline; gline = gline->gl_next)
827 *gl_size += sizeof(struct Gline);
828 *gl_size += gline->gl_user ? (strlen(gline->gl_user) + 1) : 0;
829 *gl_size += gline->gl_host ? (strlen(gline->gl_host) + 1) : 0;
830 *gl_size += gline->gl_reason ? (strlen(gline->gl_reason) + 1) : 0;