Mercurial > prosody-modules
comparison mod_firewall/conditions.lib.lua @ 2520:c6fd8975704b
mod_firewall: Initial support for lists, in-memory and HTTP
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 19 Feb 2017 21:10:26 +0000 |
parents | d4bc434a60a4 |
children | 66b81e144ded |
comparison
equal
deleted
inserted
replaced
2519:d4bc434a60a4 | 2520:c6fd8975704b |
---|---|
250 return ("(current_timestamp - (session.firewall_marked_%s or 0)) < %d"):format(idsafe(name), tonumber(time)), { "timestamp" }; | 250 return ("(current_timestamp - (session.firewall_marked_%s or 0)) < %d"):format(idsafe(name), tonumber(time)), { "timestamp" }; |
251 end | 251 end |
252 return ("not not session.firewall_marked_"..idsafe(name)); | 252 return ("not not session.firewall_marked_"..idsafe(name)); |
253 end | 253 end |
254 | 254 |
255 -- CHECK LIST: spammers contains $<@from> | |
256 function condition_handlers.CHECK_LIST(list_condition) | |
257 local list_name, expr = list_condition:match("(%S+) contains (.+)$"); | |
258 if not list_name and expr then | |
259 error("Error parsing list check, syntax: LISTNAME contains EXPRESSION"); | |
260 end | |
261 local meta_deps = {}; | |
262 expr = meta(("%q"):format(expr), meta_deps); | |
263 return ("list_%s:contains(%s) == true"):format(list_name, expr), { "list:"..list_name, unpack(meta_deps) }; | |
264 end | |
265 | |
255 return condition_handlers; | 266 return condition_handlers; |