--[[Ipset file dumper for Alpine WallCopyright (C) 2012 Kaarle RitvanenLicensed under the terms of GPL2]]--module(...,package.seeall)localfunctioncommands()localconfig=awall.configlocalres={}ifconfig.ipsetthenforname,paramsinpairs(config.ipset)doifnotparams.typethenerror('Type not defined for set '..name)endlocalline='create '..name..' '..params.typeifparams.familythenline=line..' family '..params.familyendtable.insert(res,line..'\n')endendreturnresendfunctioncreate()fori,lineinipairs(commands())dolocalpid,stdin=lpc.run('ipset','-!','restore')stdin:write(line)stdin:close()iflpc.wait(pid)~=0thenio.stderr:write('ipset command failed: '..line)endendendfunctiondump(ipsfile)localfile=io.output(ipsfile)fori,lineinipairs(commands())dofile:write(line)endfile:close()end