summaryrefslogtreecommitdiffstats
path: root/openvpn-controller.lua
blob: 85deb28a9a57623e95ad7fb5ad687170dffac34c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module (..., package.seeall)

require("controllerfunctions")

default_action = "status"

status = function (self)
	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

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

deleteconfig = function(self)
	return self:redirect_to_referrer(self.model.delete_config(self.clientdata.name))
end

viewconfig = function(self)
	return self.model.get_config(self.clientdata.name)
end

statusinfo = function (self)
	return self.model.getclientinfo(self.clientdata.name)
end

logfile = function (self)
	return self.model.get_logfile(self.clientdata.name)
end

function startstop(self)
	local data = self.model.startstop_service(clientdata.action,clientdata.service)
	data.service = clientdata.service
	if (data) and (data.value) and (data.value.result) and (data.value.result.value) then
		redirect(self, "listconfigs")
	end
	if not (clientdata.service) then
		redirect(self, "listconfigs")
	end
	return data
end