Comparison

mod_firewall/conditions.lib.lua @ 2107:f445f43b9ba1

mod_firewall: Add support for session marking (MARK_ORIGIN, UNMARK_ORIGIN, ORIGIN_MARKED)
author Matthew Wild <mwild1@gmail.com>
date Thu, 17 Mar 2016 11:27:10 +0000
parent 2075:baa1cb349427
child 2109:9db4113d0cb5
comparison
equal deleted inserted replaced
2106:f2ee508315e1 2107:f445f43b9ba1
178 178
179 function condition_handlers.LIMIT(name) 179 function condition_handlers.LIMIT(name)
180 return ("not throttle_%s:poll(1)"):format(name), { "throttle:"..name }; 180 return ("not throttle_%s:poll(1)"):format(name), { "throttle:"..name };
181 end 181 end
182 182
183 function condition_handlers.ORIGIN_MARKED(name_and_time)
184 local name, time = name_and_time:match("^%s*(%w+)%s+%(([^)]+)s%)%s*$");
185 if not name then
186 name = name_and_time:match("^%s*(%w+)%s*$");
187 end
188 if not name then
189 error("Error parsing mark name, see documentation for usage examples");
190 end
191 if time then
192 return ("(current_time - (session.firewall_marked_%s or 0)) < %d"):format(idsafe(name), tonumber(time)), { "timestamp" };
193 end
194 return ("not not session.firewall_marked_"..idsafe(name));
195 end
196
183 return condition_handlers; 197 return condition_handlers;