Comparison

mod_firewall/mod_firewall.lua @ 2418:ef95853cf900

mod_firewall: More semicolons
author Kim Alvefur <zash@zash.se>
date Fri, 16 Dec 2016 03:30:46 +0100
parent 2416:ade918cd9ca7
child 2464:01babf1caa4a
comparison
equal deleted inserted replaced
2417:5e7badecf7fe 2418:ef95853cf900
105 bare_to = { depends = { "jid_bare", "to" }, local_code = "local bare_to = jid_bare(to)"}; 105 bare_to = { depends = { "jid_bare", "to" }, local_code = "local bare_to = jid_bare(to)"};
106 bare_from = { depends = { "jid_bare", "from" }, local_code = "local bare_from = jid_bare(from)"}; 106 bare_from = { depends = { "jid_bare", "from" }, local_code = "local bare_from = jid_bare(from)"};
107 group_contains = { 107 group_contains = {
108 global_code = [[local group_contains = module:depends("groups").group_contains]]; 108 global_code = [[local group_contains = module:depends("groups").group_contains]];
109 }; 109 };
110 is_admin = { global_code = [[local is_admin = require "core.usermanager".is_admin]]}; 110 is_admin = { global_code = [[local is_admin = require "core.usermanager".is_admin;]]};
111 core_post_stanza = { global_code = [[local core_post_stanza = prosody.core_post_stanza]] }; 111 core_post_stanza = { global_code = [[local core_post_stanza = prosody.core_post_stanza;]] };
112 zone = { global_code = function (zone) 112 zone = { global_code = function (zone)
113 assert(idsafe(zone), "Invalid zone name: "..zone); 113 assert(idsafe(zone), "Invalid zone name: "..zone);
114 return ("local zone_%s = zones[%q] or {};"):format(zone, zone); 114 return ("local zone_%s = zones[%q] or {};"):format(zone, zone);
115 end }; 115 end };
116 date_time = { global_code = [[local os_date = os.date]]; local_code = [[local current_date_time = os_date("*t");]] }; 116 date_time = { global_code = [[local os_date = os.date]]; local_code = [[local current_date_time = os_date("*t");]] };
119 for field in what:gmatch("%a+") do 119 for field in what:gmatch("%a+") do
120 table.insert(defs, ("local current_%s = current_date_time.%s;"):format(field, field)); 120 table.insert(defs, ("local current_%s = current_date_time.%s;"):format(field, field));
121 end 121 end
122 return table.concat(defs, " "); 122 return table.concat(defs, " ");
123 end, depends = { "date_time" }; }; 123 end, depends = { "date_time" }; };
124 timestamp = { global_code = [[local get_time = require "socket".gettime]]; local_code = [[local current_timestamp = get_time()]]; }; 124 timestamp = { global_code = [[local get_time = require "socket".gettime;]]; local_code = [[local current_timestamp = get_time();]]; };
125 globalthrottle = { 125 globalthrottle = {
126 global_code = function (throttle) 126 global_code = function (throttle)
127 assert(idsafe(throttle), "Invalid rate limit name: "..throttle); 127 assert(idsafe(throttle), "Invalid rate limit name: "..throttle);
128 assert(active_definitions.RATE[throttle], "Unknown rate limit: "..throttle); 128 assert(active_definitions.RATE[throttle], "Unknown rate limit: "..throttle);
129 return ("local global_throttle_%s = rates.%s:single();"):format(throttle, throttle); 129 return ("local global_throttle_%s = rates.%s:single();"):format(throttle, throttle);