Software /
code /
prosody-modules
Comparison
mod_firewall/mod_firewall.lua @ 5856:75dee6127829 draft
Merge upstream
author | Trần H. Trung <xmpp:trần.h.trung@trung.fun> |
---|---|
date | Tue, 06 Feb 2024 18:32:01 +0700 |
parent | 5816:e304e19536f2 |
child | 5858:866a49f5aa61 |
comparison
equal
deleted
inserted
replaced
5664:52db2da66680 | 5856:75dee6127829 |
---|---|
259 end | 259 end |
260 ]]):format(search_name, pattern_name, search_name, search_name, pattern_name, search_name, pattern_name); | 260 ]]):format(search_name, pattern_name, search_name, search_name, pattern_name, search_name, pattern_name); |
261 return code, { "search:"..search_name, "pattern:"..pattern_name }; | 261 return code, { "search:"..search_name, "pattern:"..pattern_name }; |
262 end; | 262 end; |
263 }; | 263 }; |
264 sender_role = { | |
265 local_code = [[local sender_role = get_jid_role(bare_from, current_host)]]; | |
266 depends = { "bare_from", "current_host", "get_jid_role" }; | |
267 }; | |
268 recipient_role = { | |
269 local_code = [[local recipient_role = get_jid_role(bare_to, current_host)]]; | |
270 depends = { "bare_to", "current_host", "get_jid_role" }; | |
271 }; | |
264 scan_list = { | 272 scan_list = { |
265 global_code = [[local function scan_list(list, items) for item in pairs(items) do if list:contains(item) then return true; end end end]]; | 273 global_code = [[local function scan_list(list, items) for item in pairs(items) do if list:contains(item) then return true; end end end]]; |
266 } | 274 }; |
275 iplib = { | |
276 global_code = [[local iplib = require "util.ip";]]; | |
277 }; | |
278 geoip_country = { | |
279 global_code = [[ | |
280 local geoip_country = require "geoip.country"; | |
281 local geov4 = geoip_country.open(module:get_option_string("geoip_ipv4_country", "/usr/share/GeoIP/GeoIP.dat")); | |
282 local geov6 = geoip_country.open(module:get_option_string("geoip_ipv6_country", "/usr/share/GeoIP/GeoIPv6.dat")); | |
283 local function get_geoip(ips, what) | |
284 if not ips then | |
285 return "--"; | |
286 end | |
287 local ip = iplib.new_ip(ips); | |
288 if not ip then | |
289 return "--"; | |
290 end | |
291 if ip.proto == "IPv6" and geov6 then | |
292 local geoinfo = geoinfo:query_by_addr6(ip.addr); | |
293 if geoinfo then | |
294 return geoinfo[what or "code"]; | |
295 end | |
296 elseif ip.proto == "IPv4" and geov4 then | |
297 local geoinfo = geoinfo:query_by_addr(ip.addr); | |
298 if geoinfo then | |
299 return geoinfo[what or "code"]; | |
300 end | |
301 end | |
302 return "--"; | |
303 end | |
304 ]]; | |
305 depends = { | |
306 "iplib" | |
307 } | |
308 }; | |
267 }; | 309 }; |
268 | 310 |
269 local function include_dep(dependency, code) | 311 local function include_dep(dependency, code) |
270 local dep, dep_param = dependency:match("^([^:]+):?(.*)$"); | 312 local dep, dep_param = dependency:match("^([^:]+):?(.*)$"); |
271 local dep_info = available_deps[dep]; | 313 local dep_info = available_deps[dep]; |