From: Vsevolod Stakhov Date: Sun, 24 Jun 2018 10:58:47 +0000 (+0100) Subject: [Minor] Improve monitored errors X-Git-Tag: 1.7.7~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a35efbe7f4b664cc81d7ef56271156d16c6e5ae;p=thirdparty%2Frspamd.git [Minor] Improve monitored errors --- diff --git a/src/libserver/monitored.c b/src/libserver/monitored.c index b94229a24d..ff4e4edab0 100644 --- a/src/libserver/monitored.c +++ b/src/libserver/monitored.c @@ -14,11 +14,13 @@ * limitations under the License. */ +#include #include "rdns.h" #include "mem_pool.h" #include "cfg_file.h" #include "cryptobox.h" #include "logger.h" +#include "contrib/uthash/utlist.h" static const gdouble default_monitoring_interval = 60.0; static const guint default_max_errors = 3; @@ -272,6 +274,8 @@ rspamd_monitored_dns_cb (struct rdns_reply *reply, void *arg) { struct rspamd_dns_monitored_conf *conf = arg; struct rspamd_monitored *m; + struct rdns_reply_entry *cur; + gboolean is_special_reply = FALSE; gdouble lat; m = conf->m; @@ -297,11 +301,30 @@ rspamd_monitored_dns_cb (struct rdns_reply *reply, void *arg) rspamd_monitored_propagate_success (m, lat); } else { - msg_info_mon ("DNS reply returned '%s' for %s while '%s' " - "was expected", - rdns_strerror (reply->code), - m->url, - rdns_strerror (conf->expected_code)); + LL_FOREACH (reply->entries, cur) { + if (cur->type == RDNS_REQUEST_A) { + if ((guint32)cur->content.a.addr.s_addr == + INADDR_LOOPBACK) { + is_special_reply = TRUE; + } + } + } + + if (is_special_reply) { + msg_info_mon ("DNS query blocked on %s " + "(127.0.0.1 returned), " + "possibly due to high volume", + m->url); + } + else { + msg_info_mon ("DNS reply returned '%s' for %s while '%s' " + "was expected " + "(likely DNS spoofing or BL internal issues)", + rdns_strerror (reply->code), + m->url, + rdns_strerror (conf->expected_code)); + } + rspamd_monitored_propagate_error (m, "invalid return"); } }