aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/dns.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-21 15:35:08 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-21 15:35:08 +0100
commitdfd52fad8db7a38b33a0ff5127bef31c42c3d4b1 (patch)
tree10d76257cb91dc814b1f9787893ff7ca1b0cdcd0 /src/libserver/dns.c
parent7b4f90b2919c85fcafa663c96c754eb10c3595b8 (diff)
downloadrspamd-dfd52fad8db7a38b33a0ff5127bef31c42c3d4b1.tar.gz
rspamd-dfd52fad8db7a38b33a0ff5127bef31c42c3d4b1.zip
Allow NULL-config resolver.
Diffstat (limited to 'src/libserver/dns.c')
-rw-r--r--src/libserver/dns.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/libserver/dns.c b/src/libserver/dns.c
index 41426f741..72903a6cf 100644
--- a/src/libserver/dns.c
+++ b/src/libserver/dns.c
@@ -116,22 +116,33 @@ dns_resolver_init (rspamd_logger_t *logger,
new = g_slice_alloc0 (sizeof (struct rspamd_dns_resolver));
new->ev_base = ev_base;
- new->request_timeout = cfg->dns_timeout;
- new->max_retransmits = cfg->dns_retransmits;
+ if (cfg != NULL) {
+ new->request_timeout = cfg->dns_timeout;
+ new->max_retransmits = cfg->dns_retransmits;
+ }
+ else {
+ new->request_timeout = 1;
+ new->max_retransmits = 2;
+ }
new->r = rdns_resolver_new ();
rdns_bind_libevent (new->r, new->ev_base);
- rdns_resolver_set_log_level (new->r, cfg->log_level);
+
+ if (cfg != NULL) {
+ rdns_resolver_set_log_level (new->r, cfg->log_level);
+ }
rdns_resolver_set_logger (new->r,
(rdns_log_function)rspamd_common_logv,
logger);
- if (cfg->nameservers == NULL) {
+ if (cfg == NULL || cfg->nameservers == NULL) {
/* Parse resolv.conf */
if (!rdns_resolver_parse_resolv_conf (new->r, "/etc/resolv.conf")) {
msg_err (
"cannot parse resolv.conf and no nameservers defined, so no ways to resolve addresses");
- return new;
+ rdns_resolver_release (new->r);
+ g_slice_free1 (sizeof (struct rspamd_dns_resolver), new);
+ return NULL;
}
}
else {