]> jfr.im git - irc/quakenet/newserv.git/blobdiff - glines/glines_buf.c
Implement nick chasing for the block command.
[irc/quakenet/newserv.git] / glines / glines_buf.c
index d1a8cd30e4b01e44021a0cef3ea4b79478c59e4d..2a15e733458f60651becb805d28e566cb9cbf002 100644 (file)
@@ -79,7 +79,7 @@ void glinebufaddbyip(glinebuf *gbuf, const char *user, struct irc_in_addr *ip, u
   if (nodebits < bits)
     bits = nodebits;
 
-  snprintf(mask, sizeof(mask), "%s@%s", user, trusts_cidr2str(ip, bits));
+  snprintf(mask, sizeof(mask), "%s@%s", user, CIDRtostr(*ip, bits));
 
   glinebufadd(gbuf, mask, creator, reason, expire, lastmod, lifetime);
 }
@@ -94,6 +94,16 @@ void glinebufaddbynick(glinebuf *gbuf, nick *np, int flags, const char *creator,
   }
 }
 
+void glinebufaddbywhowas(glinebuf *gbuf, whowas *ww, int flags, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime) {
+  if (flags & GLINE_ALWAYS_NICK) {
+    char mask[512];
+    snprintf(mask, sizeof(mask), "%s!*@*", ww->nick);
+    glinebufadd(gbuf, mask, creator, reason, expire, lastmod, lifetime);
+  } else {
+    glinebufaddbyip(gbuf, ww->ident, &ww->ip, 128, flags, creator, reason, expire, lastmod, lifetime);
+  }
+}
+
 void glinebufcounthits(glinebuf *gbuf, int *users, int *channels) {
   gline *gl;
   int i, hit, slot;
@@ -298,7 +308,7 @@ int glinebufcommit(glinebuf *gbuf, int propagate) {
   glinebufcounthits(gbuf, &users, &channels);
 
   if (propagate && (users > MAXGLINEUSERHITS || channels > MAXGLINECHANNELHITS)) {
-    controlwall(NO_OPER, NL_GLINES, "G-Line buffer would hit %d users/%d channels. Not setting G-Lines.");
+    controlwall(NO_OPER, NL_GLINES_AUTO, "G-Line buffer would hit %d users/%d channels. Not setting G-Lines.");
     glinebufabort(gbuf);
     return 0;
   }