comparison mod_firewall/mod_firewall.lua @ 6502:b15601203d0d

mod_firewall: Support 'FROM IP' and 'FROM SUBNET' conditions
author Matthew Wild <mwild1@gmail.com>
date Thu, 26 Mar 2026 13:33:44 +0000
parents 547feb8181eb
children ce716e5e0fee
comparison
equal deleted inserted replaced
6501:f7158c0e2202 6502:b15601203d0d
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]]; 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]];
274 }; 274 };
275 iplib = { 275 iplib = {
276 global_code = [[local iplib = require "util.ip";]]; 276 global_code = [[local iplib = require "util.ip";]];
277 }; 277 };
278 session_parsed_ip = {
279 local_code = [[local session_parsed_ip = iplib.new_ip(session.ip)]];
280 depends = { "iplib" };
281 };
282 parsed_ip = {
283 local_code = function (parsed_ip_spec)
284 local ip_hash, ip_str = parsed_ip_spec:match("^(%x+):(.+)$");
285 local code = ([[local parsed_ip_%s = iplib.new_ip(%q)]]):format(ip_hash, ip_str)
286 return code, { "iplib" };
287 end;
288 };
278 geoip_country = { 289 geoip_country = {
279 global_code = [[ 290 global_code = [[
280 local geoip_country = require "geoip.country"; 291 local geoip_country = require "geoip.country";
281 local geov4 = geoip_country.open(module:get_option_string("geoip_ipv4_country", "/usr/share/GeoIP/GeoIP.dat")); 292 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")); 293 local geov6 = geoip_country.open(module:get_option_string("geoip_ipv6_country", "/usr/share/GeoIP/GeoIPv6.dat"));