Software /
code /
prosody-modules
Comparison
mod_firewall/mod_firewall.lua @ 2539:1510b66a43fc
mod_firewall: Allow using spaces instead of underscores in actions, as well as conditions
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 21 Feb 2017 10:38:14 +0000 |
parent | 2538:a1b6a6b0aabb |
child | 2543:3c16f0a8d66c |
comparison
equal
deleted
inserted
replaced
2538:a1b6a6b0aabb | 2539:1510b66a43fc |
---|---|
364 | 364 |
365 if not active_definitions[what] then | 365 if not active_definitions[what] then |
366 active_definitions[what] = {}; | 366 active_definitions[what] = {}; |
367 end | 367 end |
368 active_definitions[what][name] = ret; | 368 active_definitions[what][name] = ret; |
369 elseif line:find("^[^%s:]+[%.=]") then | 369 elseif line:find("^[%w_ ]+[%.=]") then |
370 -- Action | 370 -- Action |
371 if state == nil then | 371 if state == nil then |
372 -- This is a standalone action with no conditions | 372 -- This is a standalone action with no conditions |
373 rule = new_rule(ruleset, chain); | 373 rule = new_rule(ruleset, chain); |
374 end | 374 end |
375 state = "actions"; | 375 state = "actions"; |
376 -- Action handlers? | 376 -- Action handlers? |
377 local action = line:match("^[%w_]+"); | 377 local action = line:match("^[%w_ ]+"):upper():gsub(" ", "_"); |
378 if not action_handlers[action] then | 378 if not action_handlers[action] then |
379 return nil, ("Unknown action on line %d: %s"):format(line_no, action or "<unknown>"); | 379 return nil, ("Unknown action on line %d: %s"):format(line_no, action or "<unknown>"); |
380 end | 380 end |
381 table.insert(rule.actions, "-- "..line) | 381 table.insert(rule.actions, "-- "..line) |
382 local ok, action_string, action_deps = pcall(action_handlers[action], line:match("=(.+)$")); | 382 local ok, action_string, action_deps = pcall(action_handlers[action], line:match("=(.+)$")); |