Commit f2298561 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

substitute table.concat for util.join

parent 0ae7ea31
...@@ -8,7 +8,6 @@ Licensed under the terms of GPL2 ...@@ -8,7 +8,6 @@ Licensed under the terms of GPL2
module(..., package.seeall) module(..., package.seeall)
require 'awall.object' require 'awall.object'
require 'awall.util'
IPSet = awall.object.class(awall.object.Object) IPSet = awall.object.class(awall.object.Object)
...@@ -23,7 +22,7 @@ end ...@@ -23,7 +22,7 @@ end
function IPSet:dumpfile(name, ipsfile) function IPSet:dumpfile(name, ipsfile)
ipsfile:write('# ipset '..name..'\n') ipsfile:write('# ipset '..name..'\n')
ipsfile:write(awall.util.join(self:options(name), ' ')) ipsfile:write(table.concat(self:options(name), ' '))
ipsfile:write('\n') ipsfile:write('\n')
end end
......
...@@ -237,7 +237,7 @@ function Rule:servoptfrags() ...@@ -237,7 +237,7 @@ function Rule:servoptfrags()
if len == 1 then if len == 1 then
opts = opts..' --dport '..plist[1] opts = opts..' --dport '..plist[1]
elseif len > 1 then elseif len > 1 then
opts = opts..' -m multiport --dports '..util.join(plist, ',') opts = opts..' -m multiport --dports '..table.concat(plist, ',')
end end
table.insert(res, {opts=opts}) table.insert(res, {opts=opts})
...@@ -311,13 +311,13 @@ function Rule:trules() ...@@ -311,13 +311,13 @@ function Rule:trules()
end end
local setopts = '-m set --match-set '..ipset.name..' ' local setopts = '-m set --match-set '..ipset.name..' '
setopts = setopts..util.join(util.map(util.list(ipset.args), setopts = setopts..table.concat(util.map(util.list(ipset.args),
function(a) function(a)
if a == 'in' then return 'src' end if a == 'in' then return 'src' end
if a == 'out' then return 'dst' end if a == 'out' then return 'dst' end
self:error('Invalid set direction argument') self:error('Invalid set direction argument')
end), end),
',') ',')
table.insert(ipsetofrags, {family=setdef.family, opts=setopts}) table.insert(ipsetofrags, {family=setdef.family, opts=setopts})
end end
res = combinations(res, ipsetofrags) res = combinations(res, ipsetofrags)
......
...@@ -7,15 +7,6 @@ Licensed under the terms of GPL2 ...@@ -7,15 +7,6 @@ Licensed under the terms of GPL2
module(..., package.seeall) module(..., package.seeall)
function join(var, sep)
local res = ''
for i, s in listpairs(var) do
if i > 1 then res = res..sep end
res = res..s
end
return res
end
function list(var) function list(var)
if not var then return {} end if not var then return {} end
if type(var) ~= 'table' then return {var} end if type(var) ~= 'table' then return {var} end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment