#include "../lib/base64.h"
#include "../lib/irc_string.h"
#include "../lib/splitline.h"
+#include "../core/nsmalloc.h"
#include "gline.h"
int glinecount = 0;
int badchancount = 0;
int rnglinecount = 0;
-int gl_nodeext = 0;
+int gl_nodeext = -1;
/*
<prefix> GL <target> [!][+|-|>|<]<mask> [<expiration>] [<lastmod>]
void _init() {
gl_nodeext = registernodeext("gline");
- if ( !gl_nodeext ) {
+ if ( gl_nodeext == -1 ) {
Error("gline", ERR_FATAL, "Could not register a required node extension (gline)");
return;
}
}
glinelist = NULL;
- if (gl_nodeext)
+ if (gl_nodeext != -1)
releasenodeext(gl_nodeext);
+
+ nsfreeall(POOL_GLINE);
}
int gline_setnick(nick *np, int duration, char *reason ) {
/* valid GL tokens have X params */
switch ( cargc ) {
+ case 2:
+ /* local modification which we reject later */
+ break;
case 5:
/* 1.3.x GL Token */
break;
break;
case '>':
case '<':
- Error("gline", ERR_WARNING, "Received local modification from %s.", sender);
+ Error("gline", ERR_WARNING, "Received local modification from %s - do they realise we're a service?", sender);
return CMD_ERROR;
}
}
} else {
/* modification - only snircd 1.4.x */
- Error("gline", ERR_WARNING, "Not Implemented");
+ if ((agline = gline_find(mask))) {
+ expires = abs_expire(atoi(cargv[2]));
+ lastmod = atoi(cargv[3]);
+ lifetime = atoi(cargv[4]);
+ reason = cargv[5];
+
+ if ( lastmod > agline->lastmod ) {
+ agline->lastmod = lastmod;
+ agline->expires = expires;
+ agline->lifetime = lifetime;
+ agline->creator = creator;
+ freesstring(agline->reason);
+ 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;
+ } else {
+ Error("gline", ERR_WARNING, "Received modification for gline that does not exist for mask %s", mask);
+ return CMD_ERROR;
+ }
}
Error("debuggline", ERR_WARNING, "Creator %s", creator->content);
#include <stdarg.h>
#include "../core/nsmalloc.h"
-int tgh_ext;
-int tgb_ext;
-int tgn_ext;
+int tgh_ext = -1;
+int tgb_ext = -1;
+int tgn_ext = -1;
unsigned long trusts_lasttrustgroupid;
unsigned long trusts_lasttrusthostid;
trusts_hash_init();
tgh_ext = registernodeext("trusthost");
- if ( !tgh_ext ) {
+ if ( tgh_ext == -1 ) {
Error("trusts", ERR_FATAL, "Could not register a required node extension (trusthost)");
return;
}
tgb_ext = registernodeext("trustblock");
- if ( !tgb_ext ) {
+ if ( tgb_ext == -1 ) {
Error("trusts", ERR_FATAL, "Could not register a required node extension (trustblock)");
return;
}
tgn_ext = registernickext("trustnick");
- if ( !tgn_ext ) {
+ if ( tgn_ext == -1 ) {
Error("trusts", ERR_FATAL, "Could not register a required nick extension (trustnick)");
return;
}
}
} PATRICIA_WALK_CLEAR_END;
- if (tgh_ext)
+ if (tgh_ext != -1)
releasenodeext(tgh_ext);
- if (tgb_ext)
+ if (tgb_ext != -1)
releasenodeext(tgb_ext);
- if (tgn_ext)
+ if (tgn_ext != -1)
releasenodeext(tgn_ext);
/* @@@ CLOSE DB */