summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-openvpn/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'applications/luci-app-openvpn/luasrc')
-rw-r--r--applications/luci-app-openvpn/luasrc/controller/openvpn.lua3
-rw-r--r--applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua28
2 files changed, 17 insertions, 14 deletions
diff --git a/applications/luci-app-openvpn/luasrc/controller/openvpn.lua b/applications/luci-app-openvpn/luasrc/controller/openvpn.lua
index a30ac81a99..b41fff21dc 100644
--- a/applications/luci-app-openvpn/luasrc/controller/openvpn.lua
+++ b/applications/luci-app-openvpn/luasrc/controller/openvpn.lua
@@ -31,8 +31,7 @@ function ovpn_upload()
http.setfilehandler(
function(meta, chunk, eof)
- local data = util.trim(chunk:gsub("\r\n", "\n")) .. "\n"
- data = util.trim(data:gsub("[\128-\255]", ""))
+ local data = chunk:gsub("\r\n", "\n")
if not fp and meta and meta.name == "ovpn_file" then
fp = io.open(file, "w")
diff --git a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua
index 9d50601b1f..7197f45ef6 100644
--- a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua
+++ b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua
@@ -7,32 +7,36 @@ local uci = require("luci.model.uci").cursor()
local cfg_file = uci:get("openvpn", arg[1], "config")
local auth_file = cfg_file:match("(.+)%..+").. ".auth"
-local m = Map("openvpn")
+local function makeForm(id, title, desc)
+ local t = Template("openvpn/pageswitch")
+ t.mode = "file"
+ t.instance = arg[1]
-local p = m:section( SimpleSection )
-p.template = "openvpn/pageswitch"
-p.mode = "file"
-p.instance = arg[1]
+ local f = SimpleForm(id, title, desc)
+ f:append(t)
+
+ return f
+end
if not cfg_file or not fs.access(cfg_file) then
- local f = SimpleForm("error", nil, translatef("The OVPN config file (%s) could not be found, please check your configuration.", cfg_file or "n/a"))
+ local f = makeForm("error", nil, translatef("The OVPN config file (%s) could not be found, please check your configuration.", cfg_file or "n/a"))
f:append(Template("openvpn/ovpn_css"))
f.reset = false
f.submit = false
- return m, f
+ return f
end
if fs.stat(cfg_file).size >= 102400 then
- f = SimpleForm("error", nil,
+ local f = makeForm("error", nil,
translatef("The size of the OVPN config file (%s) is too large for online editing in LuCI (≥ 100 KB). ", cfg_file)
.. translate("Please edit this file directly in a terminal session."))
f:append(Template("openvpn/ovpn_css"))
f.reset = false
f.submit = false
- return m, f
+ return f
end
-f = SimpleForm("cfg", nil)
+f = makeForm("cfg", nil)
f:append(Template("openvpn/ovpn_css"))
f.submit = translate("Save")
f.reset = false
@@ -47,7 +51,7 @@ function file.cfgvalue()
end
function file.write(self, section, data1)
- return fs.writefile(cfg_file, "\n" .. util.trim(data1:gsub("\r\n", "\n")) .. "\n")
+ return fs.writefile(cfg_file, util.trim(data1:gsub("\r\n", "\n")) .. "\n")
end
function file.remove(self, section, value)
@@ -79,4 +83,4 @@ function s.handle(self, state, data2)
return true
end
-return m, f
+return f