]> jfr.im git - irc/quakenet/newserv.git/blobdiff - glines/glines_buf.c
CHANSERV: fix issue where chanserv_relay doesn't wait for db to be loaded before...
[irc/quakenet/newserv.git] / glines / glines_buf.c
index 675711e0e4e5488ca6b7d5ae33edc69988f3e4f5..7053853171bdc98276f26e816d896c0777ff397a 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, (bits == 128) ? IPtostr(*ip) : CIDRtostr(*ip, bits));
 
   glinebufadd(gbuf, mask, creator, reason, expire, lastmod, lifetime);
 }
@@ -90,7 +90,19 @@ void glinebufaddbynick(glinebuf *gbuf, nick *np, int flags, const char *creator,
     snprintf(mask, sizeof(mask), "%s!*@*", np->nick);
     glinebufadd(gbuf, mask, creator, reason, expire, lastmod, lifetime);
   } else {
-    glinebufaddbyip(gbuf, np->ident, &np->p_ipaddr, 128, flags, creator, reason, expire, lastmod, lifetime);
+    glinebufaddbyip(gbuf, np->ident, &np->ipaddress, 128, flags, creator, reason, expire, lastmod, lifetime);
+  }
+}
+
+void glinebufaddbywhowas(glinebuf *gbuf, whowas *ww, int flags, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime) {
+  nick *np = &ww->nick;
+
+  if (flags & GLINE_ALWAYS_NICK) {
+    char mask[512];
+    snprintf(mask, sizeof(mask), "%s!*@*", np->nick);
+    glinebufadd(gbuf, mask, creator, reason, expire, lastmod, lifetime);
+  } else {
+    glinebufaddbyip(gbuf, np->ident, &np->ipaddress, 128, flags, creator, reason, expire, lastmod, lifetime);
   }
 }