diff options
author | Ted Trask <ttrask01@yahoo.com> | 2013-10-18 20:02:30 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2013-10-18 20:02:30 +0000 |
commit | b564ccb75dc3abda19acbb2b94e9db45b043fc9e (patch) | |
tree | a265dbb54b6fe935fb7d5fd6d610deb649ec2fe1 /awall-model.lua | |
parent | 5dead1840ddd8e2053d4f13adf41fbbc74b9bbda (diff) | |
download | acf-awall-b564ccb75dc3abda19acbb2b94e9db45b043fc9e.tar.bz2 acf-awall-b564ccb75dc3abda19acbb2b94e9db45b043fc9e.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 'awall-model.lua')
-rw-r--r-- | awall-model.lua | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/awall-model.lua b/awall-model.lua index c8c6dc3..e242d40 100644 --- a/awall-model.lua +++ b/awall-model.lua @@ -1,4 +1,4 @@ -module(..., package.seeall) +local mymodule = {} -- Load libraries posix = require("posix") @@ -68,16 +68,16 @@ end -- ################################################################################ -- PUBLIC FUNCTIONS -function getstatus() +function mymodule.getstatus() return modelfunctions.getstatus(nil, packagename, "AWall Status") end -function get_startstop(self, clientdata) +function mymodule.get_startstop(self, clientdata) local actions = {"Verify", "Translate", "Activate"} return cfe({ type="group", label="Management", value={}, option=actions }) end -function startstop_service(self, startstop, action) +function mymodule.startstop_service(self, startstop, action) if not action then startstop.errtxt = "Invalid Action" else @@ -99,7 +99,7 @@ function startstop_service(self, startstop, action) return startstop end -function list_policies() +function mymodule.list_policies() -- core-router disabled BSN core router local policies = {} local reversepolicies = {} @@ -147,14 +147,14 @@ function list_policies() return cfe({ type="list", value=policies, label="Policies", errtxt=errtxt }) end -function get_newpolicy() +function mymodule.get_newpolicy() local newpolicy = {} newpolicy.name = cfe({ label="Name", seq=1 }) newpolicy.optional = cfe({ type="boolean", label="Optional", seq=2 }) return cfe({ type="group", value=newpolicy, label="New Policy" }) end -function create_policy(self, newpolicy) +function mymodule.create_policy(self, newpolicy) local success = true local name = newpolicy.value.name.value @@ -162,7 +162,7 @@ function create_policy(self, newpolicy) newpolicy.value.name.errtxt = "Invalid name" success = false else - local policies = list_policies() + local policies = mymodule.list_policies() for i,pol in ipairs(policies.value) do if pol.name == newpolicy.value.name.value then newpolicy.value.name.errtxt = "Name already exists" @@ -195,13 +195,13 @@ function create_policy(self, newpolicy) return newpolicy end -function get_delete_policy(self, clientdata) +function mymodule.get_delete_policy(self, clientdata) retval = {} retval.filename = cfe({ value=clientdata.filename or "", label="File Name" }) return cfe({ type="group", value=retval, label="Delete Policy File" }) end -function delete_policy(self, delpolicy) +function mymodule.delete_policy(self, delpolicy) if validateeditablefile(delpolicy.value.filename.value) then os.remove(delpolicy.value.filename.value) else @@ -212,7 +212,7 @@ function delete_policy(self, delpolicy) return delpolicy end -function read_policyfile(self, clientdata) +function mymodule.read_policyfile(self, clientdata) -- Can read from all 4 locations return modelfunctions.getfiledetails(clientdata.filename, function(filename) local dir = posix.dirname(filename or "").."/" @@ -224,27 +224,29 @@ function read_policyfile(self, clientdata) end) end -function get_policyfile(self, clientdata) +function mymodule.get_policyfile(self, clientdata) -- Can only get (for editing) from /etc/ locations return modelfunctions.getfiledetails(clientdata.filename, validateeditablefile) end -function update_policyfile(self, filedetails) +function mymodule.update_policyfile(self, filedetails) return modelfunctions.setfiledetails(self, filedetails, validateeditablefile, validatefiledetails) end -function get_enablepolicy(self, clientdata) +function mymodule.get_enablepolicy(self, clientdata) local policy = {} policy.name = cfe({ value=clientdata.name or "", label="Name", seq=1 }) return cfe({ type="group", value=policy, label="Policy" }) end -function enable_policy(self, enable) +function mymodule.enable_policy(self, enable) enable.descr, enable.errtxt = modelfunctions.run_executable({"awall", "enable", enable.value.name.value}, true) return enable end -function disable_policy(self, disable) +function mymodule.disable_policy(self, disable) disable.descr, disable.errtxt = modelfunctions.run_executable({"awall", "disable", disable.value.name.value}, true) return disable end + +return mymodule |