From ce3179c6d1fba656cddb05cb13f69153bda60396 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sun, 17 May 2015 22:33:30 -0500 Subject: [PATCH] luci-app-fwknopd: Add qr code support Signed-off-by: Jonathan Bennett --- applications/luci-app-fwknopd/Makefile | 2 +- .../luasrc/model/cbi/fwknopd.lua | 3 +++ .../luasrc/view/fwknopd-qr.htm | 1 + .../luci-app-fwknopd/root/usr/sbin/gen-qr.sh | 22 +++++++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 applications/luci-app-fwknopd/luasrc/view/fwknopd-qr.htm create mode 100644 applications/luci-app-fwknopd/root/usr/sbin/gen-qr.sh diff --git a/applications/luci-app-fwknopd/Makefile b/applications/luci-app-fwknopd/Makefile index a24b56285..3fbd88ad6 100644 --- a/applications/luci-app-fwknopd/Makefile +++ b/applications/luci-app-fwknopd/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk LUCI_TITLE:=Fwknopd config - web config for the firewall knock daemon -LUCI_DEPENDS:=+fwknopd +LUCI_DEPENDS:=+fwknopd +qrencode PKG_VERSION:=1.0 PKG_RELEASE:=1 PKG_LICENSE:=GPLv2 diff --git a/applications/luci-app-fwknopd/luasrc/model/cbi/fwknopd.lua b/applications/luci-app-fwknopd/luasrc/model/cbi/fwknopd.lua index 8a454dd58..84a1a23d8 100644 --- a/applications/luci-app-fwknopd/luasrc/model/cbi/fwknopd.lua +++ b/applications/luci-app-fwknopd/luasrc/model/cbi/fwknopd.lua @@ -6,6 +6,9 @@ m = Map("fwknopd", translate("Firewall Knock Operator")) s = m:section(TypedSection, "global", translate("Enable Uci/Luci control")) -- Set uci control on or off s.anonymous=true s:option(Flag, "uci_enabled", translate("Enable config overwrite"), translate("When unchecked, the config files in /etc/fwknopd will be used as is, ignoring any settings here.")) +qr = s:option(DummyValue, "note0", "dummy") +qr.template = "fwknopd-qr" +qr:depends("uci_enabled", "1") s = m:section(TypedSection, "access", translate("access.conf stanzas")) -- set the access.conf settings s.anonymous=true diff --git a/applications/luci-app-fwknopd/luasrc/view/fwknopd-qr.htm b/applications/luci-app-fwknopd/luasrc/view/fwknopd-qr.htm new file mode 100644 index 000000000..9e6e8185f --- /dev/null +++ b/applications/luci-app-fwknopd/luasrc/view/fwknopd-qr.htm @@ -0,0 +1 @@ +<% print(luci.sys.exec("sh /usr/sbin/gen-qr.sh")) %> diff --git a/applications/luci-app-fwknopd/root/usr/sbin/gen-qr.sh b/applications/luci-app-fwknopd/root/usr/sbin/gen-qr.sh new file mode 100644 index 000000000..97493dafe --- /dev/null +++ b/applications/luci-app-fwknopd/root/usr/sbin/gen-qr.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +key_base64=$(uci get fwknopd.@access[0].KEY_BASE64) +key=$(uci get fwknopd.@access[0].KEY) +hmac_key_base64=$(uci get fwknopd.@access[0].HMAC_KEY_BASE64) +hmac_key=$(uci get fwknopd.@access[0].HMAC_KEY) + +if [ $key_base64 != "" ]; then +qr="KEY_BASE64:$key_base64" +fi +if [ $key != "" ]; then +qr="$qr KEY:$key" + +fi +if [ $hmac_key_base64 != "" ]; then +qr="$qr HMAC_KEY_BASE64:$hmac_key_base64" +fi +if [ $hmac_key != "" ]; then +qr="$qr HMAC_KEY:$hmac_key" +fi + +qrencode -o - "$qr" -- 2.25.1