diff mod_firewall/mod_firewall.lua @ 966:a65df6e97d94

mod_firewall: Add time and date deps
author Matthew Wild <mwild1@gmail.com>
date Sat, 06 Apr 2013 14:02:38 +0100
parents d4e24fb289c0
children a88f33fe6970
line wrap: on
line diff
--- a/mod_firewall/mod_firewall.lua	Fri Apr 05 19:21:46 2013 +0100
+++ b/mod_firewall/mod_firewall.lua	Sat Apr 06 14:02:38 2013 +0100
@@ -76,6 +76,14 @@
 		assert(zone:match("^%a[%w_]*$"), "Invalid zone name: "..zone);
 		return ("local zone_%s = zones[%q] or {};"):format(zone, zone);
 	end };
+	date_time = { global_code = [[local os_date = os.date]]; local_code = [[local current_date_time = os_date("*t");]] };
+	time = { local_code = function (what)
+		local defs = {};
+		for field in what:gmatch("%a+") do
+			table.insert(defs, ("local current_%s = current_date_time.%s;"):format(field, field));
+		end
+		return table.concat(defs, " ");
+	end, depends = { "date_time" }; };
 };
 
 local function include_dep(dep, code)