]> jfr.im git - irc/quakenet/newserv.git/blobdiff - trusts/formats.c
CHANSERV: better batcher error handling for expired accounts/accounts with no email.
[irc/quakenet/newserv.git] / trusts / formats.c
index b723c4aaf363faf89a91557cb789f60cf480cfd1..35bee39d80179f44f5e12452dc0bb813d8fb44e3 100644 (file)
@@ -7,28 +7,6 @@
 #include "../irc/irc.h"
 #include "trusts.h"
 
-char *trusts_cidr2str(struct irc_in_addr *ip, unsigned char bits) {
-  static char buf[100];
-  struct irc_in_addr iptemp;
-  int i;
-
-  for(i=0;i<8;i++) {
-    int curbits = bits - i * 16;
-
-    if (curbits<0)
-      curbits = 0;
-    else if (curbits>16)
-      curbits = 16;
-
-    uint16_t mask = 0xffff & ~((1 << (16 - curbits)) - 1);
-    iptemp.in6_16[i] = htons(ntohs(ip->in6_16[i]) & mask);
-  }
-
-  snprintf(buf, sizeof(buf), "%s/%u", IPtostr(iptemp), (irc_in_addr_is_ipv4(&iptemp))?bits-96:bits);
-
-  return buf;
-}
-
 char *trusts_timetostr(time_t t) {
   static char buf[100];
 
@@ -41,9 +19,9 @@ char *dumpth(trusthost *th, int oformat) {
   static char buf[512];
 
   if(oformat) {
-    snprintf(buf, sizeof(buf), "#%u,%s,%u,%u,%jd", th->group->id, trusts_cidr2str(&th->ip, 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,%jd,%jd,%u,%u", th->group->id, trusts_cidr2str(&th->ip, 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;
@@ -113,6 +91,9 @@ int parsetg(char *buf, trustgroup *tg, int oformat) {
     r = sscanf(line, "%*u,%u,%u,%u,%u,%lu,%lu,%lu,%n",
                /*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->flags, &tg->maxperident,
@@ -156,7 +137,7 @@ int parseth(char *line, trusthost *th, unsigned int *tgid, int oformat) {
   int maxpernode, nodebits;
   char *ip, xbuf[1024], *id;
 
-/* #id,213.230.192.128/26,20,23,1222732944
+/* #id,192.168.2.128/26,20,23,1222732944
        ip                ,cur,max,lastseen */
 
   strlcpy(xbuf, line, sizeof(xbuf));
@@ -187,6 +168,8 @@ int parseth(char *line, trusthost *th, unsigned int *tgid, int oformat) {
     if(sscanf(line, "%*u,%u,%lu", /*current, */&th->maxusage, &lastseen) != 2)
       return 0;
     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;