#include "../irc/irc.h" /* irc_send() */
#include "../lib/irc_string.h" /* IPtostr(), longtoduration(), durationtolong() */
#include "../lib/strlfunc.h"
+#include "../glines/glines.h"
/* used for *_free functions that need to warn users of certain things
i.e. hitting too many users in a (kill) or (gline) - declared in newsearch.c */
localdata->marker = nextchanmarker();
else if (ctx->searchcmd == reg_nicksearch)
localdata->marker = nextnickmarker();
+ else if (ctx->searchcmd == reg_whowassearch)
+ localdata->marker = nextwhowasmarker();
else {
free(localdata);
parseError = "gline: invalid search type";
struct gline_localdata *localdata;
nick *np;
chanindex *cip;
+ whowas *ww;
localdata = thenode->localdata;
if (ctx->searchcmd == reg_chansearch) {
cip = (chanindex *)theinput;
cip->marker = localdata->marker;
- localdata->count += cip->channel->users->totalusers;
+ if (cip->channel != NULL)
+ localdata->count += cip->channel->users->totalusers;
}
else {
np = (nick *)theinput;
- np->marker = localdata->marker;
+ if (ctx->searchcmd == reg_nicksearch)
+ np->marker = localdata->marker;
+ else {
+ ww = (whowas *)np->next;
+ ww->marker = localdata->marker;
+ }
localdata->count++;
}
return (void *)1;
}
-static int glineuser(nick *np, struct gline_localdata *localdata, time_t ti) {
+static int glineuser(glinebuf *gbuf, nick *np, struct gline_localdata *localdata, time_t ti) {
char msgbuf[512];
if (!IsOper(np) && !IsService(np) && !IsXOper(np)) {
nssnprintf(msgbuf, sizeof(msgbuf), localdata->reason, np);
- glinebynick(np, localdata->duration, msgbuf, 0, "newsearch");
+ glinebufaddbynick(gbuf, np, 0, "newsearch", msgbuf, getnettime() + localdata->duration, getnettime(), getnettime() + localdata->duration);
return 1;
}
struct gline_localdata *localdata;
nick *np, *nnp;
chanindex *cip, *ncip;
- int i, j, safe=0;
+ whowas *ww;
+ int i, j, hits, safe=0;
time_t ti = time(NULL);
+ glinebuf gbuf;
localdata = thenode->localdata;
return;
}
+ glinebufinit(&gbuf, 0);
+
if (ctx->searchcmd == reg_chansearch) {
for (i=0;i<CHANNELHASHSIZE;i++) {
for (cip=chantable[i];cip;cip=ncip) {
continue;
if ((np=getnickbynumeric(cip->channel->users->content[j]))) {
- if(!glineuser(np, localdata, ti))
+ if(!glineuser(&gbuf, np, localdata, ti))
safe++;
}
}
}
}
}
- }
- else {
+ } else if (ctx->searchcmd == reg_nicksearch) {
for (i=0;i<NICKHASHSIZE;i++) {
for (np=nicktable[i];np;np=nnp) {
nnp = np->next;
if (np->marker == localdata->marker) {
- if(!glineuser(np, localdata, ti))
+ if(!glineuser(&gbuf, np, localdata, ti))
safe++;
}
}
}
+ } else {
+ for (i = whowasoffset; i < whowasoffset + WW_MAXENTRIES; i++) {
+ ww = &whowasrecs[i % WW_MAXENTRIES];
+
+ if (ww->type == WHOWAS_UNUSED)
+ continue;
+
+ if (ww->marker == localdata->marker) {
+ if(!glineuser(&gbuf, &ww->nick, localdata, ti))
+ safe++;
+ }
+ }
}
+
+ glinebufcounthits(&gbuf, &hits, NULL);
+ glinebufcommit(&gbuf, 1);
+
if (safe)
ctx->reply(senderNSExtern, "Warning: your pattern matched privileged users (%d in total) - these have not been touched.", safe);
/* notify opers of the action */