]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Small polishes for Lua parts
authorAndrew Lewis <nerf@judo.za.org>
Wed, 16 Nov 2016 08:17:42 +0000 (10:17 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Wed, 16 Nov 2016 08:17:42 +0000 (10:17 +0200)
src/plugins/lua/antivirus.lua
src/plugins/lua/asn.lua
src/plugins/lua/dmarc.lua
src/plugins/lua/fann_classifier.lua
src/plugins/lua/hfilter.lua
src/plugins/lua/multimap.lua
src/plugins/lua/phishing.lua
src/plugins/lua/replies.lua
src/plugins/lua/spamassassin.lua
src/plugins/lua/trie.lua

index c55305f2a1be698e801a3f0c8df3e801a6abb1f6..91ac61af691720a1632a7898dac480fcad10f4f4 100644 (file)
@@ -346,7 +346,7 @@ local function clamav_check(task, rule)
         upstream:ok()
 
         data = tostring(data)
-        local s,_ = string.find(data, ' FOUND')
+        local s = string.find(data, ' FOUND')
         local cached = 'OK'
         if s then
           local vname = string.match(data:sub(1, s - 1), 'stream: (.+)')
index 7fff000a45c1462cb8d6fff6087f61f1da417c08..91b5cc87499b27ee335c85c48cb514798feb17c7 100644 (file)
@@ -131,7 +131,7 @@ local function asn_check(task)
       end
     end
 
-    local ret,_,_ = rspamd_redis_make_request(task,
+    local ret = rspamd_redis_make_request(task,
       redis_params, -- connect params
       key, -- hash key
       false, -- is write
index cdbc8700e7f97ce00b0e562a5afdbd1d2a1ff5fd..400882755dd83173904d3e36f7f56cad537c8a6d 100644 (file)
@@ -116,6 +116,7 @@ local function dmarc_callback(task)
 
   local function dmarc_dns_cb(_, to_resolve, results, err)
 
+    task:inc_dns_req()
     local lookup_domain = string.sub(to_resolve, 8)
     if err and (err ~= 'requested record is not found' and err ~= 'no records with this name') then
       task:insert_result(dmarc_symbols['dnsfail'], 1.0, lookup_domain .. ' : ' .. err)
index 770f244d8dc6fb8df9b4e48510f9f206e22dcbf2..ca6fb202688585f8b1fa2b06032aed4d085ebdee 100644 (file)
@@ -282,7 +282,7 @@ if redis_params then
       maybe_load_fann(task, classify_cb, false)
     end,
 
-    learn = function(task, _, tokens, is_spam, _)
+    learn = function(task, _, tokens, is_spam)
       local function learn_cb(_, is_loaded)
         if not is_loaded then
           create_fann()
index 6bf8358a9a7ca66ac5bd0e5525d9a429ab5a67f9..0bcbc52ffdb30e921a068d2aeb0782a0d1780d94 100644 (file)
@@ -19,8 +19,7 @@ limitations under the License.
 -- Weight for checks_hellohost and checks_hello: 5 - very hard, 4 - hard, 3 - meduim, 2 - low, 1 - very low.
 -- From HFILTER_HELO_* and HFILTER_HOSTNAME_* symbols the maximum weight is selected in case of their actuating.
 
-
---local dumper = require 'pl.pretty'.dump
+local rspamd_logger = require "rspamd_logger"
 local rspamd_regexp = require "rspamd_regexp"
 local rspamc_local_helo = "rspamc.local"
 local checks_hellohost = {
@@ -142,8 +141,11 @@ local function check_host(task, host, symbol_suffix, eq_ip, eq_host)
   local failed_address = 0
   local resolved_address = {}
 
-  local function check_host_cb_mx(_, _, results)
+  local function check_host_cb_mx(_, to_resolve, results, err)
     task:inc_dns_req()
+    if err and (err ~= 'requested record is not found' and err ~= 'no records with this name') then
+        rspamd_logger.errx(task, 'error looking up %s: %s', to_resolve, err)
+    end
     if not results then
       task:insert_result('HFILTER_' .. symbol_suffix .. '_NORES_A_OR_MX', 1.0)
     else
index 9783e99cb3f84057e8ce6dd985a4c097924560f5..0e0ead4741e6ce6f07f243cfe5ea38fd12e51502 100644 (file)
@@ -528,6 +528,7 @@ local function multimap_callback(task, rule)
         match_rule(rule, ip)
       else
         local cb = function (_, to_resolve, results, err)
+          task:inc_dns_req()
           if err and (err ~= 'requested record is not found' and err ~= 'no records with this name') then
             rspamd_logger.errx(task, 'error looking up %s: %s', to_resolve, err)
           end
index 015e079dd9c39748d91bf53be3da884792bc8620..1383fcd05e50301e2ec4f8258ad3add6f8765756 100644 (file)
@@ -177,7 +177,7 @@ local function phishing_map(mapname, phishmap, id)
       xd[1] = opts[mapname]
     end
     for _,d in ipairs(xd) do
-      local s, _ = string.find(d, ':[^:]+$')
+      local s = string.find(d, ':[^:]+$')
       if s then
         local sym = string.sub(d, s + 1, -1)
         local map = string.sub(d, 1, s - 1)
index 314f09083d27cd8509f48a53b07b7095927a3fc8..c8e4bb6b6dfdcdd9e2943e427e5bb4bf51c932c0 100644 (file)
@@ -65,7 +65,7 @@ local function replies_check(task)
   -- Create hash of in-reply-to and query redis
   local key = make_key(irt)
 
-  local ret,_,_ = rspamd_redis_make_request(task,
+  local ret = rspamd_redis_make_request(task,
     redis_params, -- connect params
     key, -- hash key
     false, -- is write
@@ -96,7 +96,7 @@ local function replies_set(task)
   end
   -- Create hash of message-id and store to redis
   local key = make_key(msg_id)
-  local ret,_,_ = rspamd_redis_make_request(task,
+  local ret = rspamd_redis_make_request(task,
     redis_params, -- connect params
     key, -- hash key
     true, -- is write
index 07a80bb90e96412c4c82577cebd83a26d864d864..f6bb37fdfa43324bffbca7fdbdbe2216756b0ffd 100644 (file)
@@ -1097,10 +1097,10 @@ local function apply_replacements(str)
   end
 
   local function replace_all_tags(s)
-    local sstr, _
+    local sstr
     sstr = s
     fun.each(function(n, t)
-        sstr,_ = string.gsub(sstr, string.format("<%s>", n),
+        sstr = string.gsub(sstr, string.format("<%s>", n),
           string.format("%s%s%s", pre, t, post))
     end, replace['tags'])
 
index 443f2e5dea094a562cb423dd3e46854955e61b53..1be5b1d98466eb89f6a91a5d8293bf7dca3f7bcc 100644 (file)
@@ -18,7 +18,7 @@ limitations under the License.
 
 local rspamd_logger = require "rspamd_logger"
 local rspamd_trie = require "rspamd_trie"
-local _ = require "fun"
+local fun = require "fun"
 
 local mime_trie
 local raw_trie
@@ -122,7 +122,7 @@ local function process_trie_conf(symbol, cf)
   if cf['file'] then
     process_trie_file(symbol, cf)
   elseif cf['patterns'] then
-    _.each(function(pat)
+    fun.each(function(pat)
       process_single_pattern(pat, symbol, cf)
     end, cf['patterns'])
   end