Software /
code /
prosody-modules
Changeset
3240:c30f2cfe9f15
mod_firewall: Assume empty list if file could not be loaded
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 19 Aug 2018 17:53:05 +0100 |
parents | 3239:796c98e8e666 |
children | 3241:4b52cafd5811 |
files | mod_firewall/definitions.lib.lua |
diffstat | 1 files changed, 8 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_firewall/definitions.lib.lua Sat Aug 18 18:17:42 2018 +0100 +++ b/mod_firewall/definitions.lib.lua Sun Aug 19 17:53:05 2018 +0100 @@ -147,18 +147,19 @@ -- %LIST: file:/path/to/file file = { init = function (self, file_spec, opts) + local items = {}; + local n = 0; local filename = file_spec:gsub("^file:", ""); local file, err = io.open(filename); if not file then module:log("warn", "Failed to open list from %s: %s", filename, err); return; - end - local items = {}; - local n = 0; - for line in file:lines() do - if not items[line] then - n = n + 1; - items[line] = true; + else + for line in file:lines() do + if not items[line] then + n = n + 1; + items[line] = true; + end end end self.items = items;