summaryrefslogtreecommitdiffstats
path: root/iptables-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2013-10-20 00:06:27 +0000
committerTed Trask <ttrask01@yahoo.com>2013-10-20 00:06:27 +0000
commit010cf490868d980e4f2b4c13231a08ea3a41bcc4 (patch)
tree2388af31ee26865ad438362ed235e0d50cd0e5a7 /iptables-model.lua
parented4e254d9b4b16102feaab4225bb4099aa6b18fa (diff)
downloadacf-iptables-010cf490868d980e4f2b4c13231a08ea3a41bcc4.tar.bz2
acf-iptables-010cf490868d980e4f2b4c13231a08ea3a41bcc4.tar.xz
Remove all calls to 'module' in preparation for move to Lua 5.2
Use mymodule parameter for module definition. This was also helpful in revealing places where the code relied on the global environment.
Diffstat (limited to 'iptables-model.lua')
-rw-r--r--iptables-model.lua38
1 files changed, 20 insertions, 18 deletions
diff --git a/iptables-model.lua b/iptables-model.lua
index 464cbf3..4eff7ba 100644
--- a/iptables-model.lua
+++ b/iptables-model.lua
@@ -1,4 +1,4 @@
-module(..., package.seeall)
+local mymodule = {}
-- Load libraries
modelfunctions = require("modelfunctions")
@@ -194,11 +194,11 @@ end
-- ################################################################################
-- PUBLIC FUNCTIONS
-function getstatus()
+function mymodule.getstatus()
return modelfunctions.getstatus(servicename, packagename, "IPtables Status")
end
-function getstatusdetails()
+function mymodule.getstatusdetails()
getdetails()
local retval = {}
for i,tab in ipairs(tables) do
@@ -214,14 +214,14 @@ function getstatusdetails()
return cfe({ type="structure", value=retval, label="IPtables Status Details" })
end
-function getrules(tab)
+function mymodule.getrules(tab)
getdetails()
tab = tab or "filter"
return cfe({ type="structure", value=details[tab] or {}, label=string.gsub(tab, "^.", string.upper).." Rules" })
end
-function read_chain(tab, chain)
+function mymodule.read_chain(tab, chain)
local retval = {}
retval.table = cfe({ type="select", value=tab or "filter", label="Table", option=tables, seq=1 })
retval.chain = cfe({ value=chain or "", label="Chain", seq=2 })
@@ -245,7 +245,7 @@ function read_chain(tab, chain)
return cfe({ type="group", value=retval, label="Chain" })
end
-function update_chain(self, chain)
+function mymodule.update_chain(self, chain)
local success = true
getdetails()
if not details[chain.value.table.value] then
@@ -268,7 +268,7 @@ function update_chain(self, chain)
return chain
end
-function create_chain(self, chain)
+function mymodule.create_chain(self, chain)
local success = true
getdetails()
if not details[chain.value.table.value] then
@@ -293,14 +293,14 @@ function create_chain(self, chain)
return chain
end
-function get_delete_chain(self, clientdata)
+function mymodule.get_delete_chain(self, clientdata)
local retval = {}
retval.table = cfe({ type="select", value=clientdata.table or "filter", label="Table", option=tables })
retval.chain = cfe({ value=clientdata.chain or "", label="Chain" })
return cfe({ type="group", value=retval, label="Delete Chain" })
end
-function delete_chain(self, chain)
+function mymodule.delete_chain(self, chain)
local chn = find_chain(chain.value.table.value, chain.value.chain.value)
if not chn then
chain.errtxt = "Could not find chain"
@@ -316,7 +316,7 @@ function delete_chain(self, chain)
return chain
end
-function read_rule(tab, chain, pos)
+function mymodule.read_rule(tab, chain, pos)
local retval = {}
-- Identification
retval.table = cfe({ type="select", value=tab or "filter", label="Table", option=tables })
@@ -470,7 +470,7 @@ function read_rule(tab, chain, pos)
return cfe({ type="group", value=retval, label="Rule" })
end
-function create_rule(self, rule)
+function mymodule.create_rule(self, rule)
local success, rule = validate_rule(rule)
if success then
@@ -494,7 +494,7 @@ function create_rule(self, rule)
return rule
end
-function update_rule(self, rule)
+function mymodule.update_rule(self, rule)
local success, rule = validate_rule(rule)
if not tonumber(rule.value.position.value) then
rule.value.position.errtxt = "Must be a number"
@@ -514,7 +514,7 @@ function update_rule(self, rule)
return rule
end
-function get_delete_rule(self, clientdata)
+function mymodule.get_delete_rule(self, clientdata)
local retval = {}
-- Identification
retval.table = cfe({ type="select", value=clientdata.table or "filter", label="Table", option=tables })
@@ -523,7 +523,7 @@ function get_delete_rule(self, clientdata)
return cfe({ type="group", value=retval, label="Delete Rule" })
end
-function delete_rule(self, rule)
+function mymodule.delete_rule(self, rule)
if "" == rule.value.table.value or "" == rule.value.chain.value or "" == rule.value.position.value then
rule.errtxt = "Incomplete specification - must define table, chain, and position"
else
@@ -533,20 +533,22 @@ function delete_rule(self, rule)
return rule
end
-function readrulesfile()
+function mymodule.readrulesfile()
local rulesfile = format.get_ini_entry(fs.read_file(configfile) or "", "", "IPTABLES_SAVE")
return modelfunctions.getfiledetails(rulesfile)
end
-function updaterulesfile(self, filedetails)
+function mymodule.updaterulesfile(self, filedetails)
local rulesfile = format.get_ini_entry(fs.read_file(configfile) or "", "", "IPTABLES_SAVE")
return modelfunctions.setfiledetails(self, filedetails, {rulesfile})
end
-function get_startstop(self, clientdata)
+function mymodule.get_startstop(self, clientdata)
return modelfunctions.get_startstop(servicename)
end
-function startstop_service(self, startstop, action)
+function mymodule.startstop_service(self, startstop, action)
return modelfunctions.startstop_service(startstop, action)
end
+
+return mymodule