Mercurial > prosody-modules
annotate mod_firewall/marks.lib.lua @ 6550:f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 24 May 2026 18:50:41 +0100 |
| parents | d2e50b587721 |
| children | 2d916ba3253c |
| rev | line source |
|---|---|
|
6549
d2e50b587721
mod_firewall: marks: switch to keyval+ store API
Matthew Wild <mwild1@gmail.com>
parents:
6548
diff
changeset
|
1 local mark_storage = module:open_store("firewall_marks", "keyval+"); |
|
2894
165d2877eeac
mod_firewall: Add experimental user-centric persistent marks behind a feature flag
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
|
165d2877eeac
mod_firewall: Add experimental user-centric persistent marks behind a feature flag
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 local user_sessions = prosody.hosts[module.host].sessions; |
|
165d2877eeac
mod_firewall: Add experimental user-centric persistent marks behind a feature flag
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 |
|
6548
430584888704
mod_firewall: marks: load marks from storage on login
Matthew Wild <mwild1@gmail.com>
parents:
5542
diff
changeset
|
5 module:hook("resource-bind", function (event) |
|
430584888704
mod_firewall: marks: load marks from storage on login
Matthew Wild <mwild1@gmail.com>
parents:
5542
diff
changeset
|
6 local session = event.session; |
|
430584888704
mod_firewall: marks: load marks from storage on login
Matthew Wild <mwild1@gmail.com>
parents:
5542
diff
changeset
|
7 local username = session.username; |
|
430584888704
mod_firewall: marks: load marks from storage on login
Matthew Wild <mwild1@gmail.com>
parents:
5542
diff
changeset
|
8 local user = user_sessions[username]; |
|
430584888704
mod_firewall: marks: load marks from storage on login
Matthew Wild <mwild1@gmail.com>
parents:
5542
diff
changeset
|
9 local marks = user.firewall_marks; |
|
430584888704
mod_firewall: marks: load marks from storage on login
Matthew Wild <mwild1@gmail.com>
parents:
5542
diff
changeset
|
10 if not marks then |
|
430584888704
mod_firewall: marks: load marks from storage on login
Matthew Wild <mwild1@gmail.com>
parents:
5542
diff
changeset
|
11 marks = mark_storage:get(username) or {}; |
|
430584888704
mod_firewall: marks: load marks from storage on login
Matthew Wild <mwild1@gmail.com>
parents:
5542
diff
changeset
|
12 user.firewall_marks = marks; -- luacheck: ignore 122 |
|
430584888704
mod_firewall: marks: load marks from storage on login
Matthew Wild <mwild1@gmail.com>
parents:
5542
diff
changeset
|
13 end |
|
430584888704
mod_firewall: marks: load marks from storage on login
Matthew Wild <mwild1@gmail.com>
parents:
5542
diff
changeset
|
14 session.firewall_marks = marks; |
|
430584888704
mod_firewall: marks: load marks from storage on login
Matthew Wild <mwild1@gmail.com>
parents:
5542
diff
changeset
|
15 end); |
|
430584888704
mod_firewall: marks: load marks from storage on login
Matthew Wild <mwild1@gmail.com>
parents:
5542
diff
changeset
|
16 |
|
430584888704
mod_firewall: marks: load marks from storage on login
Matthew Wild <mwild1@gmail.com>
parents:
5542
diff
changeset
|
17 |
|
5536
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
18 module:hook("firewall/marked/user", function (event) |
|
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
19 local user = user_sessions[event.username]; |
|
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
20 local marks = user and user.firewall_marks; |
|
5541
3804ee5117ca
mod_firewall: Load marks from storage on demand rather than at login
Matthew Wild <mwild1@gmail.com>
parents:
5536
diff
changeset
|
21 if user and not marks then |
|
3804ee5117ca
mod_firewall: Load marks from storage on demand rather than at login
Matthew Wild <mwild1@gmail.com>
parents:
5536
diff
changeset
|
22 -- Load marks from storage to cache on the user object |
|
3804ee5117ca
mod_firewall: Load marks from storage on demand rather than at login
Matthew Wild <mwild1@gmail.com>
parents:
5536
diff
changeset
|
23 marks = mark_storage:get(event.username) or {}; |
|
3804ee5117ca
mod_firewall: Load marks from storage on demand rather than at login
Matthew Wild <mwild1@gmail.com>
parents:
5536
diff
changeset
|
24 user.firewall_marks = marks; --luacheck: ignore 122 |
|
3804ee5117ca
mod_firewall: Load marks from storage on demand rather than at login
Matthew Wild <mwild1@gmail.com>
parents:
5536
diff
changeset
|
25 end |
|
5536
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
26 if marks then |
|
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
27 marks[event.mark] = event.timestamp; |
|
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
28 end |
|
6549
d2e50b587721
mod_firewall: marks: switch to keyval+ store API
Matthew Wild <mwild1@gmail.com>
parents:
6548
diff
changeset
|
29 local ok, err = mark_storage:set_key(event.username, event.mark, event.timestamp); |
|
5536
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
30 if not ok then |
|
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
31 module:log("error", "Failed to mark user %q with %q: %s", event.username, event.mark, err); |
|
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
32 end |
|
5542
048284447643
mod_firewall: Add console commands to mark/unmark users
Matthew Wild <mwild1@gmail.com>
parents:
5541
diff
changeset
|
33 return true; |
|
048284447643
mod_firewall: Add console commands to mark/unmark users
Matthew Wild <mwild1@gmail.com>
parents:
5541
diff
changeset
|
34 end, -1); |
|
2894
165d2877eeac
mod_firewall: Add experimental user-centric persistent marks behind a feature flag
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
35 |
|
5536
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
36 module:hook("firewall/unmarked/user", function (event) |
|
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
37 local user = user_sessions[event.username]; |
|
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
38 local marks = user and user.firewall_marks; |
|
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
39 if marks then |
|
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
40 marks[event.mark] = nil; |
|
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
41 end |
|
6549
d2e50b587721
mod_firewall: marks: switch to keyval+ store API
Matthew Wild <mwild1@gmail.com>
parents:
6548
diff
changeset
|
42 local ok, err = mark_storage:set_key(event.username, event.mark, nil); |
|
5536
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
43 if not ok then |
|
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
44 module:log("error", "Failed to unmark user %q with %q: %s", event.username, event.mark, err); |
|
96dec7681af8
mod_firewall: Update user marks to store instantly via map store
Matthew Wild <mwild1@gmail.com>
parents:
2894
diff
changeset
|
45 end |
|
5542
048284447643
mod_firewall: Add console commands to mark/unmark users
Matthew Wild <mwild1@gmail.com>
parents:
5541
diff
changeset
|
46 return true; |
|
048284447643
mod_firewall: Add console commands to mark/unmark users
Matthew Wild <mwild1@gmail.com>
parents:
5541
diff
changeset
|
47 end, -1); |
|
6550
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
48 |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
49 module:add_item("shell-command", { |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
50 section = "firewall"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
51 section_desc = "mod_firewall commands"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
52 name = "mark"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
53 desc = "Add a firewall mark to a user account"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
54 args = { |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
55 { name = "user_jid", type = "string" }; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
56 { name = "mark_name", type = "string" }; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
57 }; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
58 host_selector = "user_jid"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
59 handler = function(self, user_jid, mark_name) --luacheck: ignore 212/self 212/host |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
60 local username, host = jid.split(user_jid); |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
61 if not username or not hosts[host] then |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
62 return nil, "Invalid JID supplied"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
63 elseif not idsafe(mark_name) then |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
64 return nil, "Invalid characters in mark name"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
65 end |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
66 if not module:fire_event("firewall/marked/user", { |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
67 username = session.username; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
68 mark = mark_name; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
69 timestamp = os.time(); |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
70 }) then |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
71 return nil, "Failed to set mark"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
72 end |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
73 return true, "Marked"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
74 end; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
75 }); |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
76 |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
77 module:add_item("shell-command", { |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
78 section = "firewall"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
79 section_desc = "mod_firewall commands"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
80 name = "unmark"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
81 desc = "Remove a firewall mark from a user account"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
82 args = { |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
83 { name = "user_jid", type = "string" }; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
84 { name = "mark_name", type = "string" }; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
85 }; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
86 host_selector = "user_jid"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
87 handler = function(self, user_jid, mark_name) --luacheck: ignore 212/self 212/host |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
88 local username, host = jid.split(user_jid); |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
89 if not username or not hosts[host] then |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
90 return nil, "Invalid JID supplied"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
91 elseif not idsafe(mark_name) then |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
92 return nil, "Invalid characters in mark name"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
93 end |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
94 if not module:fire_event("firewall/unmarked/user", { |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
95 username = session.username; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
96 mark = mark_name; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
97 timestamp = os.time(); |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
98 }) then |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
99 return nil, "Failed to remove mark"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
100 end |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
101 return true, "Unmarked"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
102 end; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
103 }); |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
104 |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
105 module:add_item("shell-command", { |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
106 section = "firewall"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
107 section_desc = "mod_firewall commands"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
108 name = "marked"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
109 desc = "List all user accounts with a specific firewall mark"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
110 args = { |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
111 { name = "host", type = "string" }; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
112 { name = "mark_name", type = "string" }; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
113 }; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
114 host_selector = "host"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
115 handler = function(self, host, mark_name) --luacheck: ignore 212/self 212/host |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
116 if not idsafe(mark_name) then |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
117 return nil, "Invalid characters in mark name"; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
118 end |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
119 local users = mark_storage:get_key_from_all(mark_name); |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
120 local usernames = {}; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
121 for username in it.keys(users) do |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
122 table.insert(usernames, username); |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
123 end |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
124 table.sort(usernames, function (a, b) |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
125 return users[a] < users[b]; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
126 end); |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
127 for _, username in ipairs(usernames) do |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
128 self.session.print(username, os.date("%Y-%m-%d %R:%s", users[username]); |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
129 end |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
130 return true, ("Showing %d users"):format(#usernames); |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
131 end; |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
132 }); |
|
f9d93d7cd6d5
mod_firewall: marks: Add commands for managing marks
Matthew Wild <mwild1@gmail.com>
parents:
6549
diff
changeset
|
133 |
