]> jfr.im git - irc/quakenet/newserv.git/blobdiff - trusts/trusts_policy.c
rework build system, part 1:
[irc/quakenet/newserv.git] / trusts / trusts_policy.c
index 607fa97fd3bb46c93cb664da8bb0a8e53033e146..32a8ca515ceda2aa37420a571d7c6c84de87eb25 100644 (file)
@@ -1,14 +1,27 @@
 #include "../core/hooks.h"
 #include "../control/control.h"
+#include "../lib/irc_string.h"
 #include "trusts.h"
 
 static int countext;
 
 static void policycheck(int hooknum, void *arg) {
-  nick *np = arg;
+  void **args = arg;
+  nick *np = args[0];
+  long moving = (long)args[1];
   trusthost *th = gettrusthost(np);
-  trustgroup *tg = th->group;
+  trustgroup *tg;
 
+  if(moving)
+    return;
+
+  if(!th) {
+    if(np->ipnode->usercount > 5)
+      controlwall(NO_OPER, NL_TRUSTS, "Hard connection limit exceeded on IP: %s (untrusted) %d connected, 5 max.", IPtostr(np->p_ipaddr), np->ipnode->usercount);
+    return;
+  }
+
+  tg = th->group;
   /*
    * the purpose of this logic is to avoid spam like this:
    * WARNING: tgX exceeded limit: 11 connected vs 10 max
@@ -17,12 +30,34 @@ static void policycheck(int hooknum, void *arg) {
    */
 
   if(hooknum == HOOK_TRUSTS_NEWNICK) {
-    if(tg->count > tg->maxusage) {
+    if(tg->count > tg->trustedfor) {
+/*
       if(tg->count > (long)tg->exts[countext]) {
+
         tg->exts[countext] = (void *)(long)tg->count;
+*/
+        controlwall(NO_OPER, NL_TRUSTS, "Hard connection limit exceeded: '%s', %d connected, %d max.", tg->name->content, tg->count, tg->trustedfor);
+      }
+/*
+    }
+*/
+    if((tg->mode == 1) && (np->ident[0] == '~'))
+      controlwall(NO_OPER, NL_TRUSTS, "Ident required: '%s' %s!%s@%s.", tg->name->content, np->nick, np->ident, np->host->name->content);
 
-        controlwall(NO_OPER, NL_TRUSTS, "Hard limit exceeded: '%s', %d connected, %d max.", tg->name->content, tg->count, tg->maxusage);
+    if(tg->maxperident > 0) {
+      int identcount = 0;
+      trusthost *th2;
+      nick *tnp;
+
+      for(th2=tg->hosts;th2;th2=th2->next) {
+        for(tnp=th2->users;tnp;tnp=nextbytrust(tnp)) {
+          if(!ircd_strcmp(tnp->ident, np->ident))
+            identcount++;
+        }
       }
+
+      if(identcount > tg->maxperident)
+        controlwall(NO_OPER, NL_TRUSTS, "Hard ident limit exceeded: '%s' %s!%s@%s, %d connected, %d max.", tg->name->content, np->nick, np->ident, np->host->name->content, identcount, tg->maxperident);
     }
   } else {
     if(tg->count < tg->maxusage)