mod_firewall: Add INSPECT conditional, for deeper inspection of stanzas
authorKim Alvefur <zash@zash.se>
Thu, 04 Apr 2013 20:31:21 +0200
changeset 954 bec5b6e2eab8
parent 953 2c38d7d8b332
child 955 97454c088b6c
mod_firewall: Add INSPECT conditional, for deeper inspection of stanzas
mod_firewall/conditions.lib.lua
--- a/mod_firewall/conditions.lib.lua	Wed Apr 03 20:29:48 2013 +0200
+++ b/mod_firewall/conditions.lib.lua	Thu Apr 04 20:31:21 2013 +0200
@@ -75,6 +75,14 @@
 	return ("stanza:get_child(nil, %q)"):format(payload_ns);
 end
 
+function condition_handlers.INSPECT(path)
+	if path:find("=") then
+		local path, match = path:match("(.-)=(.*)");
+		return ("stanza:find(%q) == %q"):format(path, match);
+	end
+	return ("stanza:find(%q)"):format(path);
+end
+
 function condition_handlers.FROM_GROUP(group_name)
 	return ("group_contains(%q, bare_from)"):format(group_name), { "group_contains", "bare_from" };
 end