aboutsummaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorarf20 <aruizfernandez05@gmail.com>2025-11-10 18:12:50 +0100
committerarf20 <aruizfernandez05@gmail.com>2025-11-10 18:12:50 +0100
commit36b52bd0f856f1b6cfcf8ac1a7459f06939dfafa (patch)
tree30c0a260f8eb6e6b6084114c9b78398cf9b601c8 /config.c
parent47992fa660c9c82858120c4d16fba0501903ceb9 (diff)
downloadarfnet2-status-36b52bd0f856f1b6cfcf8ac1a7459f06939dfafa.tar.gz
arfnet2-status-36b52bd0f856f1b6cfcf8ac1a7459f06939dfafa.zip
email alerts working
Diffstat (limited to 'config.c')
-rw-r--r--config.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/config.c b/config.c
index 39dc1b9..1d485d7 100644
--- a/config.c
+++ b/config.c
@@ -8,7 +8,7 @@
unsigned short port = DEFAULT_PORT;
char *log_path = DEFAULT_LOG_PATH;
monitor_config_t monitor_config = { .interval = DEFAULT_INTERVAL };
-alert_config_t alert_config;
+alert_config_t alert_config = { 0 };
int
config_load(const char *conf_path)
@@ -64,11 +64,23 @@ config_load(const char *conf_path)
value[strlen(value) - 1] = '\0';
log_path = strdup(value);
printf("\tlog path: %s\n", log_path);
- } else if (strcmp(line, "from") == 0) {
+ } else if (strcmp(line, "mailserver") == 0) {
+ value[strlen(value) - 1] = '\0';
+ alert_config.mail_server = strdup(value);
+ printf("\tmailserver: %s\n", alert_config.mail_server);
+ } else if (strcmp(line, "mailfrom") == 0) {
value[strlen(value) - 1] = '\0';
alert_config.from = strdup(value);
printf("\tfrom: %s\n", log_path);
- } else if (strcmp(line, "target") == 0) {
+ } else if (strcmp(line, "mailuser") == 0) {
+ value[strlen(value) - 1] = '\0';
+ alert_config.user = strdup(value);
+ } else if (strcmp(line, "mailpassword") == 0) {
+ value[strlen(value) - 1] = '\0';
+ alert_config.password = strdup(value);
+ }
+
+ else if (strcmp(line, "target") == 0) {
target_pos += snprintf(target_pos,
cfgsize - (target_pos - monitor_config.target_config),
"%s", value);
@@ -85,6 +97,9 @@ config_load(const char *conf_path)
fclose(cfgf);
+ if (!alert_config.from || !alert_config.mail_server)
+ fprintf(stderr, "[config] W: no mail\n");
+
return 0;
}