From 054fbee67a6e7bc7d396027ecc901f88255302cf Mon Sep 17 00:00:00 2001 From: Ben Draut Date: Fri, 13 Apr 2018 15:43:04 -0600 Subject: [PATCH] MINOR: config: Warn if resolvers has no nameservers Today, a `resolvers` section may be configured without any `nameserver` directives, which is useless. This implements a warning when such sections are detected. [List thread][1]. [1]: https://www.mail-archive.com/haproxy@formilux.org/msg29600.html --- src/cfgparse.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cfgparse.c b/src/cfgparse.c index 37bbf45..621af6c 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -7336,6 +7336,7 @@ int check_config_validity() struct bind_conf *bind_conf; char *err; struct cfg_postparser *postparser; + struct dns_resolvers *curr_resolvers = NULL; bind_conf = NULL; /* @@ -8976,6 +8977,15 @@ out_uri_auth_compat: global.tune.max_http_hdr * sizeof(struct hdr_idx_elem), MEM_F_SHARED); + list_for_each_entry(curr_resolvers, &dns_resolvers, list) { + if (LIST_ISEMPTY(&curr_resolvers->nameservers)) { + ha_warning("config : resolvers '%s' [%s:%d] has no nameservers configured!\n", + curr_resolvers->id, curr_resolvers->conf.file, + curr_resolvers->conf.line); + err_code |= ERR_WARN; + } + } + list_for_each_entry(postparser, &postparsers, list) { if (postparser->func) cfgerr += postparser->func(); -- 1.7.10.4