Mercurial > prosody-modules
comparison mod_firewall/actions.lib.lua @ 5653:62c6e17a5e9d
Merge
| author | Stephen Paul Weber <singpolyma@singpolyma.net> |
|---|---|
| date | Mon, 18 Sep 2023 08:24:19 -0500 |
| parents | 1249ab2f797c |
| children | bfc35ae9edcb |
comparison
equal
deleted
inserted
replaced
| 5652:eade7ff9f52c | 5653:62c6e17a5e9d |
|---|---|
| 218 function action_handlers.UNMARK_ORIGIN(name) | 218 function action_handlers.UNMARK_ORIGIN(name) |
| 219 return [[session.firewall_marked_]]..idsafe(name)..[[ = nil;]] | 219 return [[session.firewall_marked_]]..idsafe(name)..[[ = nil;]] |
| 220 end | 220 end |
| 221 | 221 |
| 222 function action_handlers.MARK_USER(name) | 222 function action_handlers.MARK_USER(name) |
| 223 return [[if session.firewall_marks then session.firewall_marks.]]..idsafe(name)..[[ = current_timestamp; end]], { "timestamp" }; | 223 return ([[if session.username and session.host == current_host then |
| 224 fire_event("firewall/marked/user", { | |
| 225 username = session.username; | |
| 226 mark = %q; | |
| 227 timestamp = current_timestamp; | |
| 228 }); | |
| 229 else | |
| 230 log("warn", "Attempt to MARK a remote user - only local users may be marked"); | |
| 231 end]]):format(assert(idsafe(name), "Invalid characters in mark name: "..name)), { | |
| 232 "current_host"; | |
| 233 "timestamp"; | |
| 234 }; | |
| 224 end | 235 end |
| 225 | 236 |
| 226 function action_handlers.UNMARK_USER(name) | 237 function action_handlers.UNMARK_USER(name) |
| 227 return [[if session.firewall_marks then session.firewall_marks.]]..idsafe(name)..[[ = nil; end]], { "timestamp" }; | 238 return ([[if session.username and session.host == current_host then |
| 239 fire_event("firewall/unmarked/user", { | |
| 240 username = session.username; | |
| 241 mark = %q; | |
| 242 }); | |
| 243 else | |
| 244 log("warn", "Attempt to UNMARK a remote user - only local users may be marked"); | |
| 245 end]]):format(assert(idsafe(name), "Invalid characters in mark name: "..name)); | |
| 228 end | 246 end |
| 229 | 247 |
| 230 function action_handlers.ADD_TO(spec) | 248 function action_handlers.ADD_TO(spec) |
| 231 local list_name, value = spec:match("(%S+) (.+)"); | 249 local list_name, value = spec:match("(%S+) (.+)"); |
| 232 local meta_deps = {}; | 250 local meta_deps = {}; |
