]> jfr.im git - irc/quakenet/newserv.git/blobdiff - trusts/db.c
fix indentation
[irc/quakenet/newserv.git] / trusts / db.c
index 69d71697e3eb4ead25663b1fff0a80f76bd2549a..ae4af07eb79727538b07d2c9d097985a0e2bc52e 100644 (file)
@@ -48,6 +48,7 @@ static void loadcomplete(void) {
   if(loaderror)
     return;
 
+  th_linktree();
   trustsdbloaded = 1;
   flushschedule = schedulerecurring(time(NULL) + 300, 0, 300, flushdatabase, NULL);
 
@@ -228,7 +229,16 @@ void tg_dbupdatecounts(trustgroup *tg) {
 }
 
 trusthost *th_new(trustgroup *tg, char *host) {
-  trusthost *th = th_add(tg, thmaxid + 1, host, 0, 0);
+  trusthost *th, *superset, *subset;
+  u_int32_t ip, mask;
+
+  /* ugh */
+  if(!trusts_str2cidr(host, &ip, &mask))
+    return NULL;
+
+  th_getsuperandsubsets(ip, mask, &superset, &subset);
+
+  th = th_add(tg, thmaxid + 1, host, 0, 0);
   if(!th)
     return NULL;
 
@@ -239,8 +249,9 @@ trusthost *th_new(trustgroup *tg, char *host) {
     "Tuusut", "hosts", th->id, tg->id, trusts_cidr2str(th->ip, th->mask), th->maxusage, th->lastseen
   );
 
-  /* fix up stuff in memory */
+  th_adjusthosts(th, subset, superset);
 
+  th_linktree();
   return th;
 }