long creatornum;
gline *agline;
nick *np;
+ glinebuf gbuf;
/**
* Valid GL tokens have X params:
/* 2nd param is mask */
mask = cargv[1];
+ /* snircd 1.3.5 can destroy glines, no #if here */
+ if (*mask == '%') {
+ flags |= GLINE_DESTROY;
+ mask++;
+ }
+
switch (*mask) {
case '+':
flags |= GLINE_ACTIVATE;
agline = findgline(mask);
if (agline) {
- if (agline->flags & GLINE_ACTIVE) {
- Error("debuggline", ERR_WARNING, "Duplicate Gline recieved for %s - old lastmod %lu, expire %lu, lifetime %lu, reason %s, creator %s", mask, agline->lastmod, agline->expire, agline->lifetime, agline->reason->content, agline->creator->content);
+ Error("debuggline", ERR_WARNING, "Update for existing gline received for %s - old lastmod %lu, expire %lu, lifetime %lu, reason %s, creator %s", mask, agline->lastmod, agline->expire, agline->lifetime, agline->reason->content, agline->creator->content);
+
+ agline->flags |= GLINE_ACTIVE;
+
+ /* check lastmod then assume the new gline is authoritive */
+ if (lastmod > agline->lastmod) {
+ agline->lastmod = lastmod;
+ agline->expire = expire;
+ agline->lifetime = lifetime;
+ freesstring(agline->creator);
+ agline->creator = getsstring(creator, 255);
+ freesstring(agline->reason);
+ agline->reason = getsstring(reason, 255);
} else {
- /* we're reactivating a gline - check lastmod then assume the new gline is authoritive */
- if (lastmod > agline->lastmod) {
- agline->lastmod = lastmod;
- agline->expire = expire;
- agline->lifetime = lifetime;
- agline->creator = getsstring(creator, 255);
- freesstring(agline->reason);
- agline->reason = getsstring(reason, 255);
- agline->flags |= GLINE_ACTIVE;
- } else {
- Error("debuggline", ERR_WARNING, "received a gline with a lower lastmod");
- /* @@@TODO resend our gline ? */
- }
- }
- /* TODO */
- return CMD_ERROR;
+ Error("debuggline", ERR_WARNING, "received a gline with a lower lastmod");
+ /* Don't send our gline as that might cause loops in case we don't understand the gline properly. */
+ }
+
+ return CMD_OK;
} else {
- gline_add(creator, mask, reason, expire, lastmod, lifetime);
+ glinebufinit(&gbuf, 0);
+ glinebufadd(&gbuf, mask, creator, reason, expire, lastmod, lifetime);
+ glinebufflush(&gbuf, 0);
}
} else if (flags & GLINE_DEACTIVATE) {
/* deactivate gline */
case 5:
/* asuka last mod */
lastmod = atoi(cargv[3]);
- gline_deactivate(agline, lastmod, 0);
+
+ if (flags & GLINE_DESTROY)
+ gline_destroy(agline, lastmod, 0);
+ else
+ gline_deactivate(agline, lastmod, 0);
+
break;
case 6:
/* snircd */
lastmod = atoi(cargv[3]);
- gline_deactivate(agline, lastmod, 0);
+
+ if (flags & GLINE_DESTROY)
+ gline_destroy(agline, lastmod, 0);
+ else
+ gline_deactivate(agline, lastmod, 0);
+
break;
default:
Error("gline", ERR_WARNING, "Gline Deactivate with invalid number (%d) of arguments", cargc);
return CMD_ERROR;
}
- agline = gline_add(creator, mask, reason, expire, lastmod, lifetime);
+ glinebufinit(&gbuf, 0);
+ agline = glinebufadd(&gbuf, mask, creator, reason, expire, lastmod, lifetime);
if (!agline) {
+ glinebufabandon(&gbuf);
Error("gline", ERR_WARNING, "gline_add failed");
return CMD_ERROR;
}
gline_deactivate(agline, lastmod, 0);
+ glinebufflush(&gbuf, 0);
return CMD_OK;
}
agline->reason = getsstring(reason, 255);
} else {
Error("debuggline", ERR_WARNING, "received a gline modification with a lower lastmod");
- /* @@@TODO resend our gline ? */
}
return CMD_OK;