comparison mod_firewall/conditions.lib.lua @ 2894:165d2877eeac

mod_firewall: Add experimental user-centric persistent marks behind a feature flag
author Kim Alvefur <zash@zash.se>
date Sat, 24 Feb 2018 21:40:56 +0100
parents 6f289283feb1
children b1cdcbcd1c90
comparison
equal deleted inserted replaced
2893:d958558e0058 2894:165d2877eeac
274 return ("(current_timestamp - (session.firewall_marked_%s or 0)) < %d"):format(idsafe(name), tonumber(time)), { "timestamp" }; 274 return ("(current_timestamp - (session.firewall_marked_%s or 0)) < %d"):format(idsafe(name), tonumber(time)), { "timestamp" };
275 end 275 end
276 return ("not not session.firewall_marked_"..idsafe(name)); 276 return ("not not session.firewall_marked_"..idsafe(name));
277 end 277 end
278 278
279 function condition_handlers.USER_MARKED(name_and_time)
280 local name, time = name_and_time:match("^%s*([%w_]+)%s+%(([^)]+)s%)%s*$");
281 if not name then
282 name = name_and_time:match("^%s*([%w_]+)%s*$");
283 end
284 if not name then
285 error("Error parsing mark name, see documentation for usage examples");
286 end
287 if time then
288 return ("(current_timestamp - (session.firewall_marks and session.firewall_marks.%s or 0)) < %d"):format(idsafe(name), tonumber(time)), { "timestamp" };
289 end
290 return ("not not (session.firewall_marks and session.firewall_marks."..idsafe(name)..")");
291 end
292
279 function condition_handlers.SENT_DIRECTED_PRESENCE_TO_SENDER() 293 function condition_handlers.SENT_DIRECTED_PRESENCE_TO_SENDER()
280 return "not not (session.directed and session.directed[from])", { "from" }; 294 return "not not (session.directed and session.directed[from])", { "from" };
281 end 295 end
282 296
283 -- TO FULL JID? 297 -- TO FULL JID?