diff --git a/src/api/docs/content/specs/config.yaml b/src/api/docs/content/specs/config.yaml index 1f04e230..9e4c9be9 100644 --- a/src/api/docs/content/specs/config.yaml +++ b/src/api/docs/content/specs/config.yaml @@ -553,6 +553,8 @@ components: type: boolean normalizeCPU: type: boolean + hide_dnsmasq_warn: + type: boolean check: type: object properties: @@ -837,6 +839,7 @@ components: extraLogging: false readOnly: false normalizeCPU: false + hide_dnsmasq_warn: false check: load: true shmem: 90 diff --git a/src/api/info.c b/src/api/info.c index 5ae1f745..0a94f1ac 100644 --- a/src/api/info.c +++ b/src/api/info.c @@ -907,29 +907,15 @@ int api_info_version(struct ftl_conn *api) int api_info_messages_count(struct ftl_conn *api) { - // Filtering based on GET parameters? - bool filter_dnsmasq_warnings = false; - if(api->request->query_string != NULL) - { - get_bool_var(api->request->query_string, "filter_dnsmasq_warnings", &filter_dnsmasq_warnings); - } - // Send reply cJSON *json = JSON_NEW_OBJECT(); - cJSON_AddNumberToObject(json, "count", count_messages(filter_dnsmasq_warnings)); + cJSON_AddNumberToObject(json, "count", count_messages()); JSON_SEND_OBJECT(json); return 0; } static int api_info_messages_GET(struct ftl_conn *api) { - // Filtering based on GET parameters? - bool filter_dnsmasq_warnings = false; - if(api->request->query_string != NULL) - { - get_bool_var(api->request->query_string, "filter_dnsmasq_warnings", &filter_dnsmasq_warnings); - } - // Create messages array cJSON *messages = cJSON_CreateArray(); if(!format_messages(messages)) @@ -943,7 +929,7 @@ static int api_info_messages_GET(struct ftl_conn *api) } // Filter messages if requested - if(filter_dnsmasq_warnings) + if(config.misc.hide_dnsmasq_warn.v.b) { // Create new array cJSON *filtered = cJSON_CreateArray(); diff --git a/src/config/config.c b/src/config/config.c index 8975465e..4e366995 100644 --- a/src/config/config.c +++ b/src/config/config.c @@ -1422,6 +1422,12 @@ void initConfig(struct config *conf) conf->misc.normalizeCPU.d.b = true; conf->misc.normalizeCPU.c = validate_stub; // Only type-based checking + conf->misc.hide_dnsmasq_warn.k = "misc.hide_dnsmasq_warn"; + conf->misc.hide_dnsmasq_warn.h = "Should FTL hide warnings coming from dnsmasq?\n\n By default, FTL reports warnings coming from the embedded dnsmasq DNS server to the FTL log file. These warnings can be useful to identify misconfigurations or problems with the DNS server. However, some warnings may be harmless and can be ignored in certain setups. Enabling this setting will hide dnsmasq warnings."; + conf->misc.hide_dnsmasq_warn.t = CONF_BOOL; + conf->misc.hide_dnsmasq_warn.d.b = false; + conf->misc.hide_dnsmasq_warn.c = validate_stub; // Only type-based checking + // sub-struct misc.check conf->misc.check.load.k = "misc.check.load"; conf->misc.check.load.h = "Pi-hole is very lightweight on resources. Nevertheless, this does not mean that you should run Pi-hole on a server that is otherwise extremely busy as queuing on the system can lead to unnecessary delays in DNS operation as the system becomes less and less usable as the system load increases because all resources are permanently in use. To account for this, FTL regularly checks the system load. To bring this to your attention, FTL warns about excessive load when the 15 minute system load average exceeds the number of cores.\n\n This check can be disabled with this setting."; diff --git a/src/config/config.h b/src/config/config.h index e4cc11c4..0ad68605 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -317,6 +317,7 @@ struct config { struct conf_item extraLogging; struct conf_item readOnly; struct conf_item normalizeCPU; + struct conf_item hide_dnsmasq_warn; struct { struct conf_item load; struct conf_item shmem; diff --git a/src/database/message-table.c b/src/database/message-table.c index 76278d2f..2a88eb23 100644 --- a/src/database/message-table.c +++ b/src/database/message-table.c @@ -1013,7 +1013,7 @@ static void format_gravity_restored_message(char *plain, const int sizeof_plain, } } -int count_messages(const bool filter_dnsmasq_warnings) +int count_messages(void) { int count = 0; @@ -1030,7 +1030,9 @@ int count_messages(const bool filter_dnsmasq_warnings) // Get message sqlite3_stmt* stmt = NULL; - const char *querystr = filter_dnsmasq_warnings ? "SELECT COUNT(*) FROM message WHERE type != 'DNSMASQ_WARN'" : "SELECT COUNT(*) FROM message"; + const char *querystr = config.misc.hide_dnsmasq_warn.v.b ? + "SELECT COUNT(*) FROM message WHERE type != 'DNSMASQ_WARN'" : + "SELECT COUNT(*) FROM message"; int rc = sqlite3_prepare_v2(db, querystr, -1, &stmt, NULL); if( rc != SQLITE_OK ){ log_err("count_messages() - SQL error prepare SELECT: %s", diff --git a/src/database/message-table.h b/src/database/message-table.h index 6c3afceb..bb7b7f9c 100644 --- a/src/database/message-table.h +++ b/src/database/message-table.h @@ -13,7 +13,7 @@ #include "sqlite3.h" #include "webserver/cJSON/cJSON.h" -int count_messages(const bool filter_dnsmasq_warnings); +int count_messages(void); bool format_messages(cJSON *array); bool create_message_table(sqlite3 *db); bool delete_message(cJSON *ids, int *deleted); diff --git a/test/pihole.toml b/test/pihole.toml index e7985fe4..23dfa7e5 100644 --- a/test/pihole.toml +++ b/test/pihole.toml @@ -1,7 +1,7 @@ -# Pi-hole configuration file (v6.2.3-301-gfcee3894-dirty) on branch tweak/api_info_system_ftl +# Pi-hole configuration file (v6.2.3-312-g9f1eb768-dirty) on branch (no branch, rebasing misc_dnsmasq_warn) # Encoding: UTF-8 # This file is managed by pihole-FTL -# Last updated on 2025-10-06 08:00:17 UTC +# Last updated on 2025-10-23 17:03:51 UTC [dns] # Upstream DNS Servers to be used by Pi-hole. If this is not set, Pi-hole will not @@ -1413,6 +1413,17 @@ # true or false normalizeCPU = true + # Should FTL hide warnings coming from dnsmasq? + # + # By default, FTL reports warnings coming from the embedded dnsmasq DNS server to the + # FTL log file. These warnings can be useful to identify misconfigurations or problems + # with the DNS server. However, some warnings may be harmless and can be ignored in + # certain setups. Enabling this setting will hide dnsmasq warnings. + # + # Allowed values are: + # true or false + hide_dnsmasq_warn = false + [misc.check] # Pi-hole is very lightweight on resources. Nevertheless, this does not mean that you # should run Pi-hole on a server that is otherwise extremely busy as queuing on the @@ -1662,7 +1673,7 @@ all = true ### CHANGED, default = false # Configuration statistics: -# 160 total entries out of which 107 entries are default +# 161 total entries out of which 108 entries are default # --> 53 entries are modified # 3 entries are forced through environment: # - misc.nice