luci-app-wireguard: merge app and proto rpcd

Signed-off-by: lvoegl <lvoegl@tdt.de>
This commit is contained in:
lvoegl 2021-08-31 13:51:06 +02:00 committed by Lukas Voegl
parent 8950c9f66c
commit d98935c45b
6 changed files with 12 additions and 30 deletions

View file

@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk
LUCI_TITLE:=WireGuard Status
LUCI_DEPENDS:=+wireguard-tools +luci-proto-wireguard
LUCI_DEPENDS:=+wireguard-tools
LUCI_PKGARCH:=all
include ../../luci.mk

View file

@ -6,7 +6,7 @@
var callGetWgInstances = rpc.declare({
object: 'luci.wireguard_status',
object: 'luci.wireguard',
method: 'getWgInstances'
});

View file

@ -6,6 +6,14 @@ local io = require "io"
local uci = require "uci"
local methods = {
generateKeyPair = {
call = function()
local prv = sys.exec("wg genkey 2>/dev/null"):sub(1, -2)
local pub = sys.exec("echo '" .. prv .. "' | wg pubkey 2>/dev/null"):sub(1, -2)
return {keys = {priv = prv, pub = pub}}
end
},
getWgInstances = {
call = function()
local data = {}

View file

@ -3,7 +3,7 @@
"description": "Grant access to LuCI app wireguard",
"read": {
"ubus": {
"luci.wireguard_status": [
"luci.wireguard": [
"getWgInstances"
]
}

View file

@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk
LUCI_TITLE:=Support for WireGuard VPN
LUCI_DEPENDS:=+wireguard-tools
LUCI_DEPENDS:=+wireguard-tools +luci-app-wireguard
LUCI_PKGARCH:=all
include ../../luci.mk

View file

@ -1,26 +0,0 @@
#!/bin/sh
. /usr/share/libubox/jshn.sh
case "$1" in
list)
json_init
json_add_object "generateKeyPair"
json_close_object
json_dump
;;
call)
case "$2" in
generateKeyPair)
prv=$(wg genkey)
pub=$(echo $prv | wg pubkey)
json_init
json_add_object "keys"
json_add_string "priv" "$prv"
json_add_string "pub" "$pub"
json_close_object
json_dump
;;
esac
;;
esac