summaryrefslogtreecommitdiffstats
path: root/openvpn-controller.lua
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2007-11-17 11:31:10 +0000
committerMika Havela <mika.havela@gmail.com>2007-11-17 11:31:10 +0000
commit31ff3ba51554722d2afbdc8153801c5496ff02b8 (patch)
treef194089397d9acaa9e98df4181c73247a083cd41 /openvpn-controller.lua
parentd1f3722325d29c220401cba825915238374763b0 (diff)
downloadacf-openvpn-31ff3ba51554722d2afbdc8153801c5496ff02b8.tar.bz2
acf-openvpn-31ff3ba51554722d2afbdc8153801c5496ff02b8.tar.xz
OpenVPN initial thoughts on functionallity. Almost no functionallity at this point.
git-svn-id: svn://svn.alpinelinux.org/acf/openvpn/trunk@332 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'openvpn-controller.lua')
-rw-r--r--openvpn-controller.lua128
1 files changed, 128 insertions, 0 deletions
diff --git a/openvpn-controller.lua b/openvpn-controller.lua
new file mode 100644
index 0000000..b088758
--- /dev/null
+++ b/openvpn-controller.lua
@@ -0,0 +1,128 @@
+-- the hostname controller
+
+module (..., package.seeall)
+
+-- Cause an http redirect to our "read" action
+-- We use the self.conf table because it already has prefix,controller,etc
+-- The redir code is defined in the application error handler (acf-controller)
+local list_redir = function (self)
+ self.conf.action = "read"
+ self.conf.type = "redir"
+ error (self.conf)
+end
+
+mvc={}
+mvc.on_load = function(self, parent)
+ if (self.worker[self.conf.action] == nil ) or ( self.conf.action == "init" ) then
+ self.worker[self.conf.action] = list_redir(self)
+ end
+
+-- logit ("hostname.mvc.on_load activated")
+
+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 <i><b>/var/log/messages</b></i><BR><font style='color:f00'>(Still working on this function)</font>"
+ } )
+]]--
+ 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 <i><b>/etc/openvpn/</b></i><br>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 <i><b>/etc/openvpn/*.conf</b></i>"
+ }
+ 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
+-- <prefix>/hostname/get
+
+
+read = function (self)
+ local me = {}
+ me = cfe{name=conflistfilesaf, value="hej"}
+ return ( {conflistfiles = self.model:list_conffiles()} )
+-- return ({conflistfiles = me})
+-- return self.model:get()
+-- return build_form(self)
+end
+
+
+server_config = function (self)
+end
+
+create = update