diff options
| author | Ted Trask <ttrask01@yahoo.com> | 2008-11-25 19:27:55 +0000 | 
|---|---|---|
| committer | Ted Trask <ttrask01@yahoo.com> | 2008-11-25 19:27:55 +0000 | 
| commit | 3459e6bf19a13f35e419b0adabf8c3456a0a5025 (patch) | |
| tree | 9330301f44a88ee2f3cb8b5d0271204294aa99c6 /openvpn-controller.lua | |
| parent | 99b9d1c5e938d818ca3e78a1f37d6a80da4b88f1 (diff) | |
| download | acf-openvpn-3459e6bf19a13f35e419b0adabf8c3456a0a5025.tar.bz2 acf-openvpn-3459e6bf19a13f35e419b0adabf8c3456a0a5025.tar.xz | |
Rewrite of openvpn to use cfes and new style.  Added ability to edit/create/delete configs.  Combined three view functions into one.  Added a new status and moved old status to listconfigs.  Still needs work, including ability to start/stop/restart.v0.3.0
git-svn-id: svn://svn.alpinelinux.org/acf/openvpn/trunk@1611 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'openvpn-controller.lua')
| -rw-r--r-- | openvpn-controller.lua | 62 | 
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 | 
