Changeset

4016:b872f111b7af

mod_firewall: Add option to ignore missing list files
author Matthew Wild <mwild1@gmail.com>
date Mon, 11 May 2020 17:18:30 +0100
parents 4015:001c756ead7d
children 4017:015452258952
files mod_firewall/definitions.lib.lua
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_firewall/definitions.lib.lua	Sun May 10 09:03:16 2020 +0200
+++ b/mod_firewall/definitions.lib.lua	Mon May 11 17:18:30 2020 +0100
@@ -10,6 +10,7 @@
 local new_throttle = require "util.throttle".create;
 local hashes = require "util.hashes";
 local jid = require "util.jid";
+local lfs = require "lfs";
 
 local multirate_cache_size = module:get_option_number("firewall_multirate_cache_limit", 1000);
 
@@ -150,6 +151,10 @@
 			local items = {};
 			local n = 0;
 			local filename = file_spec:gsub("^file:", "");
+			if opts.missing == "ignore" and not lfs.attributes(filename, "mode") then
+				module:log("debug", "Ignoring missing list file: %s", filename);
+				return;
+			end
 			local file, err = io.open(filename);
 			if not file then
 				module:log("warn", "Failed to open list from %s: %s", filename, err);