summaryrefslogtreecommitdiffstats
path: root/openvpn-controller.lua
diff options
context:
space:
mode:
Diffstat (limited to 'openvpn-controller.lua')
-rw-r--r--openvpn-controller.lua62
1 files changed, 18 insertions, 44 deletions
diff --git a/openvpn-controller.lua b/openvpn-controller.lua
index 54a28e2..047e7df 100644
--- a/openvpn-controller.lua
+++ b/openvpn-controller.lua
@@ -1,63 +1,37 @@
--- the hostname controller
-
module (..., package.seeall)
+require("controllerfunctions")
+
default_action = "status"
status = function (self)
- -- FIXME: If return 1 rows go direct to that config-page
- return ( {conflistfiles = self.model:get_conflist(), url = self.conf.script .. self.conf.prefix .. self.conf.controller, version = self.model:openvpn_version()} )
+ return self.model.getstatus()
+end
+
+listconfigs = function (self)
+ return self.model.get_conflist()
end
+editconfig = function (self)
+ return controllerfunctions.handle_form(self, function() return self.model.get_filecontent(self.clientdata.name) end, self.model.update_filecontent, self.clientdata, "Save", "Edit Config File", "Config File Saved")
+end
-serverconfig = function (self)
- local configname = self.clientdata.name or ""
- return ( {config = self.model:get_config(configname), url = self.conf.script .. self.conf.prefix .. self.conf.controller} )
+createconfig = function ( self )
+ return controllerfunctions.handle_form(self, self.model.create_new_config, self.model.create_config, self.clientdata, "Create", "Create new config", "New config Created")
end
-clientconfig = function (self)
- local configname = self.clientdata.name or ""
- return ( {config = self.model:get_config(configname), url = self.conf.script .. self.conf.prefix .. self.conf.controller} )
+deleteconfig = function(self)
+ return self:redirect_to_referrer(self.model.delete_config(self.clientdata.name))
end
-peminfo = function (self)
+viewconfig = function(self)
+ return self.model.get_config(self.clientdata.name)
end
statusinfo = function (self)
- local configname = self.clientdata.name or ""
- return ( {clientlist = self.model:clientlist(configname), url = self.conf.script .. self.conf.prefix .. self.conf.controller} )
-end
-
-unknownconfig = function (self)
- local filename = self.clientdata.name or ""
- local filecontent = self.clientdata.modifications or ""
-
----[[
- if ( filecontent ~= "") then
- local me = ( {configfilecontent = self.model:update_filecontent(filename,filecontent), url = self.conf.script .. self.conf.prefix .. self.conf.controller } )
- if ( me.configfilecontent == nil ) then
- redirect(self)
- else
- return me
- end
- else
----[=[
- local me = ( {configfilecontent = self.model:get_filecontent(filename), url = self.conf.script .. self.conf.prefix .. self.conf.controller } )
- if ( me.configfilecontent == nil ) then
- redirect(self)
- else
- return me
- end
---]=]
--- return ( {configfilecontent = self.model:get_filecontent(filename), url = self.conf.script .. self.conf.prefix .. self.conf.controller} )
-
- end
---]]
-
+ return self.model.getclientinfo(self.clientdata.name)
end
logfile = function (self)
- local configname = self.clientdata.name or ""
- -- FIXME: If return 0 rows, goto read
- return ( {logfilecontent = self.model:get_logfile(configname), url = self.conf.script .. self.conf.prefix .. self.conf.controller } )
+ return self.model.get_logfile(self.clientdata.name)
end