From 35a9b743abd0f047871396de1603a648bd32ad87 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Tue, 1 Mar 2022 12:46:19 +0000 Subject: [PATCH] Feature: Check if client_limit is reasonable bigger than source_limit --- src/admin.c | 2 ++ src/cfgfile.c | 6 ++++++ src/cfgfile.h | 1 + 3 files changed, 9 insertions(+) diff --git a/src/admin.c b/src/admin.c index 05de4e0e..f866c1f8 100644 --- a/src/admin.c +++ b/src/admin.c @@ -1549,6 +1549,8 @@ static void command_dashboard (client_t *client, source_t *source, adm __reportxml_add_maintenance(reportnode, config->reportxml_db, "b6224fc4-53a1-433f-a6cd-d5b85c60f1c9", "error", "Obsolete tags are used in the config file. See the error.log for details and update your configuration accordingly.", NULL); if (config->config_problems & CONFIG_PROBLEM_INVALID_NODE) __reportxml_add_maintenance(reportnode, config->reportxml_db, "0f6f757d-52d8-4b9a-8e57-9bcd528fffba", "error", "Invalid tags are used in the config file. See the error.log for details and update your configuration accordingly.", NULL); + if (config->config_problems & CONFIG_PROBLEM_VALIDATION) + __reportxml_add_maintenance(reportnode, config->reportxml_db, "8fc33086-274d-4ccb-b32f-599b3fa0f41a", "error", "The configuration did not validate. See the error.log for details and update your configuration accordingly.", NULL); if (!has_sources) __reportxml_add_maintenance(reportnode, config->reportxml_db, "f68dd8a3-22b1-4118-aba6-b039f2c5b51e", "info", "Currently no sources are connected to this server.", NULL); diff --git a/src/cfgfile.c b/src/cfgfile.c index 35d9f5c6..a462581c 100644 --- a/src/cfgfile.c +++ b/src/cfgfile.c @@ -1040,6 +1040,12 @@ int config_parse_file(const char *filename, ice_config_t *configuration) _parse_root(doc, node->xmlChildrenNode, configuration); xmlFreeDoc(doc); _merge_mounts_all(configuration); + + if (configuration->client_limit <= (configuration->source_limit*2)) { + configuration->config_problems |= CONFIG_PROBLEM_VALIDATION; + ICECAST_LOG_ERROR("Client limit (%i) is too small for given source limit (%i)", configuration->client_limit, configuration->source_limit); + } + return 0; } diff --git a/src/cfgfile.h b/src/cfgfile.h index bfd0113f..988d5a41 100644 --- a/src/cfgfile.h +++ b/src/cfgfile.h @@ -37,6 +37,7 @@ #define CONFIG_PROBLEM_UNKNOWN_NODE 0x0010U #define CONFIG_PROBLEM_OBSOLETE_NODE 0x0020U #define CONFIG_PROBLEM_INVALID_NODE 0x0040U +#define CONFIG_PROBLEM_VALIDATION 0x0080U typedef enum _http_header_type { /* static: headers are passed as is to the client. */