diff mod_firewall/conditions.lib.lua @ 954:bec5b6e2eab8

mod_firewall: Add INSPECT conditional, for deeper inspection of stanzas
author Kim Alvefur <zash@zash.se>
date Thu, 04 Apr 2013 20:31:21 +0200
parents c91cac3b823f
children 93ffa3ffc66f
line wrap: on
line diff
--- 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