Software /
code /
prosody-modules
Diff
mod_firewall/definitions.lib.lua @ 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 |
parent | 2898:9fd61234b6f0 |
child | 4016:b872f111b7af |
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;