Parse monitoring port from internal configuration
authorJennifer Richards <jennifer@painless-security.com>
Fri, 13 Apr 2018 16:43:25 +0000 (12:43 -0400)
committerJennifer Richards <jennifer@painless-security.com>
Fri, 13 Apr 2018 16:43:25 +0000 (12:43 -0400)
common/tr_config_internal.c

index 85cd69c..82a57e2 100644 (file)
@@ -146,7 +146,7 @@ do {                         \
  */
 TR_CFG_RC tr_cfg_parse_internal(TR_CFG *trc, json_t *jint)
 {
-  json_t *jlog = NULL;
+  json_t *jtmp = NULL;
   const char *s = NULL;
 
   if ((!trc) || (!jint))
@@ -175,20 +175,26 @@ TR_CFG_RC tr_cfg_parse_internal(TR_CFG *trc, json_t *jint)
   NOPARSE_UNLESS(tr_cfg_parse_unsigned(jint, "tid_response_numerator",   &(trc->internal->tid_resp_numer)));
   NOPARSE_UNLESS(tr_cfg_parse_unsigned(jint, "tid_response_denominator", &(trc->internal->tid_resp_denom)));
 
-  if (NULL != (jlog = json_object_get(jint, "logging"))) {
-    NOPARSE_UNLESS(tr_cfg_parse_string(jlog, "log_threshold", &s));
+  /* Parse the logging section */
+  if (NULL != (jtmp = json_object_get(jint, "logging"))) {
+    NOPARSE_UNLESS(tr_cfg_parse_string(jtmp, "log_threshold", &s));
     if (s) {
       trc->internal->log_threshold = str2sev(s);
       talloc_free((void *) s);
     }
 
-    NOPARSE_UNLESS(tr_cfg_parse_string(jlog, "console_threshold", &s));
+    NOPARSE_UNLESS(tr_cfg_parse_string(jtmp, "console_threshold", &s));
     if (s) {
       trc->internal->console_threshold = str2sev(s);
       talloc_free((void *) s);
     }
   }
 
+  /* Parse the monitoring section */
+  if (NULL != (jtmp = json_object_get(jint, "monitoring"))) {
+    NOPARSE_UNLESS(tr_cfg_parse_unsigned(jtmp, "port", &(trc->internal->monitoring_port)));
+  }
+
   tr_debug("tr_cfg_parse_internal: Internal config parsed.");
   return TR_CFG_SUCCESS;
 }