Mercurial > prosody-modules
comparison mod_firewall/marks.lib.lua @ 5542:048284447643
mod_firewall: Add console commands to mark/unmark users
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 08 Jun 2023 19:47:35 +0100 |
parents | 3804ee5117ca |
children |
comparison
equal
deleted
inserted
replaced
5541:3804ee5117ca | 5542:048284447643 |
---|---|
16 end | 16 end |
17 local ok, err = mark_map_storage:set(event.username, event.mark, event.timestamp); | 17 local ok, err = mark_map_storage:set(event.username, event.mark, event.timestamp); |
18 if not ok then | 18 if not ok then |
19 module:log("error", "Failed to mark user %q with %q: %s", event.username, event.mark, err); | 19 module:log("error", "Failed to mark user %q with %q: %s", event.username, event.mark, err); |
20 end | 20 end |
21 end, 1); | 21 return true; |
22 end, -1); | |
22 | 23 |
23 module:hook("firewall/unmarked/user", function (event) | 24 module:hook("firewall/unmarked/user", function (event) |
24 local user = user_sessions[event.username]; | 25 local user = user_sessions[event.username]; |
25 local marks = user and user.firewall_marks; | 26 local marks = user and user.firewall_marks; |
26 if marks then | 27 if marks then |
28 end | 29 end |
29 local ok, err = mark_map_storage:set(event.username, event.mark, nil); | 30 local ok, err = mark_map_storage:set(event.username, event.mark, nil); |
30 if not ok then | 31 if not ok then |
31 module:log("error", "Failed to unmark user %q with %q: %s", event.username, event.mark, err); | 32 module:log("error", "Failed to unmark user %q with %q: %s", event.username, event.mark, err); |
32 end | 33 end |
33 end, 1); | 34 return true; |
35 end, -1); |