summaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-03-17 15:41:05 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-03-17 15:46:59 +0000
commitc269f2a59c51347ff074010f8bd0f3b117e7c0d6 (patch)
treed9e3d2c0cec1f76f408f374d75d343689cee4c81 /src/libserver
parent9e1ab1e5444e690fc136978f558d5311edebefb7 (diff)
downloadrspamd-c269f2a59c51347ff074010f8bd0f3b117e7c0d6.tar.gz
rspamd-c269f2a59c51347ff074010f8bd0f3b117e7c0d6.zip
[Minor] Implement `hosts` parameter in DNS config
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/dns.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/libserver/dns.c b/src/libserver/dns.c
index 1d114ec96..8fe0c6f92 100644
--- a/src/libserver/dns.c
+++ b/src/libserver/dns.c
@@ -766,18 +766,32 @@ rspamd_dns_resolver_config_ucl (struct rspamd_config *cfg,
}
hosts = ucl_object_lookup (dns_section, "hosts");
+
if (hosts == NULL) {
/* Read normal `/etc/hosts` file */
rspamd_dns_read_hosts_file (cfg, dns_resolver, "/etc/hosts");
}
else if (ucl_object_type (hosts) == UCL_NULL) {
-
+ /* Do nothing, hosts are explicitly disabled */
}
else if (ucl_object_type (hosts) == UCL_STRING) {
-
+ if (!rspamd_dns_read_hosts_file (cfg, dns_resolver, ucl_object_tostring (hosts))) {
+ msg_err_config ("cannot read hosts file %s", ucl_object_tostring (hosts));
+ }
}
else if (ucl_object_type (hosts) == UCL_ARRAY) {
+ const ucl_object_t *cur;
+ ucl_object_iter_t it = NULL;
+ while ((cur = ucl_object_iterate (hosts, &it, true)) != NULL) {
+ if (!rspamd_dns_read_hosts_file (cfg, dns_resolver, ucl_object_tostring (cur))) {
+ msg_err_config ("cannot read hosts file %s", ucl_object_tostring (cur));
+ }
+ }
+ }
+ else {
+ msg_err_config ("invalid type for hosts parameter: %s",
+ ucl_object_type_to_string (ucl_object_type (hosts)));
}
fails_cache_size = ucl_object_lookup (dns_section, "fails_cache_size");