Merge pull request #1481 from TDT-AG/luci-app-openvpn-fixes
luci-app-openvpn: several fixes
This commit is contained in:
commit
c181699bf7
1 changed files with 8 additions and 6 deletions
|
@ -56,7 +56,7 @@ function s.create(self, name)
|
||||||
luci.cbi.CREATE_PREFIX .. self.config .. "." ..
|
luci.cbi.CREATE_PREFIX .. self.config .. "." ..
|
||||||
self.sectiontype .. ".text"
|
self.sectiontype .. ".text"
|
||||||
)
|
)
|
||||||
if string.len(name)>3 and not name:match("[^a-zA-Z0-9_]") then
|
if #name > 3 and not name:match("[^a-zA-Z0-9_]") then
|
||||||
uci:section(
|
uci:section(
|
||||||
"openvpn", "openvpn", name,
|
"openvpn", "openvpn", name,
|
||||||
uci:get_all( "openvpn_recipes", recipe )
|
uci:get_all( "openvpn_recipes", recipe )
|
||||||
|
@ -67,9 +67,11 @@ function s.create(self, name)
|
||||||
uci:save("openvpn")
|
uci:save("openvpn")
|
||||||
|
|
||||||
luci.http.redirect( self.extedit:format(name) )
|
luci.http.redirect( self.extedit:format(name) )
|
||||||
else
|
elseif #name > 0 then
|
||||||
self.invalid_cts = true
|
self.invalid_cts = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,10 +105,7 @@ function updown.cfgvalue(self, section)
|
||||||
end
|
end
|
||||||
function updown.write(self, section, value)
|
function updown.write(self, section, value)
|
||||||
if self.option == "stop" then
|
if self.option == "stop" then
|
||||||
local pid = s.getPID(section)
|
luci.sys.call("/etc/init.d/openvpn stop %s" % section)
|
||||||
if pid ~= nil then
|
|
||||||
sys.process.signal(pid,15)
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
luci.sys.call("/etc/init.d/openvpn start %s" % section)
|
luci.sys.call("/etc/init.d/openvpn start %s" % section)
|
||||||
end
|
end
|
||||||
|
@ -126,5 +125,8 @@ function proto.cfgvalue(self, section)
|
||||||
return val or "udp"
|
return val or "udp"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function m.on_after_commit(self,map)
|
||||||
|
require("luci.sys").call('/etc/init.d/openvpn reload')
|
||||||
|
end
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
Loading…
Reference in a new issue