]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add received tokens
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 17 Nov 2018 13:30:26 +0000 (13:30 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 17 Nov 2018 13:30:26 +0000 (13:30 +0000)
lualib/lua_stat.lua

index 2fb633cd385855137e50f0e96b391d8457cb9c2d..21870b27d04718a915a2702b1718ed26f61a1c78 100644 (file)
@@ -766,6 +766,25 @@ local function get_meta_stat_tokens(task, res, i)
     i = i + 1
   end
 
+  local rh = task:get_received_headers()
+
+  if rh and #rh > 0 then
+    local lim = math.min(5, #rh)
+    for j =1,lim do
+      local rcvd = rh[j]
+      local ip = rcvd.real_ip
+      if ip and ip:is_valid() and ip:get_version() == 4 then
+        local masked = ip:apply_mask(24)
+
+        rawset(res, i, string.format("#rcv:%s:%s", tostring(masked),
+            rcvd.proto))
+        lua_util.debugm("bayes", task, "added received token: %s",
+            res[i])
+        i = i + 1
+      end
+    end
+  end
+
   return i
 end