commit 0240e90: [Minor] Fix random monitored requests

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Sep 17 14:42:06 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-09-17 15:36:41 +0100
URL: https://github.com/rspamd/rspamd/commit/0240e90e511812cb1c97c47d709835d526ad6e46 (HEAD -> master)

[Minor] Fix random monitored requests

---
 src/libserver/monitored.c | 8 +++++---
 src/plugins/lua/rbl.lua   | 4 ++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/libserver/monitored.c b/src/libserver/monitored.c
index 4d88bb4f9..821e128d6 100644
--- a/src/libserver/monitored.c
+++ b/src/libserver/monitored.c
@@ -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 *
@@ -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");
diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua
index aa3857b6a..ffb3b85e1 100644
--- a/src/plugins/lua/rbl.lua
+++ b/src/plugins/lua/rbl.lua
@@ -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
 


More information about the Commits mailing list