Turned enforcement on by default at startup. Added a ulogd.conf config option to...
[distributedratelimiting.git] / drl / ulogd_DRL.c
index 83e5f13..f9d6d56 100644 (file)
  * Add the config options for DRL. 
  */
 
  * Add the config options for DRL. 
  */
 
-static config_entry_t partition = {
+static config_entry_t enforce_on = {
     .next = NULL,
     .next = NULL,
+    .key = "enforce_on",
+    .type = CONFIG_TYPE_INT,
+    .options = CONFIG_OPT_NONE,
+    .u = { .value = 1 },
+};
+
+static config_entry_t partition = {
+    .next = &enforce_on,
     .key = "partition_set",
     .type = CONFIG_TYPE_INT,
     .options = CONFIG_OPT_NONE,
     .key = "partition_set",
     .type = CONFIG_TYPE_INT,
     .options = CONFIG_OPT_NONE,
@@ -1782,6 +1790,13 @@ static void _drl_reg_op(void)
         fprintf(stderr, "An error has occured starting ulogd_DRL.  Refer to your logfile (%s) for additional information.\n", drl_logfile.u.string);
         exit(EXIT_FAILURE);
     }
         fprintf(stderr, "An error has occured starting ulogd_DRL.  Refer to your logfile (%s) for additional information.\n", drl_logfile.u.string);
         exit(EXIT_FAILURE);
     }
+
+    if (enforce_on.u.value) {
+        pthread_rwlock_wrlock(&limiter.limiter_lock);
+        do_enforcement = 1;
+        printlog(LOG_CRITICAL, "--Switching enforcement on.--\n");
+        pthread_rwlock_unlock(&limiter.limiter_lock);
+    }
 }
 
 void _init(void)
 }
 
 void _init(void)