summaryrefslogtreecommitdiffhomepage
path: root/protocols/luci-proto-wireguard/root/usr/libexec/rpcd/luci.wireguard
blob: a6c951f3de1551c5a44c9867a507406a8208a280 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/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