diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2014-10-24 00:50:59 +0300 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2015-03-26 00:01:27 +0200 |
commit | 65d36f6f83d1a8f4bdef8508f0addfdbf08e2833 (patch) | |
tree | cfd8cef240f1eac022c2840e278d88fcc71b2d7b | |
parent | ca2cdba6a930f614f25dfc45122be248ac9b5787 (diff) | |
download | awall-65d36f6f83d1a8f4bdef8508f0addfdbf08e2833.tar.bz2 awall-65d36f6f83d1a8f4bdef8508f0addfdbf08e2833.tar.xz |
use table.unpack
-rwxr-xr-x | awall-cli | 3 | ||||
-rw-r--r-- | awall/class.lua | 2 | ||||
-rw-r--r-- | awall/ipset.lua | 5 | ||||
-rw-r--r-- | awall/iptables.lua | 5 | ||||
-rw-r--r-- | awall/modules/filter.lua | 2 | ||||
-rw-r--r-- | awall/optfrag.lua | 4 | ||||
-rw-r--r-- | awall/uerror.lua | 2 |
7 files changed, 14 insertions, 9 deletions
@@ -14,6 +14,9 @@ signal = posix.signal stringy = require('stringy') +-- Lua 5.1 compatibility +if not table.unpack then table.unpack = unpack end + function help() io.stderr:write([[ Alpine Wall diff --git a/awall/class.lua b/awall/class.lua index de36a43..0320503 100644 --- a/awall/class.lua +++ b/awall/class.lua @@ -19,7 +19,7 @@ local function class(base) return function(...) local arg = {...} arg[1] = obj - return v(unpack(arg)) + return v(table.unpack(arg)) end end } diff --git a/awall/ipset.lua b/awall/ipset.lua index 8a3e041..081ba97 100644 --- a/awall/ipset.lua +++ b/awall/ipset.lua @@ -20,8 +20,9 @@ end function IPSet:create() for name, ipset in pairs(self.config) do - local pid = lpc.run('ipset', '-!', 'create', name, - unpack(ipset.options)) + local pid = lpc.run( + 'ipset', '-!', 'create', name, table.unpack(ipset.options) + ) if lpc.wait(pid) ~= 0 then io.stderr:write('ipset creation failed: '..name) end diff --git a/awall/iptables.lua b/awall/iptables.lua index d8c3f10..b1303b8 100644 --- a/awall/iptables.lua +++ b/awall/iptables.lua @@ -61,8 +61,9 @@ function BaseIPTables:restore(test) if file then io.close(file) - local pid, stdin, stdout = lpc.run(params.cmd..'-restore', - unpack({test and '-t' or nil})) + local pid, stdin, stdout = lpc.run( + params.cmd..'-restore', table.unpack{test and '-t' or nil} + ) stdout:close() self:dumpfile(family, stdin) stdin:close() diff --git a/awall/modules/filter.lua b/awall/modules/filter.lua index 2c492ce..00ccb15 100644 --- a/awall/modules/filter.lua +++ b/awall/modules/filter.lua @@ -41,7 +41,7 @@ function FilterLimit:recentofrags(name) for _, family in ipairs{'inet', 'inet6'} do if type(self.mask[family].mode) ~= 'table' then return end local mask = '' - local attr, len = unpack(self.mask[family].mode) + local attr, len = table.unpack(self.mask[family].mode) if family == 'inet' then local octet diff --git a/awall/optfrag.lua b/awall/optfrag.lua index 72bbdbc..e24177f 100644 --- a/awall/optfrag.lua +++ b/awall/optfrag.lua @@ -16,7 +16,7 @@ function M.combinations(of1, ...) local of2 = arg[1] table.remove(arg, 1) - if not of2 then return M.combinations(of1, unpack(arg)) end + if not of2 then return M.combinations(of1, table.unpack(arg)) end local res = {} for i, x in ipairs(of1) do @@ -48,7 +48,7 @@ function M.combinations(of1, ...) end end - return M.combinations(res, unpack(arg)) + return M.combinations(res, table.unpack(arg)) end function M.location(of) return of.family..'/'..of.table..'/'..of.chain end diff --git a/awall/uerror.lua b/awall/uerror.lua index 3acf517..7282b6e 100644 --- a/awall/uerror.lua +++ b/awall/uerror.lua @@ -14,7 +14,7 @@ function M.raise(msg) error(prefix..msg) end function M.call(f, ...) local arg = {...} return xpcall( - function() f(unpack(arg)) end, + function() f(table.unpack(arg)) end, function(msg) local si, ei = msg:find(prefix, 1, true) if si then msg = 'awall: '..msg:sub(ei + 1, -1) end |