I am trying to add the Endpoint parameter to the Peer section in WireGuard QR code. The problem I am encountering is as follows: the WireGuard App on my phone fails to import the configuration; it returns the error
could not parse endpoint yourdomain.ddns.net
Note that the port is missing, although I included it in the code.
I know that the Lua code below is getting valid values for the
listenPort and the
endPoint, I have independently confirmed those; so I am not sure why I am seeing this error, as it is just a simple string concatenation, right? I do not believe I need to use any escape sequences for a colon in Lua, although I have tried
% anyway. I tried wrapping it all in a
tostring() function as well. Am I doing something obviously wrong?
local qr_enc local qr_code local qr_privkey local endPoint = luci.sys.exec("uci get ddns.myddns.domain") local listenPort = luci.sys.exec("uci get network.wg0.listen_port) local endPointString = tostring(endPoint .. ":" .. listenPort) if fs.access("/usr/bin/qrencode") then qr_privkey = qr_clean("privkey", luci.sys.exec("wg genkey 2>/dev/null")) if qr_pubkey[ikey] and qr_privkey then qr_enc = "[Interface]\n" ..qr_privkey.. "\n[Peer]\n" ..qr_pubkey[ikey].. "\nAllowedIPs = 0.0.0.0/0, ::/0\nEndpoint = ".. endPointString .."\n" qr_code = luci.sys.exec("/usr/bin/qrencode --inline --8bit --type=SVG --output=- '" ..qr_enc.. "' 2>/dev/null") else qr_code = "<em>The QR-Code could not be generated, the wg interface setup is incomplete!</em>" end else qr_code = "<em>For QR-Code support please install the package 'qrencode'!</em>" end