summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-openvpn/luasrc/model/cbi/openvpn.lua
diff options
context:
space:
mode:
authorDirk Brenken <dev@brenken.org>2020-04-18 08:57:36 +0200
committerDirk Brenken <dev@brenken.org>2020-04-18 08:57:36 +0200
commitd4fef2cc647b2381c195f2e417a883b1c0adfb15 (patch)
tree20cc7eb7d988f7273933a4131ea23dcca6fea634 /applications/luci-app-openvpn/luasrc/model/cbi/openvpn.lua
parent1dbcc737fe9e0b5d3ae81a01a21eb122c19e8183 (diff)
luci-app-openvpn: relax port/protocol parser
* relax port/protocol parser for ovpn files * limit protocol to 'udp' or 'tcp' Signed-off-by: Dirk Brenken <dev@brenken.org>
Diffstat (limited to 'applications/luci-app-openvpn/luasrc/model/cbi/openvpn.lua')
-rw-r--r--applications/luci-app-openvpn/luasrc/model/cbi/openvpn.lua10
1 files changed, 2 insertions, 8 deletions
diff --git a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn.lua b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn.lua
index 9164f7f600..74d27f6350 100644
--- a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn.lua
+++ b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn.lua
@@ -144,10 +144,7 @@ function port.cfgvalue(self, section)
if not val then
local file_cfg = self.map:get(section, "config")
if file_cfg and fs.access(file_cfg) then
- val = sys.exec("awk '{if(match(tolower($1),/^port$/)&&match($2,/[0-9]+/)){cnt++;printf $2;exit}}END{if(cnt==0)printf \"-\"}' " ..file_cfg)
- if val == "-" then
- val = sys.exec("awk '{if(match(tolower($1),/^remote$/)&&match($3,/[0-9]+/)){cnt++;printf $3;exit}}END{if(cnt==0)printf \"-\"}' " ..file_cfg)
- end
+ val = sys.exec("awk '{if(match(tolower($1),/^port$|^remote$/)&&match($2,/[0-9]+/)){cnt++;printf $2;exit}}END{if(cnt==0)printf \"-\"}' " ..file_cfg)
end
end
return val or "-"
@@ -159,10 +156,7 @@ function proto.cfgvalue(self, section)
if not val then
local file_cfg = self.map:get(section, "config")
if file_cfg and fs.access(file_cfg) then
- val = sys.exec("awk '{if(match(tolower($1),/^proto$/)&&match(tolower($2),/^udp[46]*$|^tcp[46]*-server$|^tcp[46]*-client$/)){cnt++;printf tolower($2);exit}}END{if(cnt==0)printf \"-\"}' " ..file_cfg)
- if val == "-" then
- val = sys.exec("awk '{if(match(tolower($1),/^remote$/)&&match(tolower($4),/^udp[46]*$|^tcp[46]*-server$|^tcp[46]*-client$/)){cnt++;printf $4;exit}}END{if(cnt==0)printf \"-\"}' " ..file_cfg)
- end
+ val = sys.exec("awk '{if(match(tolower($1),/^proto$|^remote$/)&&match(tolower($2),/^udp[46]*$|^tcp[a-z46-]*$/)){cnt++;print tolower(substr($2,1,3));exit}}END{if(cnt==0)printf \"-\"}' " ..file_cfg)
end
end
return val or "-"