Skip to content

Commit

Permalink
[Minor] Fix random monitored requests
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Sep 17, 2019
1 parent abf0834 commit 0240e90
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/libserver/monitored.c
Expand Up @@ -214,12 +214,13 @@ rspamd_monitored_dns_random (struct rspamd_monitored *m,
}

for (guint i = 0; i < len; i ++) {
guint idx = rspamd_random_uint64_fast () % sizeof (dns_chars);
guint idx = rspamd_random_uint64_fast () % (sizeof (dns_chars) - 1);
random_prefix[i] = dns_chars[idx];
}

conf->request->len = 0;
rspamd_printf_gstring (conf->request, "%*.s.%s", len, random_prefix, m->url);
rspamd_printf_gstring (conf->request, "%*.s.%s", len, random_prefix,
m->url);
}

static void *
Expand Down Expand Up @@ -414,7 +415,8 @@ rspamd_monitored_dns_mon (struct rspamd_monitored *m,
if (!rdns_make_request_full (ctx->resolver, rspamd_monitored_dns_cb,
conf, ctx->cfg->dns_timeout, ctx->cfg->dns_retransmits,
1, conf->request->str, conf->rt)) {
msg_notice_mon ("cannot make request to resolve %s", conf->request->str);
msg_notice_mon ("cannot make request to resolve %s (%s monitored url)",
conf->request->str, conf->m->url);

m->cur_errors ++;
rspamd_monitored_propagate_error (m, "failed to make DNS request");
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/lua/rbl.lua
Expand Up @@ -58,6 +58,10 @@ local function get_monitored(rbl)
ret.random = true
end

lua_util.debugm(N, rspamd_config,
'added monitored address: %s (%s random)',
ret.prefix, ret.random)

return ret
end

Expand Down

0 comments on commit 0240e90

Please sign in to comment.