- 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);
- }
- }
- }
- }
- else if (parc < 2 || *parv[1] == '\0')
- {
- /* Not enough args and a user; list glines */
- for (gline = GlobalGlineList; gline; gline = gline->next)
- sendto_one(cptr, rpl_str(RPL_GLIST), me.name, parv[0],
- gline->name, gline->host, gline->expire, gline->reason,
- GlineIsActive(gline) ? (GlineIsLocal(gline) ? " (local)" : "") :
- " (Inactive)");
- sendto_one(cptr, rpl_str(RPL_ENDOFGLIST), me.name, parv[0]);
+ if (IsMe(acptr)) {
+ if (agline) /* G-line already exists, so let's ignore it... */
+ return 0;
+
+ /* OK, create the local G-line */
+ Debug((DEBUG_DEBUG, "I am creating a local G-line here; target %s, "
+ "mask %s, operforce %s, action %s, expire %Tu, reason: %s",
+ target, mask, flags & GLINE_OPERFORCE ? "YES" : "NO",
+ action == GLINE_ACTIVATE ? "+" : "-", expire, reason));
+
+ return gline_add(cptr, sptr, mask, reason, expire, lastmod,
+ lifetime, flags | GLINE_ACTIVE);
+ }
+ } else if (IsMe(acptr)) { /* destroying a local G-line */
+ if (!agline) /* G-line doesn't exist, so let's complain... */
+ return send_reply(sptr, ERR_NOSUCHGLINE, mask);
+
+ /* Let's now destroy the G-line */;
+ Debug((DEBUG_DEBUG, "I am destroying a local G-line here; target %s, "
+ "mask %s, operforce %s, action %s", target, mask,
+ flags & GLINE_OPERFORCE ? "YES" : "NO",
+ action == GLINE_ACTIVATE ? "+" : "-"));
+
+ return gline_destroy(cptr, sptr, agline);
+ }
+
+ /* OK, we've converted arguments; if it's not for us, forward */
+ /* UPDATE NOTE: Once all servers are updated to u2.10.12.11, the
+ * format string in this sendcmdto_one() may be updated to omit
+ * <lastmod> for GLINE_ACTIVATE and to omit <expire>, <lastmod>,
+ * and <reason> for GLINE_DEACTIVATE.
+ */
+ assert(!IsMe(acptr));
+
+ Debug((DEBUG_DEBUG, "I am forwarding a local G-line to a remote server; "
+ "target %s, mask %s, operforce %s, action %c, expire %Tu, "
+ "lastmod %Tu, reason: %s", target, mask,
+ flags & GLINE_OPERFORCE ? "YES" : "NO",
+ action == GLINE_ACTIVATE ? '+' : '-', expire, CurrentTime,
+ reason));
+
+ sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%c%s %Tu %Tu :%s",
+ acptr, flags & GLINE_OPERFORCE ? "!" : "",
+ action == GLINE_ACTIVATE ? '+' : '-', mask,
+ expire - CurrentTime, CurrentTime, reason);
+
+ return 0; /* all done */