summaryrefslogtreecommitdiffstats
path: root/openssh-controller.lua
diff options
context:
space:
mode:
Diffstat (limited to 'openssh-controller.lua')
-rw-r--r--openssh-controller.lua74
1 files changed, 1 insertions, 73 deletions
diff --git a/openssh-controller.lua b/openssh-controller.lua
index 30800f5..6a76512 100644
--- a/openssh-controller.lua
+++ b/openssh-controller.lua
@@ -3,8 +3,6 @@ module(..., package.seeall)
-- Load libraries
require("controllerfunctions")
-local checkboxes = { "PermitRootLogin", "PasswordAuthentication", "UseDNS" }
-
default_action = "status"
function status(self)
@@ -12,75 +10,7 @@ function status(self)
end
function config(self)
- local output = {}
- local errtxt = {}
- local successfuledit
- if (self.clientdata.cmdsave) then
- local fields = { "Port", "ListenAddress", "PermitRootLogin", "PasswordAuthentication", "UseDNS", }
- local newconfig = {}
- for _ , v in pairs(fields) do
- newconfig[v] = self.clientdata[v] or ""
- end
- successfuledit, errtxt = self.model.write_config(newconfig)
- end
-
- local config = self.model.read_config() or {}
- output.cmdsave = cfe({
- name="cmdsave",
- label="Save above changes",
- value="Apply",
- type="submit",
- })
-
- output.Port = cfe({
- name="Port",
- label="Port",
- value=config.Port,
- })
- output.ListenAddress = cfe({
- name="ListenAddress",
- label="Listen address",
- value=config.ListenAddress,
- })
- output.PermitRootLogin = cfe({
- name="PermitRootLogin",
- label="Permit Root Login",
- })
-
- output.PasswordAuthentication = cfe({
- name="PasswordAuthentication",
- label="Password Authentication",
- })
-
- output.UseDNS = cfe({
- name="UseDNS",
- label="Use DNS",
- })
-
- -- Display checkboxes checked/unchecked
- for k,v in pairs(checkboxes) do
- output[v]['value']="yes"
- output[v]['type']="checkbox"
- if (config[v]) and (string.lower(tostring(config[v] or "")) == "yes") then
- output[v]['checked']="yes"
- end
- end
-
- -- Display results of previous save action
- if (self.clientdata.cmdsave) and not (successfuledit) then
- for k,v in pairs(self.clientdata) do
- if (output) and (output[k]) and (k) then
- output[k]['value'] = self.clientdata[k]
- output[k]['errtxt'] = errtxt[k]
- end
- end
-
- output.cmdsave.errtxt = "Save action was canceled because there was invalid input."
- elseif (self.clientdata.cmdsave) and (successfuledit) then
- output.cmdsave.descr = "* Configuration was succesfully saved"
- end
-
- return output
+ return controllerfunctions.handle_form(self, self.model.read_config, self.model.update_config, self.clientdata, "Save", "Edit Config", "Configuration Saved")
end
function startstop(self)
@@ -94,5 +24,3 @@ end
function connectedpeers(self)
return self.model.list_conn_peers()
end
-function welcome(self)
-end