From 6ca6e443b7cfae9583c00a30a8ac1811f11e1d75 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 12 Feb 2014 12:31:54 +0000 Subject: [PATCH] Fix nameservers setup. Conflicts: src/dns.c --- src/cfg_rcl.c | 5 +++-- src/dns.c | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/cfg_rcl.c b/src/cfg_rcl.c index f719e239f..0dc41689b 100644 --- a/src/cfg_rcl.c +++ b/src/cfg_rcl.c @@ -1423,6 +1423,7 @@ rspamd_rcl_parse_struct_string_list (struct config_file *cfg, ucl_object_t *obj, gchar *val; ucl_object_t *cur; const gsize num_str_len = 32; + ucl_object_iter_t iter = NULL; target = (GList **)(((gchar *)pd->user_struct) + pd->offset); @@ -1431,10 +1432,10 @@ rspamd_rcl_parse_struct_string_list (struct config_file *cfg, ucl_object_t *obj, return FALSE; } - for (cur = obj; cur != NULL; cur = cur->next) { + while ((cur = ucl_iterate_object (obj, &iter, true)) != NULL) { switch (cur->type) { case UCL_STRING: - val = memory_pool_strdup (cfg->cfg_pool, ucl_copy_value_trash (obj)); + val = memory_pool_strdup (cfg->cfg_pool, ucl_copy_value_trash (cur)); break; case UCL_INT: val = memory_pool_alloc (cfg->cfg_pool, num_str_len); diff --git a/src/dns.c b/src/dns.c index 5bd7766d6..5ec372f17 100644 --- a/src/dns.c +++ b/src/dns.c @@ -1486,11 +1486,13 @@ dns_resolver_init (struct event_base *ev_base, struct config_file *cfg) p ++; if (!new->is_master_slave) { priority = strtoul (p, &err, 10); - if (err != NULL && (*err == 'm' || *err == 'M' || *err == 's' || *err == 'S')) { - new->is_master_slave = TRUE; - } - else { - msg_info ("bad character '%c', must be 'm' or 's' or a numeric priority", *err); + if (err != NULL && *err != '\0') { + if ((*err == 'm' || *err == 'M' || *err == 's' || *err == 'S')) { + new->is_master_slave = TRUE; + } + else { + msg_info ("bad character '%x', must be 'm' or 's' or a numeric priority", *err); + } } } if (new->is_master_slave) { @@ -1510,14 +1512,15 @@ dns_resolver_init (struct event_base *ev_base, struct config_file *cfg) priority = 0; } serv = &new->servers[new->servers_num]; - if (inet_pton (AF_INET6, p, addr_holder) == 1 || - inet_pton (AF_INET, p, addr_holder) == 1) { + if (inet_pton (AF_INET6, begin, addr_holder) == 1 || + inet_pton (AF_INET, begin, addr_holder) == 1) { serv->name = memory_pool_strdup (new->static_pool, begin); serv->up.priority = priority; + serv->up.weight = priority; new->servers_num ++; } else { - msg_warn ("cannot parse ip address of nameserver: %s", p); + msg_warn ("cannot parse ip address of nameserver: %s", begin); cur = g_list_next (cur); continue; } -- 2.39.5