diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2014-10-11 12:07:35 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2014-10-11 12:07:35 +0200 |
commit | 52326c28efacd6b6eadaf7bab72b8ec633192a00 (patch) | |
tree | a9e4f6d6530d5c8d810bd9c07652e9413040a619 | |
parent | 7ee4e9c78acccd7bdb6ec33a464bc67459068641 (diff) | |
parent | 90c0e4dad4a4d02ea7207a3ac9c5d76001ab069d (diff) |
Merge pull request #220 from Wedmer/openvpnfix_dtfix_watchcatfix
applications/luci-openvpn: fixes for current openWRT openvpn packages.
8 files changed, 30 insertions, 23 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) diff --git a/applications/luci-openvpn/luasrc/view/openvpn/cbi-select-input-add.htm b/applications/luci-openvpn/luasrc/view/openvpn/cbi-select-input-add.htm index cedac51e4..0166de778 100644 --- a/applications/luci-openvpn/luasrc/view/openvpn/cbi-select-input-add.htm +++ b/applications/luci-openvpn/luasrc/view/openvpn/cbi-select-input-add.htm @@ -1,6 +1,6 @@ <div class="cbi-section-create"> <% if self.invalid_cts then -%><div class="cbi-section-error"><% end %> - <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" /> + <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.text" /> <select class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.select"> <%- for k, v in luci.util.kspairs(self.add_select_options) do %> <option value="<%=k%>"><%=luci.util.pcdata(v)%></option> diff --git a/applications/luci-openvpn/root/etc/config/openvpn_recipes b/applications/luci-openvpn/root/etc/config/openvpn_recipes index 50e328af5..1b394dffb 100644 --- a/applications/luci-openvpn/root/etc/config/openvpn_recipes +++ b/applications/luci-openvpn/root/etc/config/openvpn_recipes @@ -8,10 +8,9 @@ config openvpn_recipe server_tun_ptp option ifconfig "10.0.0.1 10.0.0.2" option secret "shared-secret.key" option keepalive "10 60" - option comp_lzo "1" + option comp_lzo "yes" option verb "3" option mssfix "1420" - option management "127.0.0.1 31194" # # Routed point-to-point client @@ -24,9 +23,8 @@ config openvpn_recipe client_tun_ptp option ifconfig "10.0.0.2 10.0.0.1" option secret "shared-secret.key" option nobind "1" - option comp_lzo "1" + option comp_lzo "yes" option verb "3" - option management "127.0.0.1 31194" # # Routed multi-client server @@ -41,10 +39,9 @@ config openvpn_recipe server_tun option key "server.key" option dh "dh1024.pem" option keepalive "10 60" - option comp_lzo "1" + option comp_lzo "yes" option verb "3" option mssfix "1420" - option management "127.0.0.1 31194" # # Routed client @@ -57,14 +54,13 @@ config openvpn_recipe client_tun list remote "vpnserver.example.org" option pkcs12 "my_client.p12" option remote_cert_tls "server" - option comp_lzo "1" + option comp_lzo "yes" option nobind "1" option persist_key "1" option persist_tun "1" option verb "3" option reneg_sec "0" option float "1" - option management "127.0.0.1 31194" # # Multi-client ethernet bridge server @@ -79,10 +75,9 @@ config openvpn_recipe server_tap_bridge option key "server.key" option dh "dh1024.pem" option keepalive "10 60" - option comp_lzo "1" + option comp_lzo "yes" option verb "3" option mssfix "1420" - option management "127.0.0.1 31194" # # Ethernet bridge client @@ -98,10 +93,10 @@ config openvpn_recipe client_tap_bridge option key "my_client.key" option dh "dh1024.pem" option remote_cert_tls "server" - option comp_lzo "1" + option comp_lzo "yes" option nobind "1" option persist_key "1" option verb "3" option reneg_sec "0" option float "1" - option management "127.0.0.1 31194" + diff --git a/applications/luci-watchcat/luasrc/model/cbi/watchcat/watchcat.lua b/applications/luci-watchcat/luasrc/model/cbi/watchcat/watchcat.lua index bcaf43855..fd7038c87 100644 --- a/applications/luci-watchcat/luasrc/model/cbi/watchcat/watchcat.lua +++ b/applications/luci-watchcat/luasrc/model/cbi/watchcat/watchcat.lua @@ -46,7 +46,7 @@ period = s:option(Value, "period", "suffix 'm' for minutes, 'h' for hours or 'd' " .. "for days")) -pinghost = s:option(Value, "pinghost", +pinghost = s:option(Value, "pinghosts", translate("Ping host"), translate("Host address to ping")) pinghost.datatype = "host" diff --git a/contrib/package/luci-addons/Makefile b/contrib/package/luci-addons/Makefile index 0838ed07e..ac31b639e 100644 --- a/contrib/package/luci-addons/Makefile +++ b/contrib/package/luci-addons/Makefile @@ -181,7 +181,7 @@ $(eval $(call application,ushare,uShare - UPnP A/V & DLNA Media Server,ushare)) $(eval $(call application,hd-idle,Hard Disk Idle Spin-Down module,hd-idle)) $(eval $(call application,tinyproxy,Tinyproxy - HTTP(S)-Proxy configuration,tinyproxy)) $(eval $(call application,polipo,LuCI Support for the Polipo Proxy,polipo)) -$(eval $(call application,openvpn,LuCI Support for OpenVPN,openvpn @BROKEN)) +$(eval $(call application,openvpn,LuCI Support for OpenVPN,openvpn)) $(eval $(call application,p2pblock,LuCI Support for the Freifunk P2P-Block addon,luci-app-firewall freifunk-p2pblock)) $(eval $(call application,multiwan,LuCI Support for the OpenWrt MultiWAN agent,luci-app-firewall multiwan)) $(eval $(call application,wol,LuCI Support for Wake-on-LAN,etherwake)) diff --git a/modules/base/luasrc/sys.lua b/modules/base/luasrc/sys.lua index df6280dda..3a04f6bad 100644 --- a/modules/base/luasrc/sys.lua +++ b/modules/base/luasrc/sys.lua @@ -186,6 +186,7 @@ function sysinfo() cpuinfo:match("model name\t+: ([^\n]+)") local model = + fs.readfile("/proc/device-tree/model") or luci.util.pcdata(fs.readfile("/tmp/sysinfo/model")) or cpuinfo:match("machine\t+: ([^\n]+)") or cpuinfo:match("Hardware\t+: ([^\n]+)") or |