- struct Client* acptr = 0; /* Init. to avoid compiler warning. */
- struct Gline* gline;
- struct Gline* prev;
- char* user;
- char* host;
- int active;
- int ip_mask;
- int gtype = 0;
- time_t expire = 0;
-
- /*
- * Remove expired G-lines
- */
- gline_remove_expired(TStime());
-#ifdef BADCHAN
- /*
- * Remove expired bad channels
- */
- bad_channel_remove_expired(TStime());
-#endif
-
- if (IsServer(cptr)) {
- if (find_conf_byhost(cptr->confs, sptr->name, CONF_UWORLD)) {
- if (parc < 3 || (*parv[2] != '-' && (parc < 5 || *parv[4] == '\0')))
- return need_more_params(sptr, "GLINE");
-
- if (*parv[2] == '-') /* add mode or delete mode? */
- active = 0;
- else
- active = 1;
-
- if (*parv[2] == '+' || *parv[2] == '-')
- parv[2]++; /* step past mode indicator */
-
- /*
- * forward the message appropriately
- */
- if (0 == ircd_strcmp(parv[1], "*")) {
- /*
- * global!
- */
- sendto_serv_butone(cptr,
- active ? "%s " TOK_GLINE " %s +%s %s :%s" : "%s " TOK_GLINE " %s -%s",
- NumServ(sptr), parv[1], parv[2], parv[3], parv[4]);
- }
- else if ((
-#if 1
- /*
- * REMOVE THIS after all servers upgraded to 2.10.01 and
- * Uworld uses a numeric too
- */
- (strlen(parv[1]) != 1 && !(acptr = FindClient(parv[1])))) ||
- (strlen(parv[1]) == 1 &&
-#endif
- !(acptr = FindNServer(parv[1]))))
- return 0; /* no such server/user exists; forget it */
- else
-#if 1
-/*
- * REMOVE THIS after all servers upgraded to 2.10.01 and
- * Uworld uses a numeric too
- */
- if (IsServer(acptr) || !MyConnect(acptr))
-#endif
- {
- /* single destination */
- sendto_one(acptr,
- active ? "%s " TOK_GLINE " %s +%s %s :%s" : "%s " TOK_GLINE " %s -%s",
- NumServ(sptr), parv[1], parv[2], parv[3], parv[4]);
- return 0; /* only the intended destination
- should add this gline */
- }
-
- if (!(host = strchr(parv[2], '@'))) {
- /*
- * convert user@host no @'s; assume username is '*'
- */
- user = "*";
- host = parv[2];
- }
- else {
- user = parv[2];
- *(host++) = '\0'; /* break up string at the '@' */
- }
- ip_mask = check_if_ipmask(host); /* Store this boolean */
-#ifdef BADCHAN
- if ('#' == *host || '&' == *host || '+' == *host)
- gtype = 1; /* BAD CHANNEL GLINE */
-#endif
- for (gline = (gtype) ? BadChanGlineList : GlobalGlineList, prev = 0; gline;
- gline = gline->next)
- {
- if (0 == ircd_strcmp(gline->name, user) &&
- 0 == ircd_strcmp(gline->host, host))
- break;
- prev = gline;
- }
-
- if (!active && gline)
- {
- /*
- * removing the gline, notify opers
- */
- sendto_op_mask(SNO_GLINE, "%s removing %s for %s@%s", parv[0],
- gtype ? "BADCHAN" : "GLINE", gline->name, gline->host);
-
-#ifdef GPATH
- write_log(GPATH, "# " TIME_T_FMT " %s removing %s for %s@%s\n",
- TStime(), parv[0], gtype ? "BADCHAN" : "GLINE", gline->name,
- gline->host);
-#endif /* GPATH */
-
- free_gline(gline, prev); /* remove the gline */
- }
- else if (active)
- { /* must be adding a gline */
- expire = atoi(parv[3]) + TStime(); /* expire time? */
- if (gline && gline->expire < expire)
- { /* new expire time? */
- /* yes, notify the opers */
- sendto_op_mask(SNO_GLINE,
- "%s resetting expiration time on %s for %s@%s to " TIME_T_FMT,
- parv[0], gtype ? "BADCHAN" : "GLINE", gline->name, gline->host,
- expire);
-#ifdef GPATH
- write_log(GPATH, "# " TIME_T_FMT " %s resetting expiration time "
- "on %s for %s@%s to " TIME_T_FMT "\n",
- TStime(), parv[0], gtype ? "BADCHAN" : "GLINE",
- gline->name, gline->host, expire);
-#endif /* GPATH */
-
- gline->expire = expire; /* reset the expire time */
- }
- else if (!gline)
- { /* create gline */
- for (gline = (gtype) ? BadChanGlineList : GlobalGlineList; gline; gline = gline->next)
- if (!mmatch(gline->name, user) &&
- (ip_mask ? GlineIsIpMask(gline) : !GlineIsIpMask(gline)) &&
- !mmatch(gline->host, host))
- return 0; /* found an existing G-line that matches */
-
- /* add the line: */
- add_gline(sptr, ip_mask, host, parv[4], user, expire, 0);
- }
- }
- }