mod_firewall/conditions.lib.lua
changeset 2132 21bc4d7cddae
parent 2131 59023dffbdd4
child 2346 6848297cf40a
equal deleted inserted replaced
2131:59023dffbdd4 2132:21bc4d7cddae
   180 		table.insert(conditions, "("..table.concat(clause, " "..op.." ")..")");
   180 		table.insert(conditions, "("..table.concat(clause, " "..op.." ")..")");
   181 	end
   181 	end
   182 	return table.concat(conditions, " or "), { "time:hour,min" };
   182 	return table.concat(conditions, " or "), { "time:hour,min" };
   183 end
   183 end
   184 
   184 
   185 function condition_handlers.LIMIT(name)
   185 function condition_handlers.LIMIT(spec)
   186 	return ("not throttle_%s:poll(1)"):format(name), { "throttle:"..name };
   186 	local name, param = spec:match("^(%w+) on (.+)$");
       
   187 
       
   188 	if not name then
       
   189 		name = spec:match("^%w+$");
       
   190 		if not name then
       
   191 			error("Unable to parse LIMIT specification");
       
   192 		end
       
   193 	else
       
   194 		param = meta(("%q"):format(param));
       
   195 	end
       
   196 
       
   197 	if not param then
       
   198 		return ("not global_throttle_%s:poll(1)"):format(name), { "globalthrottle:"..name };
       
   199 	end
       
   200 	return ("not multi_throttle_%s:poll_on(%s, 1)"):format(name, param), { "multithrottle:"..name };	
   187 end
   201 end
   188 
   202 
   189 function condition_handlers.ORIGIN_MARKED(name_and_time)
   203 function condition_handlers.ORIGIN_MARKED(name_and_time)
   190 	local name, time = name_and_time:match("^%s*([%w_]+)%s+%(([^)]+)s%)%s*$");
   204 	local name, time = name_and_time:match("^%s*([%w_]+)%s+%(([^)]+)s%)%s*$");
   191 	if not name then
   205 	if not name then