Mercurial > prosody-modules
comparison mod_firewall/actions.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 | 8fd37f0e108c |
children | b8f2e86df7ce |
comparison
equal
deleted
inserted
replaced
2893:d958558e0058 | 2894:165d2877eeac |
---|---|
211 | 211 |
212 function action_handlers.UNMARK_ORIGIN(name) | 212 function action_handlers.UNMARK_ORIGIN(name) |
213 return [[session.firewall_marked_]]..idsafe(name)..[[ = nil;]] | 213 return [[session.firewall_marked_]]..idsafe(name)..[[ = nil;]] |
214 end | 214 end |
215 | 215 |
216 function action_handlers.MARK_USER(name) | |
217 return [[if session.firewall_marks then session.firewall_marks.]]..idsafe(name)..[[ = current_timestamp; end]], { "timestamp" }; | |
218 end | |
219 | |
220 function action_handlers.UNMARK_USER(name) | |
221 return [[if session.firewall_marks then session.firewall_marks.]]..idsafe(name)..[[ = nil; end]], { "timestamp" }; | |
222 end | |
223 | |
216 function action_handlers.ADD_TO(spec) | 224 function action_handlers.ADD_TO(spec) |
217 local list_name, value = spec:match("(%S+) (.+)"); | 225 local list_name, value = spec:match("(%S+) (.+)"); |
218 local meta_deps = {}; | 226 local meta_deps = {}; |
219 value = meta(("%q"):format(value), meta_deps); | 227 value = meta(("%q"):format(value), meta_deps); |
220 return ("list_%s:add(%s);"):format(list_name, value), { "list:"..list_name, unpack(meta_deps) }; | 228 return ("list_%s:add(%s);"):format(list_name, value), { "list:"..list_name, unpack(meta_deps) }; |