]> jfr.im git - irc/quakenet/newserv.git/blobdiff - trusts/db.c
Add subset/set checking into trustadd, now handles moving of users between trusts...
[irc/quakenet/newserv.git] / trusts / db.c
index 69d71697e3eb4ead25663b1fff0a80f76bd2549a..a740a616e4d2f8528f1d288a44a813575bc447e3 100644 (file)
@@ -228,7 +228,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,7 +248,7 @@ 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);
 
   return th;
 }