diff options
author | Vladimir Ulrich <admin@evl.su> | 2014-07-14 06:03:32 +0400 |
---|---|---|
committer | Vladimir Ulrich <admin@evl.su> | 2014-10-10 19:59:35 +0400 |
commit | 01541f8c7f0e9b2fdbc42f47b788b3038c29d937 (patch) | |
tree | 10b2942463dc34fe57a53286cb864369b8efed54 /applications/luci-openvpn/luasrc/model/cbi | |
parent | bb388f0873b5f9b88c45af5c7d35e9eb9f4ac8ac (diff) |
Updated openvpn app to work with current openvpn package
Signed-off-by: Vladimir Ulrich <admin@evl.su>
Diffstat (limited to 'applications/luci-openvpn/luasrc/model/cbi')
3 files changed, 19 insertions, 8 deletions
diff --git a/applications/luci-openvpn/luasrc/model/cbi/openvpn-advanced.lua b/applications/luci-openvpn/luasrc/model/cbi/openvpn-advanced.lua index eee08eb81..f47af6d2f 100644 --- a/applications/luci-openvpn/luasrc/model/cbi/openvpn-advanced.lua +++ b/applications/luci-openvpn/luasrc/model/cbi/openvpn-advanced.lua @@ -88,7 +88,7 @@ local knownParams = { { ListValue, "mtu_disc", { "yes", "maybe", "no" }, translate("Enable Path MTU discovery") }, { Flag, "mtu_test", 0, translate("Empirically measure MTU") }, - { Flag, "comp_lzo", 0, translate("Use fast LZO compression") }, + { ListValue, "comp_lzo", { "yes", "no", "adaptive" }, translate("Use fast LZO compression") }, { Flag, "comp_noadapt", 0, translate("Don't use adaptive lzo compression"), { comp_lzo=1 } }, { Value, "link_mtu", 1500, translate("Set TCP/UDP MTU") }, { Value, "tun_mtu", 1500, translate("Set tun/tap device MTU") }, diff --git a/applications/luci-openvpn/luasrc/model/cbi/openvpn-basic.lua b/applications/luci-openvpn/luasrc/model/cbi/openvpn-basic.lua index dc1114b6e..92f7cb569 100644 --- a/applications/luci-openvpn/luasrc/model/cbi/openvpn-basic.lua +++ b/applications/luci-openvpn/luasrc/model/cbi/openvpn-basic.lua @@ -32,7 +32,7 @@ local basicParams = { { Value,"server_bridge","192.168.1.1 255.255.255.0 192.168.1.128 192.168.1.254", translate("Configure server bridge") }, { Flag,"nobind",0, translate("Do not bind to local address and port") }, - { Flag,"comp_lzo",0, translate("Use fast LZO compression") }, + { ListValue,"comp_lzo",{"yes","no","adaptive"}, translate("Use fast LZO compression") }, { Value,"keepalive","10 60", translate("Helper directive to simplify the expression of --ping and --ping-restart in server mode configurations") }, { ListValue,"proto",{ "udp", "tcp" }, translate("Use protocol") }, diff --git a/applications/luci-openvpn/luasrc/model/cbi/openvpn.lua b/applications/luci-openvpn/luasrc/model/cbi/openvpn.lua index 0fa60fd02..2f865e002 100644 --- a/applications/luci-openvpn/luasrc/model/cbi/openvpn.lua +++ b/applications/luci-openvpn/luasrc/model/cbi/openvpn.lua @@ -15,6 +15,8 @@ $Id$ local fs = require "nixio.fs" local sys = require "luci.sys" local uci = require "luci.model.uci".cursor() +local testfullps = luci.sys.exec("ps --help 2>&1 | grep BusyBox") --check which ps do we have +local psstring = (string.len(testfullps)>0) and "ps w" or "ps axfw" --set command we use to get pid local m = Map("openvpn", translate("OpenVPN")) local s = m:section( TypedSection, "openvpn", translate("OpenVPN instances"), translate("Below is a list of configured OpenVPN instances and their current state") ) @@ -52,8 +54,11 @@ function s.create(self, name) luci.cbi.CREATE_PREFIX .. self.config .. "." .. self.sectiontype .. ".select" ) - - if name and not name:match("[^a-zA-Z0-9_]") then + name = luci.http.formvalue( + luci.cbi.CREATE_PREFIX .. self.config .. "." .. + self.sectiontype .. ".text" + ) + if string.len(name)>3 and not name:match("[^a-zA-Z0-9_]") then uci:section( "openvpn", "openvpn", name, uci:get_all( "openvpn_recipes", recipe ) @@ -74,7 +79,7 @@ s:option( Flag, "enabled", translate("Enabled") ) local active = s:option( DummyValue, "_active", translate("Started") ) function active.cfgvalue(self, section) - local pid = fs.readfile("/var/run/openvpn-%s.pid" % section) + local pid = sys.exec("%s | grep %s | grep openvpn | grep -v grep | awk '{print $1}'" % { psstring,section} ) if pid and #pid > 0 and tonumber(pid) ~= nil then return (sys.process.signal(pid, 0)) and translatef("yes (%i)", pid) @@ -85,8 +90,11 @@ end local updown = s:option( Button, "_updown", translate("Start/Stop") ) updown._state = false +updown.redirect = luci.dispatcher.build_url( + "admin", "services", "openvpn" +) function updown.cbid(self, section) - local pid = fs.readfile("/var/run/openvpn-%s.pid" % section) + local pid = sys.exec("%s | grep %s | grep openvpn | grep -v grep | awk '{print $1}'" % { psstring,section} ) self._state = pid and #pid > 0 and sys.process.signal(pid, 0) self.option = self._state and "stop" or "start" return AbstractValue.cbid(self, section) @@ -97,12 +105,15 @@ function updown.cfgvalue(self, section) end function updown.write(self, section, value) if self.option == "stop" then - luci.sys.call("/etc/init.d/openvpn down %s" % section) + local pid = sys.exec("%s | grep %s | grep openvpn | grep -v grep | awk '{print $1}'" % { psstring,section} ) + sys.process.signal(pid,15) else - luci.sys.call("/etc/init.d/openvpn up %s" % section) + luci.sys.call("/etc/init.d/openvpn start %s" % section) end + luci.http.redirect( self.redirect ) end + local port = s:option( DummyValue, "port", translate("Port") ) function port.cfgvalue(self, section) local val = AbstractValue.cfgvalue(self, section) |