]> jfr.im git - irc/quakenet/newserv.git/blobdiff - trusts/trusts_management.c
TRUSTS: require sqlite
[irc/quakenet/newserv.git] / trusts / trusts_management.c
index 1e0f4b9fe4777880098ed6de1a3d5792901afe5b..8f72f4d6d501e339cc1e083b33e3af31fc1641fc 100644 (file)
@@ -8,8 +8,8 @@
 #include "../core/schedule.h"
 #include "../irc/irc.h"
 #include "../lib/stringbuf.h"
-#include "../noperserv/noperserv.h"
-#include "../noperserv/noperserv_policy.h"
+#include "../control/control.h"
+#include "../control/control_policy.h"
 #include "trusts.h"
 
 MODULE_VERSION("");
@@ -69,14 +69,14 @@ static int trusts_cmdtrustadd(void *source, int cargc, char **cargv) {
   /* OKAY! Lots of checking here!
    *
    * Need to check:
-   *   - host isn't already covered by given group (reject if it is)
+   *   - exact same host isn't already covered by given group (reject if it is)
    *   - host doesn't already exist exactly already (reject if it does)
    *   - host is more specific than an existing one (warn if it is, fix up later)
    *   - host is less specific than an existing one (warn if it is, don't need to do anything special)
    */
 
   for(th=tg->hosts;th;th=th->next) {
-    if(ipmask_check(&ip, &th->ip, th->bits)) {
+    if(ipmask_check(&ip, &th->ip, th->bits) && th->bits == bits) {
       controlreply(sender, "This host (or part of it) is already covered in the given group.");
       return CMD_ERROR;
     }
@@ -401,6 +401,20 @@ static int modifyreliableusername(void *arg, char *num, nick *source, int overri
   return 1;
 }
 
+static int modifyunthrottle(void *arg, char *num, nick *source, int override) {
+  trustgroup *tg = arg;
+
+  if(num[0] == '1') {
+    tg->flags |= TRUST_UNTHROTTLE;
+  } else if(num[0] == '0') {
+    tg->flags &= ~TRUST_UNTHROTTLE;
+  } else {
+    return 0;
+  }
+
+  return 1;
+}
+
 static int modifyexpires(void *arg, char *expires, nick *source, int override) {
   trustgroup *tg = arg;
   int howlong = durationtolong(expires);
@@ -487,6 +501,11 @@ static int modifynodebits(void *arg, char *num, nick *source, int override) {
   if(irc_in_addr_is_ipv4(&th->ip))
     nodebits += 96;
 
+  if(nodebits > 128) {
+    controlreply(source, "Node bits is invalid.");
+    return 0;
+  }
+
   if(!override) {
     int minbits = irc_in_addr_is_ipv4(&th->ip)?TRUST_MIN_UNPRIVILEGED_NODEBITS_IPV4:TRUST_MIN_UNPRIVILEGED_NODEBITS_IPV6;
 
@@ -798,6 +817,7 @@ static void setupmods(void) {
   MSGROUP(trustedfor);
   MSGROUP(cleanup);
   MSGROUP(protected);
+  MSGROUP(unthrottle);
 
   MSHOST(maxpernode);
   MSHOST(nodebits);
@@ -812,15 +832,18 @@ static void cleanuptrusts(void *arg) {
   trusthost *th;
   int thcount = 0, tgcount = 0;
   int i;
+  flag_t noticelevel;
   array expiredths, expiredtgs;
 
   now = getnettime();
   to_age = now - (CLEANUP_TH_INACTIVE * 3600 * 24);
 
   if(np) {
-    controlwall(NO_OPER, NL_TRUSTS, "CLEANUPTRUSTS: Manually started by %s.", np->nick);
+    noticelevel = NL_TRUSTS;
+    controlwall(NO_OPER, noticelevel, "CLEANUPTRUSTS: Manually started by %s.", np->nick);
   } else {
-    controlwall(NO_OPER, NL_TRUSTS, "CLEANUPTRUSTS: Automatically started.");
+    noticelevel = NL_CLEANUP;
+    controlwall(NO_OPER, noticelevel, "CLEANUPTRUSTS: Automatically started.");
   }
 
   if (cleanuptrusts_active) {
@@ -873,7 +896,7 @@ static void cleanuptrusts(void *arg) {
     tgcount++;
   }
 
-  controlwall(NO_OPER, NL_TRUSTS, "CLEANUPTRUSTS: Removed %d trust hosts (inactive for %d days) and %d empty trust groups.", thcount, CLEANUP_TH_INACTIVE, tgcount);
+  controlwall(NO_OPER, noticelevel, "CLEANUPTRUSTS: Removed %d trust hosts (inactive for %d days) and %d empty trust groups.", thcount, CLEANUP_TH_INACTIVE, tgcount);
 
   cleanuptrusts_active=0;
 }