]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] SURBL: Add failure symbols
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 22 Mar 2019 12:16:07 +0000 (12:16 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 22 Mar 2019 12:16:07 +0000 (12:16 +0000)
Issue: #2801

src/plugins/lua/rbl.lua
src/plugins/surbl.c

index 5114ffeb9b4e94d0cf28e2322b2fc85440642f7c..0b53a4ca1bb2c7d7569d8f4f85be94849d41513f 100644 (file)
@@ -560,7 +560,7 @@ local function add_rbl(key, rbl)
 
   -- Failure symbol
   rspamd_config:register_symbol{
-    type = 'virtual',
+    type = 'virtual,nostat',
     name = rbl.symbol .. '_FAIL',
     parent = id,
     score = 0.0,
index 11d3e35d934930a7ef3eb56e347e7261a5004a9a..cab816c501853f5326c01243d1ad3a48472878a2 100644 (file)
@@ -853,7 +853,14 @@ surbl_module_parse_rule (const ucl_object_t* value, struct rspamd_config* cfg)
                                0, surbl_test_url, new_suffix, SYMBOL_TYPE_CALLBACK, -1);
                rspamd_symcache_add_dependency (cfg->cache, cb_id,
                                SURBL_REDIRECTOR_CALLBACK);
+               /* Failure symbol */
+               g_string_append (sym, "_FAIL");
+               rspamd_symcache_add_symbol (cfg->cache, sym->str,
+                               0, NULL, NULL, SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_NOSTAT, cb_id);
+               rspamd_config_add_symbol (cfg, sym->str, 0.0, "SURBL failure symbol",
+                               "surbl", 0, 0, 0);
                g_string_free (sym, TRUE);
+
                nrules++;
                new_suffix->callback_id = cb_id;
                cur = ucl_object_lookup (cur_rule, "bits");
@@ -1617,9 +1624,19 @@ surbl_dns_callback (struct rdns_reply *reply, gpointer arg)
                }
        }
        else {
-               msg_debug_surbl ("<%s> domain [%s] is not in surbl %s",
-                       param->task->message_id, param->host_resolve,
-                       param->suffix->suffix);
+               if (reply->code == RDNS_RC_NXDOMAIN || reply->code == RDNS_RC_NOREC) {
+                       msg_debug_surbl ("<%s> domain [%s] is not in surbl %s",
+                                       param->task->message_id, param->host_resolve,
+                                       param->suffix->suffix);
+               }
+               else {
+                       /* Insert failure symbol */
+                       GString *sym = g_string_new (param->suffix->symbol);
+
+                       g_string_append (sym, "_FAIL");
+                       rspamd_task_insert_result (task, sym->str, 1.0,
+                                       rdns_strerror (reply->code));
+               }
        }
 
        rspamd_symcache_item_async_dec_check (param->task, param->item, M);