summaryrefslogtreecommitdiffstats
path: root/awall-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'awall-model.lua')
-rw-r--r--awall-model.lua34
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