summaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/once_received.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-10-05 17:58:04 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-10-05 17:58:04 +0400
commit876e5f104227f855269daa0c2812f26a45b38cc7 (patch)
tree68f4f9a405f8613a809c56b08d2253354e548dec /src/plugins/lua/once_received.lua
parentce482fbf8e2c1b9bf0cdba0ab61bc26985ee8977 (diff)
downloadrspamd-876e5f104227f855269daa0c2812f26a45b38cc7.tar.gz
rspamd-876e5f104227f855269daa0c2812f26a45b38cc7.zip
* Add once_received plugin (by dmx)
* Fix read_callback to avoid double freeing of task object
Diffstat (limited to 'src/plugins/lua/once_received.lua')
-rw-r--r--src/plugins/lua/once_received.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/plugins/lua/once_received.lua b/src/plugins/lua/once_received.lua
new file mode 100644
index 000000000..409ec4aff
--- /dev/null
+++ b/src/plugins/lua/once_received.lua
@@ -0,0 +1,15 @@
+-- 0 or 1 received: = spam
+
+local metric = 'default'
+local symbol = 'ONCE_RECEIVED'
+
+function check_quantity_received (task)
+ local recvh = task:get_received_headers()
+ if table.maxn(recvh) <= 1 then
+ task:insert_result(metric, symbol, 1)
+ end
+end
+
+-- Register symbol's callback
+local m = rspamd_config:get_metric(metric)
+m:register_symbol(symbol, 1.0, 'check_quantity_received')