diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-01 17:57:42 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-01 17:57:42 +0100 |
commit | 61506d52797c8d64588570adda52c0d62698121d (patch) | |
tree | 49f4c8cf6f8e216df29619ce4244aa8ce745ca00 /src/libutil | |
parent | b3eb4d1800eee3527772f26201f6a8a6a3a56022 (diff) | |
download | rspamd-61506d52797c8d64588570adda52c0d62698121d.tar.gz rspamd-61506d52797c8d64588570adda52c0d62698121d.zip |
[Project] Some fixes in SRV records handling
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/upstream.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/libutil/upstream.c b/src/libutil/upstream.c index 22e5200c7..543f07201 100644 --- a/src/libutil/upstream.c +++ b/src/libutil/upstream.c @@ -28,6 +28,7 @@ struct upstream_inet_addr_entry { rspamd_inet_addr_t *addr; + guint priority; struct upstream_inet_addr_entry *next; }; @@ -52,6 +53,7 @@ struct upstream { guint checked; guint dns_requests; gint active_idx; + guint ttl; gchar *name; ev_timer ev; gdouble last_fail; @@ -464,7 +466,6 @@ rspamd_upstream_dns_cb (struct rdns_reply *reply, void *arg) struct rspamd_upstream_srv_dns_cb { struct upstream *up; - guint ttl; guint priority; guint port; guint requests_inflight; @@ -492,12 +493,16 @@ rspamd_upstream_dns_srv_phase2_cb (struct rdns_reply *reply, void *arg) up_ent = g_malloc0 (sizeof (*up_ent)); up_ent->addr = rspamd_inet_address_new (AF_INET, &entry->content.a.addr); + up_ent->priority = cbdata->priority; + rspamd_inet_address_set_port (up_ent->addr, cbdata->port); LL_PREPEND (up->new_addrs, up_ent); } else if (entry->type == RDNS_REQUEST_AAAA) { up_ent = g_malloc0 (sizeof (*up_ent)); up_ent->addr = rspamd_inet_address_new (AF_INET6, &entry->content.aaa.addr); + up_ent->priority = cbdata->priority; + rspamd_inet_address_set_port (up_ent->addr, cbdata->port); LL_PREPEND (up->new_addrs, up_ent); } entry = entry->next; @@ -542,7 +547,8 @@ rspamd_upstream_dns_srv_cb (struct rdns_reply *reply, void *arg) ncbdata = g_malloc0 (sizeof (*ncbdata)); ncbdata->priority = entry->content.srv.weight; ncbdata->port = entry->content.srv.port; - ncbdata->ttl = entry->ttl; + /* XXX: for all entries? */ + upstream->ttl = entry->ttl; if (rdns_make_request_full (upstream->ctx->res, rspamd_upstream_dns_srv_phase2_cb, ncbdata, @@ -646,11 +652,16 @@ rspamd_upstream_lazy_resolve_cb (struct ev_loop *loop, ev_timer *w, int revents) ev_timer_stop (loop, w); if (up->ls) { - rspamd_upstream_resolve_addrs (up->ls, up); - w->repeat = rspamd_time_jitter (up->ls->limits.lazy_resolve_time, - up->ls->limits.lazy_resolve_time * .1); + if (up->ttl == 0 || up->ttl > up->ls->limits.lazy_resolve_time) { + w->repeat = rspamd_time_jitter (up->ls->limits.lazy_resolve_time, + up->ls->limits.lazy_resolve_time * .1); + } + else { + w->repeat = up->ttl; + } + ev_timer_again (loop, w); } |