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);
}
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);
}
}
else
strftime(lastmod, sizeof(lastmod), "%d/%m/%y %H:%M:%S", localtime(&gl->lastmod));
- controlreply(spewto, "%-40s %-20s %-20s %-25s %s", glinetostring(gl), timebuf, lastmod, gl->creator->content, gl->reason->content);
+ controlreply(spewto, "%-40s %-20s %-20s %-25s %s", glinetostring(gl), timebuf, lastmod, gl->creator->content, gl->reason ? gl->reason->content : "");
}
controlreply(spewto, "Hits");
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;
}