Mercurial > prosody-modules
comparison mod_firewall/mod_firewall.lua @ 2367:3ebd3cb4d7d2
mod_firewall: When compiling on the command-line with -v, ensure chain function names are unique and valid ids
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 15 Nov 2016 15:01:14 +0000 |
| parents | 14021c93a962 |
| children | 7e1d8c46d788 |
comparison
equal
deleted
inserted
replaced
| 2366:14021c93a962 | 2367:3ebd3cb4d7d2 |
|---|---|
| 474 if verbose then | 474 if verbose then |
| 475 print(); | 475 print(); |
| 476 print("local active_definitions = "..serialize(active_definitions)..";"); | 476 print("local active_definitions = "..serialize(active_definitions)..";"); |
| 477 print(); | 477 print(); |
| 478 end | 478 end |
| 479 local c = 0; | |
| 479 for chain, handler_code in pairs(chain_functions) do | 480 for chain, handler_code in pairs(chain_functions) do |
| 481 c = c + 1; | |
| 480 print("---- Chain "..chain:gsub("_", " ")); | 482 print("---- Chain "..chain:gsub("_", " ")); |
| 483 local chain_func_name = "chain_"..tostring(c).."_"..chain:gsub("%p", "_"); | |
| 481 if not verbose then | 484 if not verbose then |
| 482 print(("%s = %s;"):format(chain, handler_code:sub(8))); | 485 print(("%s = %s;"):format(chain_func_name, handler_code:sub(8))); |
| 483 else | 486 else |
| 484 | 487 |
| 485 print(("local %s = (%s)(active_definitions, fire_event, logger(%q));"):format(chain, handler_code:sub(8), filename)); | 488 print(("local %s = (%s)(active_definitions, fire_event, logger(%q));"):format(chain_func_name, handler_code:sub(8), filename)); |
| 486 print(); | 489 print(); |
| 487 | 490 |
| 488 local chain_definition = chains[chain]; | 491 local chain_definition = chains[chain]; |
| 489 if chain_definition and chain_definition.type == "event" then | 492 if chain_definition and chain_definition.type == "event" then |
| 490 for _, event_name in ipairs(chain_definition) do | 493 for _, event_name in ipairs(chain_definition) do |
| 491 print(("module:hook(%q, %s, %d);"):format(event_name, chain, chain_definition.priority or 0)); | 494 print(("module:hook(%q, %s, %d);"):format(event_name, chain_func_name, chain_definition.priority or 0)); |
| 492 end | 495 end |
| 493 end | 496 end |
| 494 print(("module:hook(%q, %s, %d);"):format("firewall/chains/"..chain, chain, chain_definition.priority or 0)); | 497 print(("module:hook(%q, %s, %d);"):format("firewall/chains/"..chain, chain_func_name, chain_definition.priority or 0)); |
| 495 end | 498 end |
| 496 | 499 |
| 497 print("---- End of chain "..chain); | 500 print("---- End of chain "..chain); |
| 498 print(); | 501 print(); |
| 499 end | 502 end |
