summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-wireguard
diff options
context:
space:
mode:
authorDirk Brenken <dev@brenken.org>2018-10-12 15:30:18 +0200
committerGitHub <noreply@github.com>2018-10-12 15:30:18 +0200
commit57bdcbebda9a8e53de8c75ca401250226663b438 (patch)
tree8a90908bb9c1ed727cd5ca7e972b45dd2b6b421c /applications/luci-app-wireguard
parentc9e3e73c8c7a64f37c0dc07d4c6a954e878edf93 (diff)
parent38541eeafa5d270219d6d7540c786a806d752be3 (diff)
Merge pull request #2204 from dibdot/wg-qrfix
luci-app-wireguard: clean up QR Code generation
Diffstat (limited to 'applications/luci-app-wireguard')
-rw-r--r--applications/luci-app-wireguard/luasrc/view/wireguard.htm13
1 files changed, 10 insertions, 3 deletions
diff --git a/applications/luci-app-wireguard/luasrc/view/wireguard.htm b/applications/luci-app-wireguard/luasrc/view/wireguard.htm
index 444533275..6ec9ddb36 100644
--- a/applications/luci-app-wireguard/luasrc/view/wireguard.htm
+++ b/applications/luci-app-wireguard/luasrc/view/wireguard.htm
@@ -9,6 +9,13 @@
local last_device = ""
local enc = { }
+ local function wg_clean(value)
+ if value and value == "(none)" then
+ value = ""
+ end
+ return value
+ end
+
local wg_dump = io.popen("wg show all dump")
if wg_dump then
local line
@@ -33,7 +40,7 @@
address = value
end
end
- enc[line[1]] = "[Interface]\nPrivateKey = " ..line[2].. "\nAddress = " ..address
+ enc[line[1]] = "[Interface]\nPrivateKey = " ..wg_clean(line[2]).. "\nAddress = " ..address
else
local peer = {
public_key = line[2],
@@ -53,7 +60,7 @@
end
end
table.insert(data[line[1]].peers, peer)
- enc[line[1]] = enc[line[1]].. "\n\n[Peer]\nEndpoint = " ..line[4].. "\nPublicKey = " ..line[2].. "\nAllowedIPs = " ..line[5]
+ enc[line[1]] = enc[line[1]].. "\n\n[Peer]\nEndpoint = " ..wg_clean(line[4]).. "\nPublicKey = " ..wg_clean(line[2]).. "\nAllowedIPs = " ..wg_clean(line[5])
end
end
end
@@ -194,7 +201,7 @@ for ikey, iface in pairs(data) do
<%-
local qrcode
if fs.access("/usr/bin/qrencode") then
- if enc[ikey]:sub(26,31) ~= "(none)" then
+ if enc[ikey]:sub(26, 26) ~= "\n" then
qrcode = luci.sys.exec("/usr/bin/qrencode --inline --8bit --type=SVG --output=- '" ..enc[ikey].. "'")
end
else