From 21f9432147b05601bc323edbe6b0a4c0daa97089 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Thu, 22 Nov 2007 16:14:52 +0000 Subject: OpenVPN Mainpage,Serverconfig,Connectedclients got more functionallity git-svn-id: svn://svn.alpinelinux.org/acf/openvpn/trunk@355 ab2d0c66-481e-0410-8bed-d214d4d58bed --- openvpn-controller.lua | 104 ++++--------------------------------------------- 1 file changed, 7 insertions(+), 97 deletions(-) (limited to 'openvpn-controller.lua') diff --git a/openvpn-controller.lua b/openvpn-controller.lua index a70782e..99a655b 100644 --- a/openvpn-controller.lua +++ b/openvpn-controller.lua @@ -22,103 +22,9 @@ mvc.on_load = function(self, parent) end -local function build_form ( model ) - local viewtable = {} - local configform = {} - local processform = {} - local messageform = {} --- local conflist = model.conflist() - local conflist = "hej" - local formwith = 60 - -- cf.self is a global variable specifiying this controller - -- local url = cf.self or "" - ---[[ table.insert ( messageform , { - type = "label" , - value = "Logfile info" , - text = "Tail file /var/log/messages
(Still working on this function)" - } ) -]]-- - table.insert ( processform , { - type = "label" , - value = "Process information", - text = "Information on if process is running." - } ) - table.insert ( processform , { - type = "formtext", - label = "openvpn process status", --- value = model.status("openvpn") - value = "hej" - } ) - - --- if table.maxn(conflist)==0 then - if 0==0 then - table.insert ( configform , { - type = "label" , - value = "List of valid configurations" , - text = "No valid configurations could be found in /etc/openvpn/
A valid config is called *.conf and has got at least the following parameters set: ca, cert, key, dev, proto (and for clients also parameter 'remote')" - } ) - else - -- Generate processlist - configform[1] = { - type = "label", - value = "List of valid configurations" , - text = "List is based on all valid configuration files named /etc/openvpn/*.conf" - } - for i=1,table.maxn(conflist) do - table.insert ( configform , { - type = "formtext" , --- label = conflist[i].confname , - label = "hej" , --- value = conflist[i].conftype or "" - value = "hej" or "" - } ) - end - end - - --- Define the main table used by the generic view renderer - viewtable[1] = { - type = "label", - value = "GENERAL" - } - viewtable[2] = { - type = "form", - method = "post", - action = "set", - -- Put the 'form' table in the view table - value = processform - } - viewtable[3] = { - type = "form", - method = "post", - action = "set", - --action = cf.self .. "/set", - -- Put the 'form' table in the view table - value = configform - } - viewtable[4] = { - type = "form", - method = "post", - action = "set", - --action = cf.self .. "/set", - -- Put the 'form' table in the view table - value = messageform - } - return viewtable -end - --- Public methods --- /hostname/get - - read = function (self) - --local me = {} - --me = cfe{name=conflistfilesaf, value="hej"} + -- FIXME: If return 1 rows go direct to that config-page return ( {conflistfiles = self.model:get_conflist(), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller, version = self.model:openvpn_version()} ) --- return ({conflistfiles = me}) --- return self.model:get() --- return build_form(self) end @@ -135,12 +41,16 @@ pem_info = function (self) end status_info = function (self) + local configname = self.clientdata.name or "" + -- FIXME: If return 0 rows, goto read + return ( {clientlist = self.model:clientlist(configname), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller} ) end unknown_config = function (self) 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 = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller} ) end - -create = update -- cgit v1.2.3