Changeset

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 953:2c38d7d8b332
children 955:97454c088b6c
files mod_firewall/conditions.lib.lua
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
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