This patch adds a configuration menu for ocserv. As it is my first attempt in luci I'd appreciate any comments.
Signed-off-by: Nikos Mavrogiannopoulos <[email protected]> --- applications/luci-ocserv/Makefile | 4 ++ .../luci-ocserv/luasrc/controller/ocserv.lua | 26 +++++++++ .../luci-ocserv/luasrc/model/cbi/ocserv.lua | 64 ++++++++++++++++++++++ contrib/package/luci/Makefile | 3 + 4 files changed, 97 insertions(+) create mode 100644 applications/luci-ocserv/Makefile create mode 100644 applications/luci-ocserv/luasrc/controller/ocserv.lua create mode 100644 applications/luci-ocserv/luasrc/model/cbi/ocserv.lua diff --git a/applications/luci-ocserv/Makefile b/applications/luci-ocserv/Makefile new file mode 100644 index 0000000..74cd597 --- /dev/null +++ b/applications/luci-ocserv/Makefile @@ -0,0 +1,4 @@ +PO = ocserv + +include ../../build/config.mk +include ../../build/module.mk diff --git a/applications/luci-ocserv/luasrc/controller/ocserv.lua b/applications/luci-ocserv/luasrc/controller/ocserv.lua new file mode 100644 index 0000000..f95b437 --- /dev/null +++ b/applications/luci-ocserv/luasrc/controller/ocserv.lua @@ -0,0 +1,26 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2014 Nikos Mavrogiannopoulos <[email protected]> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- + +module("luci.controller.ocserv", package.seeall) + +function index() + if not nixio.fs.access("/etc/config/ocserv") then + return + end + + local page + + page = entry({"admin", "services", "ocserv"}, cbi("ocserv"), _("OpenConnect VPN")) + page.dependent = true +end diff --git a/applications/luci-ocserv/luasrc/model/cbi/ocserv.lua b/applications/luci-ocserv/luasrc/model/cbi/ocserv.lua new file mode 100644 index 0000000..b0715f2 --- /dev/null +++ b/applications/luci-ocserv/luasrc/model/cbi/ocserv.lua @@ -0,0 +1,64 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2014 Nikos Mavrogiannopoulos <[email protected]> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- + +m = Map("ocserv", translate("OpenConnect VPN")) + +s = m:section(TypedSection, "ocserv", "OpenConnect") +s.anonymous = true + +s:tab("general", translate("General Settings")) +s:tab("template", translate("Edit Template")) +s:tab("ca", translate("CA certificate")) + +s:taboption("general", Value, "port", translate("Port")) +s:taboption("general", Value, "max_clients", translate("Max clients")) +s:taboption("general", Value, "max_same", translate("Max same clients")) +s:taboption("general", Value, "dpd", translate("Dead peer detection time (secs)")) + +tmpl = s:taboption("template", Value, "_tmpl", + translate("Edit the template that is used for generating the ocserv configuration.")) + +tmpl.template = "cbi/tvalue" +tmpl.rows = 20 + +function tmpl.cfgvalue(self, section) + return nixio.fs.readfile("/etc/ocserv/ocserv.conf.template") +end + +function tmpl.write(self, section, value) + value = value:gsub("\r\n?", "\n") + nixio.fs.writefile("/etc/ocserv/ocserv.conf.template", value) +end + +ca = s:taboption("ca", Value, "_ca", + translate("View the CA certificate used by this server.")) + +ca.template = "cbi/tvalue" +ca.rows = 20 + +function ca.cfgvalue(self, section) + return nixio.fs.readfile("/etc/ocserv/ca.pem") +end + +s = m:section(TypedSection, "ocservusers", translate("Available users")) +s.anonymous = true +s.addremove = true +s.template = "cbi/tblsection" + +s:option(Value, "name", translate("Name")).rmempty = true +pwd = s:option(Value, "password", translate("Password")) + +pwd.password = true + +return m diff --git a/contrib/package/luci/Makefile b/contrib/package/luci/Makefile index 64abf69..4cc9d8b 100644 --- a/contrib/package/luci/Makefile +++ b/contrib/package/luci/Makefile @@ -403,6 +403,9 @@ $(eval $(call application,polipo,LuCI Support for the Polipo Proxy,\ $(eval $(call application,openvpn,LuCI Support for OpenVPN,\ +PACKAGE_luci-app-openvpn:openvpn @BROKEN)) +$(eval $(call application,ocserv,LuCI Support for OpenConnect VPN,\ + +PACKAGE_luci-app-ocserv:ocserv certtool)) + $(eval $(call application,p2pblock,LuCI Support for the Freifunk P2P-Block addon,\ luci-app-firewall +PACKAGE_luci-app-p2pblock:freifunk-p2pblock)) -- 1.9.2 _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
