Comparison

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
parent 965:d4e24fb289c0
child 967:a88f33fe6970
comparison
equal deleted inserted replaced
965:d4e24fb289c0 966:a65df6e97d94
74 core_post_stanza = { global_code = [[local core_post_stanza = prosody.core_post_stanza]] }; 74 core_post_stanza = { global_code = [[local core_post_stanza = prosody.core_post_stanza]] };
75 zone = { global_code = function (zone) 75 zone = { global_code = function (zone)
76 assert(zone:match("^%a[%w_]*$"), "Invalid zone name: "..zone); 76 assert(zone:match("^%a[%w_]*$"), "Invalid zone name: "..zone);
77 return ("local zone_%s = zones[%q] or {};"):format(zone, zone); 77 return ("local zone_%s = zones[%q] or {};"):format(zone, zone);
78 end }; 78 end };
79 date_time = { global_code = [[local os_date = os.date]]; local_code = [[local current_date_time = os_date("*t");]] };
80 time = { local_code = function (what)
81 local defs = {};
82 for field in what:gmatch("%a+") do
83 table.insert(defs, ("local current_%s = current_date_time.%s;"):format(field, field));
84 end
85 return table.concat(defs, " ");
86 end, depends = { "date_time" }; };
79 }; 87 };
80 88
81 local function include_dep(dep, code) 89 local function include_dep(dep, code)
82 local dep, dep_param = dep:match("^([^:]+):?(.*)$"); 90 local dep, dep_param = dep:match("^([^:]+):?(.*)$");
83 local dep_info = available_deps[dep]; 91 local dep_info = available_deps[dep];