#include <string.h>
#include <stdlib.h>
#include "../lib/strlfunc.h"
+#include "../irc/irc.h"
#include "trusts.h"
-char *trusts_cidr2str(struct irc_in_addr *ip, unsigned char bits) {
- static char buf[100];
-
- snprintf(buf, sizeof(buf), "%s/%u", IPtostr(*ip), (irc_in_addr_is_ipv4(ip))?bits-96:bits);
-
- return buf;
-}
-
char *trusts_timetostr(time_t t) {
static char buf[100];
static char buf[512];
if(oformat) {
- snprintf(buf, sizeof(buf), "#%u,%s/%u,%u,%u,%jd", th->group->id, IPtostr(th->ip), (unsigned int)th->bits, th->count, th->maxusage, (intmax_t)th->lastseen);
+ snprintf(buf, sizeof(buf), "#%u,%s,%u,%u,%jd", th->group->id, CIDRtostr(th->ip, th->bits), th->count, th->maxusage, (intmax_t)th->lastseen);
} else {
- snprintf(buf, sizeof(buf), "%u,%s/%u,%u,%u,%jd,%jd,%u,%u", th->group->id, IPtostr(th->ip), (unsigned int)th->bits, th->id, th->maxusage, (intmax_t)th->lastseen, (intmax_t)th->created, th->maxpernode, th->nodebits);
+ snprintf(buf, sizeof(buf), "%u,%s,%u,%u,%jd,%jd,%u,%u", th->group->id, CIDRtostr(th->ip, th->bits), th->id, th->maxusage, (intmax_t)th->lastseen, (intmax_t)th->created, th->maxpernode, th->nodebits);
}
return buf;
static char buf[512];
if(oformat) {
- snprintf(buf, sizeof(buf), "#%u,%s,%u,%u,%d,%u,%u,%jd,%jd,%jd,%s,%s,%s", tg->id, tg->name->content, tg->count, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, (intmax_t)tg->expires, (intmax_t)tg->lastseen, (intmax_t)tg->lastmaxusereset, tg->createdby->content, tg->contact->content, tg->comment->content);
+ snprintf(buf, sizeof(buf), "#%u,%s,%u,%u,%d,%u,%u,%jd,%jd,%jd,%s,%s,%s", tg->id, tg->name->content, tg->count, tg->trustedfor, tg->flags & TRUST_ENFORCE_IDENT, tg->maxperident, tg->maxusage, (intmax_t)tg->expires, (intmax_t)tg->lastseen, (intmax_t)tg->lastmaxusereset, tg->createdby->content, tg->contact->content, tg->comment->content);
} else {
- snprintf(buf, sizeof(buf), "%u,%s,%u,%d,%u,%u,%jd,%jd,%jd,%s,%s,%s", tg->id, tg->name->content, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, (intmax_t)tg->expires, (intmax_t)tg->lastseen, (intmax_t)tg->lastmaxusereset, tg->createdby->content, tg->contact->content, tg->comment->content);
+ snprintf(buf, sizeof(buf), "%u,%s,%u,%d,%u,%u,%jd,%jd,%jd,%s,%s,%s", tg->id, tg->name->content, tg->trustedfor, tg->flags, tg->maxperident, tg->maxusage, (intmax_t)tg->expires, (intmax_t)tg->lastseen, (intmax_t)tg->lastmaxusereset, tg->createdby->content, tg->contact->content, tg->comment->content);
}
return buf;
/* #id,ticket35153,14,20,1,1,17,1879854575,1222639249,0,nterfacer,Qwhois&2120764,Non-Commercial Bouncer (Created by: doomie)
,name ,current
,trustedfor
- ,mode
+ ,flags
,maxperident
,maxusage
,expires ,lastseen ,lastmaxusereset
if(oformat) {
r = sscanf(line, "%*u,%u,%u,%u,%u,%lu,%lu,%lu,%n",
- /*current, */ &tg->trustedfor, &tg->mode, &tg->maxperident,
+ /*current, */ &tg->trustedfor, &tg->flags, &tg->maxperident,
&tg->maxusage, &expires, &lastseen, &lastmaxusereset, &pos);
+
+ if(tg->maxperident > 0)
+ tg->flags |= TRUST_RELIABLE_USERNAME;
} else {
r = sscanf(line, "%u,%u,%u,%u,%lu,%lu,%lu,%n",
- &tg->trustedfor, &tg->mode, &tg->maxperident,
+ &tg->trustedfor, &tg->flags, &tg->maxperident,
&tg->maxusage, &expires, &lastseen, &lastmaxusereset, &pos);
}
if(r != 7)
if(oformat) {
if(sscanf(line, "%*u,%u,%lu", /*current, */&th->maxusage, &lastseen) != 2)
return 0;
- created = time(NULL);
+ created = getnettime();
+ maxpernode = 0;
+ nodebits = 128;
} else {
if(sscanf(line, "%u,%u,%lu,%lu,%d,%d", &th->id, &th->maxusage, &lastseen, &created, &maxpernode, &nodebits) != 6)
return 0;