#include "../lib/stringbuf.h"
#include "../core/hooks.h"
#include "../server/server.h"
+#include "../lib/strlfunc.h"
+#include <stdint.h>
#define INSTANT_IDENT_GLINE 1
#define INSTANT_HOST_GLINE 2
#define DELAYED_HOST_GLINE 5
#define DELAYED_KILL 6
-MODULE_VERSION("");
+#define RESERVED_NICK_GLINE_DURATION 3600 /* 1h */
+
+MODULE_VERSION("1.44");
typedef struct rg_glinenode {
nick *np;
struct rg_delay *next;
} rg_delay;
+#define GLINE_HEADER " ID Expires Set by Class Type Last seen (ago) Hits(p) Hits Reason"
+
rg_delay *rg_delays;
void rg_setdelay(nick *np, struct rg_struct *reason, short punish);
void rg_dodelay(void *arg);
void rg_dogline(struct rg_glinelist *gll, nick *np, struct rg_struct *rp, char *matched);
+void rg_flush_schedule(void *arg);
+
+static char *gvhost(nick *np);
static DBModuleIdentifier dbid;
static unsigned long highestid = 0;
static int attached = 0, started = 0;
-static const char *classes[] = { "drone", "proxy", "spam", "fakeauth", "other", (char *)0 };
+static unsigned int getrgmarker(void);
+
+#define RESERVED_NICK_CLASS "reservednick"
+/* shadowserver only reports classes[0] */
+static const char *classes[] = { "drone", "proxy", "spam", "other", RESERVED_NICK_CLASS, (char *)0 };
void _init(void) {
sstring *max_casualties, *max_spew, *expiry_time, *max_per_gline;
deleteschedule(rg_schedule, &rg_checkexpiry, NULL);
rg_schedule = NULL;
}
-
+
+ deleteallschedules(rg_flush_schedule);
+ rg_flush_schedule(NULL);
+
for(gp=rg_list;gp;) {
oldgp = gp;
gp = gp->next;
}
}
+static int ignorable_nick(nick *np) {
+ if(IsOper(np) || IsService(np) || IsXOper(np) || SIsService(&serverlist[homeserver(np->numeric)]))
+ return 1;
+ return 0;
+}
+
void rg_checkexpiry(void *arg) {
struct rg_struct *rp = rg_list, *lp = NULL;
time_t current = time(NULL);
while(rp) {
if (current >= rp->expires) {
+ dbquery("DELETE FROM regexglines WHERE id = %d", rp->id);
if (lp) {
lp->next = rp->next;
rg_freestruct(rp);
static void rg_shadowserver(nick *np, struct rg_struct *reason, int type) {
char buf[1024];
+
+ if(reason->class != classes[0]) /* drone */
+ return;
+
snprintf(buf, sizeof(buf), "regex-ban %lu %s!%s@%s %s %s", time(NULL), np->nick, np->ident, np->host->name->content, reason->mask->content, serverlist[homeserver(np->numeric)].name->content);
triggerhook(HOOK_SHADOW_SERVER, (void *)buf);
}
if ((delay->reason->type == DELAYED_KILL) || (usercount > rg_max_per_gline)) {
- if (IsAccount(delay->np)) {
- controlwall(NO_OPER, NL_HITS, "%s!%s@%s/%s matched delayed kill regex %08lx (class: %s)", delay->np->nick, delay->np->ident, delay->np->host->name->content, delay->np->authname, delay->reason->glineid, delay->reason->class);
- } else {
- controlwall(NO_OPER, NL_HITS, "%s!%s@%s matched delayed kill regex %08lx (class: %s)", delay->np->nick, delay->np->ident, delay->np->host->name->content, delay->reason->glineid, delay->reason->class);
- }
+ controlwall(NO_OPER, NL_HITS, "%s matched delayed kill regex %08lx (class: %s)", gvhost(delay->np), delay->reason->glineid, delay->reason->class);
rg_shadowserver(delay->np, delay->reason, DELAYED_KILL);
killuser(NULL, delay->np, "%s (ID: %08lx)", delay->reason->reason->content, delay->reason->glineid);
}
if (delay->reason->type == DELAYED_IDENT_GLINE) {
- if (IsAccount(delay->np)) {
- controlwall(NO_OPER, NL_HITS, "%s!%s@%s/%s matched delayed user@host gline regex %08lx (class: %s, hit %d user%s)", delay->np->nick, delay->np->ident, delay->np->host->name->content, delay->np->authname, delay->reason->glineid, delay->reason->class, usercount, (usercount!=1)?"s":"");
- } else {
- controlwall(NO_OPER, NL_HITS, "%s!%s@%s matched delayed user@host gline regex %08lx (class: %s, hit %d user%s)", delay->np->nick, delay->np->ident, delay->np->host->name->content, delay->reason->glineid, delay->reason->class, usercount, (usercount!=1)?"s":"");
- }
+ controlwall(NO_OPER, NL_HITS, "%s matched delayed user@host gline regex %08lx (class: %s, hit %d user%s)", gvhost(delay->np), delay->reason->glineid, delay->reason->class, usercount, (usercount!=1)?"s":"");
} else if (delay->reason->type == DELAYED_HOST_GLINE) {
- if (IsAccount(delay->np)) {
- controlwall(NO_OPER, NL_HITS, "%s!%s@%s/%s matched delayed *@host gline regex %08lx (class: %s, hit %d user%s)", delay->np->nick, delay->np->ident, delay->np->host->name->content, delay->np->authname, delay->reason->glineid, delay->reason->class, usercount, (usercount!=1)?"s":"");
- } else {
- controlwall(NO_OPER, NL_HITS, "%s!%s@%s matched delayed *@host gline regex %08lx (class: %s, hit %d user%s)", delay->np->nick, delay->np->ident, delay->np->host->name->content, delay->reason->glineid, delay->reason->class, usercount, (usercount!=1)?"s":"");
- }
+ controlwall(NO_OPER, NL_HITS, "%s matched delayed *@host gline regex %08lx (class: %s, hit %d user%s)", gvhost(delay->np), delay->reason->glineid, delay->reason->class, usercount, (usercount!=1)?"s":"");
} else {
return;
}
rg_shadowserver(delay->np, delay->reason, delay->reason->type);
- irc_send("%s GL * +%s %d %d :AUTO: %s (ID: %08lx)\r\n", mynumeric->content, hostname, rg_expiry_time, time(NULL), delay->reason->reason->content, delay->reason->glineid);
+ irc_send("%s GL * +%s %d %jd :AUTO: %s (ID: %08lx)\r\n", mynumeric->content, hostname, rg_expiry_time, (intmax_t)time(NULL), delay->reason->reason->content, delay->reason->glineid);
rg_deletedelay(delay);
}
for(nn=gll->start;nn;nn=pn) {
pn = nn->next;
if(nn->punish == INSTANT_KILL) {
- if ( IsAccount(nn->np) ) {
- controlwall(NO_OPER, NL_HITS, "%s!%s@%s/%s matched kill regex %08lx (class: %s)", nn->np->nick, nn->np->ident, nn->np->host->name->content, nn->np->authname, nn->reason->glineid, nn->reason->class);
- } else {
- controlwall(NO_OPER, NL_HITS, "%s!%s@%s matched kill regex %08lx (class: %s)", nn->np->nick, nn->np->ident, nn->np->host->name->content, nn->reason->glineid, nn->reason->class);
- }
+ controlwall(NO_OPER, NL_HITS, "%s matched kill regex %08lx (class: %s)", gvhost(nn->np), nn->reason->glineid, nn->reason->class);
rg_shadowserver(nn->np, nn->reason, nn->punish);
killuser(NULL, nn->np, "%s (ID: %08lx)", nn->reason->reason->content, nn->reason->glineid);
return;
}
- if (dbnumfields(dbres) != 7) {
+ if (dbnumfields(dbres) != 9) {
Error("regexgline", ERR_ERROR, "DB format error");
return;
}
while(dbfetchrow(dbres)) {
- unsigned long id;
+ unsigned long id, hitssaved;
+ time_t lastseen;
char *gline, *setby, *reason, *expires, *type, *class;
id = strtoul(dbgetvalue(dbres, 0), NULL, 10);
type = dbgetvalue(dbres, 5);
class = dbgetvalue(dbres, 6);
- if (!rg_newsstruct(id, gline, setby, reason, expires, type, 0, class))
- dbquery("DELETE FROM regexgline.glines WHERE id = %u", id);
+ lastseen = strtoul(dbgetvalue(dbres, 7), NULL, 10);
+ hitssaved = strtoul(dbgetvalue(dbres, 8), NULL, 10);
+
+ if (!rg_newsstruct(id, gline, setby, reason, expires, type, 0, class, lastseen, hitssaved))
+ dbquery("DELETE FROM regexgline.glines WHERE id = %lu", id);
}
dbclear(dbres);
"Duration is represented as 3d, 3M etc.\n"
"Class is one of the following: %s\n"
"Type is an integer which represents the following:\n"
- "1 - Instant USER@IP GLINE\n"
- "2 - Instant *@IP GLINE\n"
- "3 - Instant KILL\n"
- "4 - Delayed USER@IP GLINE\n"
- "5 - Delayed *@IP GLINE\n"
- "6 - Delayed KILL",
+ "1 - Instant USER@IP GLINE (igu)\n"
+ "2 - Instant *@IP GLINE (igh)\n"
+ "3 - Instant KILL (ik)\n"
+ "4 - Delayed USER@IP GLINE (dgu)\n"
+ "5 - Delayed *@IP GLINE (dgh)\n"
+ "6 - Delayed KILL (dk)\n"
+ "Note that some classes may have additional side effects (e.g. 'reservednick' also sets nick style glines).",
allclasses);
registercontrolhelpcmd("regexgline", NO_OPER, 5, &rg_gline, helpbuf);
rg_startup();
rg_schedule = schedulerecurring(time(NULL) + 1, 0, 1, rg_checkexpiry, NULL);
+ schedulerecurring(time(NULL) + 60, 0, 60, rg_flush_schedule, NULL);
}
void rg_dbload(void) {
dbattach("regexgline");
- dbcreatequery("CREATE TABLE regexgline.glines (id INT NOT NULL PRIMARY KEY, gline TEXT NOT NULL, setby VARCHAR(%d) NOT NULL, reason VARCHAR(%d) NOT NULL, expires INT NOT NULL, type INT NOT NULL DEFAULT 1, class TEXT NOT NULL)", ACCOUNTLEN, RG_REASON_MAX);
+ dbcreatequery("CREATE TABLE regexgline.glines (id INT NOT NULL PRIMARY KEY, gline TEXT NOT NULL, setby VARCHAR(%d) NOT NULL, reason VARCHAR(%d) NOT NULL, expires INT NOT NULL, type INT NOT NULL DEFAULT 1, class TEXT NOT NULL, lastseen INT DEFAULT 0, hits INT DEFAULT 0)", ACCOUNTLEN, RG_REASON_MAX);
dbcreatequery("CREATE TABLE regexgline.clog (host VARCHAR(%d) NOT NULL, account VARCHAR(%d) NOT NULL, event TEXT NOT NULL, arg TEXT NOT NULL, ts TIMESTAMP)", RG_MASKLEN - 1, ACCOUNTLEN);
dbcreatequery("CREATE TABLE regexgline.glog (glineid INT NOT NULL, ts TIMESTAMP, nickname VARCHAR(%d) NOT NULL, username VARCHAR(%d) NOT NULL, hostname VARCHAR(%d) NOT NULL, realname VARCHAR(%d))", NICKLEN, USERLEN, HOSTLEN, REALLEN);
hostlen = RGBuildHostname(hostname, np);
- if(IsOper(np) || IsService(np) || IsXOper(np))
+ if(ignorable_nick(np))
return;
for(rp=rg_list;rp;rp=rp->next) {
dbescapestring(eereason, reason, strlen(reason));
highestid = highestid + 1;
- dbquery("INSERT INTO regexgline.glines (id, gline, setby, reason, expires, type, class) VALUES (%d, '%s', '%s', '%s', %d, %c, '%s')", highestid, eemask, eesetby, eereason, realexpiry, type, eeclass);
- rp = rg_newsstruct(highestid, regex, np->nick, reason, "", cargv[2], realexpiry, class);
+ dbquery("INSERT INTO regexgline.glines (id, gline, setby, reason, expires, type, class, lastseen, hits) VALUES (%lu, '%s', '%s', '%s', %lu, %c, '%s', 0, 0)", highestid, eemask, eesetby, eereason, realexpiry, type, eeclass);
+ rp = rg_newsstruct(highestid, regex, np->nick, reason, "", cargv[2], realexpiry, class, 0, 0);
rg_initglinelist(&gll);
for(j=0;j<NICKHASHSIZE;j++) {
for(tnp=nicktable[j];tnp;tnp=tnp->next) {
- if(IsOper(tnp) || IsService(tnp) || IsXOper(tnp))
+ if(ignorable_nick(tnp))
continue;
hostlen = RGBuildHostname(hostname, tnp);
} else {
struct rg_struct *rp;
unsigned long id = 0;
- int i;
+ int i, longest = 0;
+ unsigned int m;
for(i=0;i<8;i++) {
if(0xff == rc_hexlookup[(int)cargv[0][i]]) {
}
}
- controlreply(np, "Mask Expires Set by Type Reason");
+ m = getrgmarker();
+ controlreply(np, GLINE_HEADER);
+ for(rp=rg_list;rp;rp=rp->next) {
+ if(id == rp->glineid) {
+ rp->marker = m;
+ if(rp->mask->length > longest)
+ longest = rp->mask->length;
+ }
+ }
+
for(rp=rg_list;rp;rp=rp->next)
- if(id == rp->glineid)
- rg_displaygline(np, rp);
+ if(rp->marker == m)
+ rg_displaygline(np, rp, longest);
controlreply(np, "Done.");
return CMD_OK;
int rg_glist(void *source, int cargc, char **cargv) {
nick *np = (nick *)source;
struct rg_struct *rp;
+ int longest = 0;
if(cargc) {
int erroroffset;
pcre *regex;
pcre_extra *hint;
const char *error;
-
+ unsigned int m;
+
if(!(regex = pcre_compile(cargv[0], RG_PCREFLAGS, &error, &erroroffset, NULL))) {
controlreply(np, "Error compiling expression %s at offset %d: %s", cargv[0], erroroffset, error);
return CMD_ERROR;
return CMD_ERROR;
}
}
-
+
+ m = getrgmarker();
rg_logevent(np, "regexglist", "%s", cargv[0]);
- controlreply(np, "Mask Expires Set by Class Type Reason");
+ controlreply(np, GLINE_HEADER);
+ for(rp=rg_list;rp;rp=rp->next) {
+ if(pcre_exec(regex, hint, rp->mask->content, rp->mask->length, 0, 0, NULL, 0) >= 0) {
+ rp->marker = m;
+ if(rp->mask->length > longest)
+ longest = rp->mask->length;
+ }
+ }
+
for(rp=rg_list;rp;rp=rp->next)
- if(pcre_exec(regex, hint, rp->mask->content, rp->mask->length, 0, 0, NULL, 0) >= 0)
- rg_displaygline(np, rp);
-
+ if(rp->marker == m)
+ rg_displaygline(np, rp, longest);
+
pcre_free(regex);
if(hint)
pcre_free(hint);
} else {
- rg_logevent(np, "regexglist", "");
- controlreply(np, "Mask Expires Set by Class Type Reason");
+ rg_logevent(np, "regexglist", "%s", "");
+ controlreply(np, GLINE_HEADER);
+ for(rp=rg_list;rp;rp=rp->next)
+ if(rp->mask->length > longest)
+ longest = rp->mask->length;
+
for(rp=rg_list;rp;rp=rp->next)
- rg_displaygline(np, rp);
+ rg_displaygline(np, rp, longest);
}
controlreply(np, "Done.");
return CMD_OK;
}
-void rg_displaygline(nick *np, struct rg_struct *rp) { /* could be a macro? I'll assume the C compiler inlines it */
- controlreply(np, "%-25s %-20s %-15s %-8s %-4d %s", rp->mask->content, longtoduration(rp->expires - time(NULL), 0), rp->setby->content, rp->class, rp->type, rp->reason->content);
+char *displaytype(int type) {
+ char *ctype;
+ static char ctypebuf[10];
+
+ switch(type) {
+ case 1:
+ ctype = "igu";
+ break;
+ case 2:
+ ctype = "igh";
+ break;
+ case 3:
+ ctype = "ik";
+ break;
+ case 4:
+ ctype = "dgu";
+ break;
+ case 5:
+ ctype = "dgh";
+ break;
+ case 6:
+ ctype = "dk";
+ break;
+ default:
+ ctype = "??";
+ }
+
+ snprintf(ctypebuf, sizeof(ctype), "%1d:%s", type, ctype);
+ return ctypebuf;
+}
+
+char *getsep(int longest) {
+ static int lastlongest = -1;
+ static char lenbuf[1024];
+
+ longest = 125;
+/*
+ if(longest < 100)
+ longest = 100;
+
+ if(longest >= sizeof(lenbuf) - 20)
+ longest = sizeof(lenbuf) - 20;
+*/
+ longest+=4;
+ if(lastlongest == -1) {
+ int i;
+
+ for(i=0;i<sizeof(lenbuf)-1;i++)
+ lenbuf[i] = '-';
+ lenbuf[sizeof(lenbuf)-1] = '\0';
+ lastlongest = 0;
+ }
+
+ if(lastlongest != longest) {
+ lenbuf[lastlongest] = '-';
+ lenbuf[longest] = '\0';
+ lastlongest = longest;
+ }
+
+ return lenbuf;
+}
+
+void rg_displaygline(nick *np, struct rg_struct *rp, int longest) { /* could be a macro? I'll assume the C compiler inlines it */
+ char *sep = getsep(longest);
+/* 12345678 12345678901234567890 123456789012345 12345678 12345 12345678901234567890 1234567 1234567 123456
+ ID Expires Set by Class Type Last seen (ago) Hits(s) Hits Reason
+*/
+
+ char d[512];
+ time_t t = time(NULL);
+
+ if(rp->lastseen == 0) {
+ strlcpy(d, "(never)", sizeof(d));
+ } else {
+ strlcpy(d, longtoduration(t - rp->lastseen, 2), sizeof(d));
+ }
+
+ controlreply(np, "%s", rp->mask->content);
+ controlreply(np, " %08lx %-20s %-15s %-8s %-5s %-20s %-7lu %-7lu %s", rp->glineid, longtoduration(rp->expires - t, 2), rp->setby->content, rp->class, displaytype(rp->type), d, rp->hitssaved, rp->hits, rp->reason->content);
+ controlreply(np, "%s", sep);
}
int rg_spew(void *source, int cargc, char **cargv) {
for(j=0;j<NICKHASHSIZE;j++) {
for(np=nicktable[j];np;np=np->next) {
- if(IsOper(np) || IsService(np) || IsXOper(np))
+ if(ignorable_nick(np))
continue;
hostlen = RGBuildHostname(hostname, np);
for(rp=rg_list;rp;rp=rp->next) {
if(rp) {
struct rg_struct *tp, *lp;
- memset(rp, 0, sizeof(rp));
+ memset(rp, 0, sizeof(rg_struct));
rp->expires = expires;
for(lp=NULL,tp=rg_list;tp;lp=tp,tp=tp->next) {
return rp;
}
-struct rg_struct *rg_newsstruct(unsigned long id, char *mask, char *setby, char *reason, char *expires, char *type, time_t iexpires, char *class) {
+struct rg_struct *rg_newsstruct(unsigned long id, char *mask, char *setby, char *reason, char *expires, char *type, time_t iexpires, char *class, time_t lastseen, unsigned int hitssaved) {
struct rg_struct *newrow, *lp, *cp;
time_t rexpires;
char glineiddata[1024];
}
newrow->id = id;
+ newrow->hitssaved = hitssaved;
+ newrow->lastseen = lastseen;
newrow->mask = getsstring(mask, RG_REGEXGLINE_MAX);
if(!newrow->mask) {
snprintf(hostname, sizeof(hostname), "%s@%s", np->ident, IPtostr(np->p_ipaddr));
}
+ if(!strcmp(rp->class, RESERVED_NICK_CLASS))
+ irc_send("%s GL * +%s!*@* %d %jd :AUTO: %s (ID: %08lx)\r\n", mynumeric->content, np->nick, RESERVED_NICK_GLINE_DURATION, (intmax_t)time(NULL), rp->reason->content, rp->glineid);
+
validdelay = (rp->type == INSTANT_KILL) || (rp->type == DELAYED_IDENT_GLINE) || (rp->type == DELAYED_HOST_GLINE) || (rp->type == DELAYED_KILL);
if (validdelay || (usercount > rg_max_per_gline)) {
struct rg_glinenode *nn = (struct rg_glinenode *)malloc(sizeof(struct rg_glinenode));
}
if (rp->type == INSTANT_IDENT_GLINE) {
- if (IsAccount(np)) {
- controlwall(NO_OPER, NL_HITS, "%s!%s@%s/%s matched user@host gline regex %08lx (class: %s, hit %d user%s)", np->nick, np->ident, np->host->name->content, np->authname, rp->glineid, rp->class, usercount, (usercount!=1)?"s":"");
- } else {
- controlwall(NO_OPER, NL_HITS, "%s!%s@%s matched user@host gline regex %08lx (class: %s, hit %d user%s)", np->nick, np->ident, np->host->name->content, rp->glineid, rp->class, usercount, (usercount!=1)?"s":"");
- }
+ controlwall(NO_OPER, NL_HITS, "%s matched user@host gline regex %08lx (class: %s, hit %d user%s)", gvhost(np), rp->glineid, rp->class, usercount, (usercount!=1)?"s":"");
} else if(rp->type == INSTANT_HOST_GLINE) {
- if (IsAccount(np)) {
- controlwall(NO_OPER, NL_HITS, "%s!%s@%s/%s matched *@host gline regex %08lx (class: %s, hit %d user%s)", np->nick, np->ident, np->host->name->content, np->authname, rp->glineid, rp->class, usercount, (usercount!=1)?"s":"");
- } else {
- controlwall(NO_OPER, NL_HITS, "%s!%s@%s matched *@host gline regex %08lx (class: %s, hit %d user%s)", np->nick, np->ident, np->host->name->content, rp->glineid, rp->class, usercount, (usercount!=1)?"s":"");
- }
+ controlwall(NO_OPER, NL_HITS, "%s matched *@host gline regex %08lx (class: %s, hit %d user%s)", gvhost(np), rp->glineid, rp->class, usercount, (usercount!=1)?"s":"");
} else {
return 0;
}
rg_shadowserver(np, rp, rp->type);
- irc_send("%s GL * +%s %d %d :AUTO: %s (ID: %08lx)\r\n", mynumeric->content, hostname, rg_expiry_time, time(NULL), rp->reason->content, rp->glineid);
+ irc_send("%s GL * +%s %d %jd :AUTO: %s (ID: %08lx)\r\n", mynumeric->content, hostname, rg_expiry_time, (intmax_t)time(NULL), rp->reason->content, rp->glineid);
return usercount;
}
+static char *gvhost(nick *np) {
+ static char buf[NICKLEN+1+USERLEN+1+HOSTLEN+1+ACCOUNTLEN+4+REALLEN+1+10];
+
+ if(IsAccount(np)) {
+ snprintf(buf, sizeof(buf), "%s!%s@%s/%s r(%s)", np->nick, np->ident, np->host->name->content, np->authname, np->realname->name->content);
+ } else {
+ snprintf(buf, sizeof(buf), "%s!%s@%s r(%s)", np->nick, np->ident, np->host->name->content, np->realname->name->content);
+ }
+
+ return buf;
+}
+
static int floodprotection = 0;
static int lastfloodspam = 0;
int masklen;
va_list va;
-
- va_start(va, details);
- vsnprintf(buf, sizeof(buf), details, va);
- va_end(va);
-
+
+ if(details) {
+ va_start(va, details);
+ vsnprintf(buf, sizeof(buf), details, va);
+ va_end(va);
+ } else {
+ buf[0] = '\0';
+ }
+
if(np) {
if (IsAccount(np)) {
strncpy(account, np->authname, sizeof(account) - 1);
void rg_loggline(struct rg_struct *rg, nick *np) {
char eenick[RG_QUERY_BUF_SIZE], eeuser[RG_QUERY_BUF_SIZE], eehost[RG_QUERY_BUF_SIZE], eereal[RG_QUERY_BUF_SIZE];
+ rg->hits++;
+ rg->hitssaved++;
+ rg->lastseen = time(NULL);
+ rg->dirty = 1;
+
/* @paul: disabled */
return;
dbquery("INSERT INTO regexgline.glog (glineid, nickname, username, hostname, realname, ts) VALUES (%d, '%s', '%s', '%s', '%s', NOW())", rg->id, eenick, eeuser, eehost, eereal);
}
+
+static unsigned int getrgmarker(void) {
+ static unsigned int marker = 0;
+
+ marker++;
+ if(!marker) {
+ struct rg_struct *l;
+
+ /* If we wrapped to zero, zap the marker on all hosts */
+ for(l=rg_list;l;l=l->next)
+ l->marker=0;
+ marker++;
+ }
+
+ return marker;
+}
+
+void rg_flush_schedule(void *arg) {
+ struct rg_struct *l;
+
+ for(l=rg_list;l;l=l->next) {
+ if(!l->dirty)
+ continue;
+
+ dbquery("UPDATE regexgline.glines SET lastseen = %jd, hits = %lu WHERE id = %d", (intmax_t)l->lastseen, l->hitssaved, l->id);
+
+ l->dirty = 0;
+ }
+}
+