]> source.dussan.org Git - rspamd.git/commitdiff
Fix and prettify ip_score output 349/head
authorAndrew Lewis <nerf@judo.za.org>
Wed, 26 Aug 2015 15:10:09 +0000 (17:10 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Wed, 26 Aug 2015 16:14:18 +0000 (18:14 +0200)
src/plugins/lua/ip_score.lua

index d0129c36ad2a4d38f0bc898b111eb0c00cea4f5c..d2ba8d3ba6920668559eb75873c24b882aa411da 100644 (file)
@@ -253,26 +253,27 @@ local ip_score_check = function(task)
       ip_score = normalize_score(ip_score, total_ip, options['scores']['ip'])
       
       local total_score = 0.0
-      local description = ''
+      local description_t = {}
+
       if ip_score ~= 0 then
         total_score = total_score + ip_score
-        description = description .. 'ip,'
+        table.insert(description_t, 'ip: ' .. '(' .. math.floor(ip_score * 1000) / 100 .. ')')
+      end
+      if ipnet_score ~= 0 then
+        total_score = total_score + ipnet_score
+        table.insert(description_t, 'ipnet: ' .. ipnet .. '(' .. math.floor(ipnet_score * 1000) / 100 .. ')')
       end
       if asn_score ~= 0 then
         total_score = total_score + asn_score
-        description = description .. 'asn:' .. asn .. ','
+        table.insert(description_t, 'asn: ' .. asn .. '(' .. math.floor(asn_score * 1000) / 100 .. ')')
       end
       if country_score ~= 0 then
         total_score = total_score + country_score
-        description = description .. 'country:' .. country .. ','
-      end
-      if ipnet_score ~= 0 then
-        total_score = total_score + ipnet_score
-        description = description .. 'ipnet:' .. ipnet .. ','
+        table.insert(description_t, 'country: ' .. country .. '(' .. math.floor(country_score * 1000) / 100 .. ')')
       end
       
       if total_score ~= 0 then
-        task:insert_result(options['symbol'], total_score, description)
+        task:insert_result(options['symbol'], total_score, table.concat(description_t, ', '))
       end
     end
   end