mod_firewall/conditions.lib.lua
changeset 2586 ac3140cd89a2
parent 2581 00cef058df8d
child 2588 d64fc9c3cffd
equal deleted inserted replaced
2585:0116672348c4 2586:ac3140cd89a2
    19 	end
    19 	end
    20 	return table.concat(conditions, " or ");
    20 	return table.concat(conditions, " or ");
    21 end
    21 end
    22 
    22 
    23 function condition_handlers.KIND(kind)
    23 function condition_handlers.KIND(kind)
       
    24 	assert(kind, "Expected stanza kind to match against");
    24 	return compile_comparison_list("name", kind), { "name" };
    25 	return compile_comparison_list("name", kind), { "name" };
    25 end
    26 end
    26 
    27 
    27 local wildcard_equivs = { ["*"] = ".*", ["?"] = "." };
    28 local wildcard_equivs = { ["*"] = ".*", ["?"] = "." };
    28 
    29 
    79 	-- Intentionally not using 'to' here, as that defaults to bare JID when nil
    80 	-- Intentionally not using 'to' here, as that defaults to bare JID when nil
    80 	return ("stanza.attr.to == nil");
    81 	return ("stanza.attr.to == nil");
    81 end
    82 end
    82 
    83 
    83 function condition_handlers.TYPE(type)
    84 function condition_handlers.TYPE(type)
       
    85 	assert(type, "Expected 'type' value to match against");
    84 	return compile_comparison_list("(type or (name == 'message' and 'normal') or (name == 'presence' and 'available'))", type), { "type", "name" };
    86 	return compile_comparison_list("(type or (name == 'message' and 'normal') or (name == 'presence' and 'available'))", type), { "type", "name" };
    85 end
    87 end
    86 
    88 
    87 local function zone_check(zone, which)
    89 local function zone_check(zone, which)
    88 	local which_not = which == "from" and "to" or "from";
    90 	local which_not = which == "from" and "to" or "from";