Software /
code /
prosody-modules
Comparison
mod_firewall/marks.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 |
child | 5536:96dec7681af8 |
comparison
equal
deleted
inserted
replaced
2893:d958558e0058 | 2894:165d2877eeac |
---|---|
1 local mark_storage = module:open_store("firewall_marks"); | |
2 | |
3 local user_sessions = prosody.hosts[module.host].sessions; | |
4 | |
5 module:hook("resource-bind", function (event) | |
6 local session = event.session; | |
7 local username = session.username; | |
8 local user = user_sessions[username]; | |
9 local marks = user.firewall_marks; | |
10 if not marks then | |
11 marks = mark_storage:get(username) or {}; | |
12 user.firewall_marks = marks; -- luacheck: ignore 122 | |
13 end | |
14 session.firewall_marks = marks; | |
15 end); | |
16 | |
17 module:hook("resource-unbind", function (event) | |
18 local session = event.session; | |
19 local username = session.username; | |
20 local marks = session.firewall_marks; | |
21 mark_storage:set(username, marks); | |
22 end); | |
23 |