changeset 2573:24dbad147aef

mod_firewall: Fix meta functions with to/from that weren't JID-based
author Matthew Wild <mwild1@gmail.com>
date Sat, 25 Feb 2017 15:46:01 +0000
parents f20dd383093a
children f65c5927ee8e
files mod_firewall/mod_firewall.lua
diffstat 1 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mod_firewall/mod_firewall.lua	Fri Feb 24 17:21:46 2017 +0000
+++ b/mod_firewall/mod_firewall.lua	Sat Feb 25 15:46:01 2017 +0000
@@ -97,14 +97,13 @@
 			end
 			if func_chain then
 				for func_name in func_chain:gmatch("|(%w+)") do
-					if code == "to" or code == "from" then
-						if func_name == "bare" then
-							code = "bare_"..code;
-							table.insert(deps, code);
-						elseif func_name == "node" or func_name == "host" or func_name == "resource" then
-							table.insert(deps, "split_"..code);
-							code = code.."_"..func_name;
-						end
+					-- to/from are already available in local variables, use those if possible
+					if (code == "to" or code == "from") and func_name == "bare" then
+						code = "bare_"..code;
+						table.insert(deps, code);
+					elseif (code == "to" or code == "from") and (func_name == "node" or func_name == "host" or func_name == "resource") then
+						table.insert(deps, "split_"..code);
+						code = code.."_"..func_name;
 					else
 						assert(meta_funcs[func_name], "unknown function: "..func_name);
 						local new_code, new_deps = meta_funcs[func_name](code);