Software / code / prosody-modules
Comparison
mod_firewall/mod_firewall.lua @ 2549:2ff588094938
mod_firewall: Pass 'module' object to chain handlers
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 23 Feb 2017 14:00:26 +0000 |
| parent | 2548:ce08a57e516b |
| child | 2550:19a182651a9b |
comparison
equal
deleted
inserted
replaced
| 2548:ce08a57e516b | 2549:2ff588094938 |
|---|---|
| 502 | 502 |
| 503 for name in pairs(definition_handlers) do | 503 for name in pairs(definition_handlers) do |
| 504 table.insert(code.global_header, 1, "local "..name:lower().."s = definitions."..name..";"); | 504 table.insert(code.global_header, 1, "local "..name:lower().."s = definitions."..name..";"); |
| 505 end | 505 end |
| 506 | 506 |
| 507 local code_string = "return function (definitions, fire_event, log)\n\t" | 507 local code_string = "return function (definitions, fire_event, log, module)\n\t" |
| 508 ..table.concat(code.global_header, "\n\t") | 508 ..table.concat(code.global_header, "\n\t") |
| 509 .."\n\tlocal db = require 'util.debug';\n\n\t" | 509 .."\n\tlocal db = require 'util.debug';\n\n\t" |
| 510 .."return function (event)\n\t\t" | 510 .."return function (event)\n\t\t" |
| 511 .."local stanza, session = event.stanza, event.origin;\n" | 511 .."local stanza, session = event.stanza, event.origin;\n" |
| 512 ..table.concat(code, "") | 512 ..table.concat(code, "") |
| 532 return nil, "Error compiling (probably a compiler bug, please report): "..err; | 532 return nil, "Error compiling (probably a compiler bug, please report): "..err; |
| 533 end | 533 end |
| 534 local function fire_event(name, data) | 534 local function fire_event(name, data) |
| 535 return module:fire_event(name, data); | 535 return module:fire_event(name, data); |
| 536 end | 536 end |
| 537 chunk = chunk()(active_definitions, fire_event, logger(filename)); -- Returns event handler with 'zones' upvalue. | 537 chunk = chunk()(active_definitions, fire_event, logger(filename), module); -- Returns event handler with 'zones' upvalue. |
| 538 return chunk; | 538 return chunk; |
| 539 end | 539 end |
| 540 | 540 |
| 541 local function resolve_script_path(script_path) | 541 local function resolve_script_path(script_path) |
| 542 local relative_to = prosody.paths.config; | 542 local relative_to = prosody.paths.config; |