diff options
author | Lukas Voegl <lvoegl@tdt.de> | 2022-03-18 14:47:44 +0100 |
---|---|---|
committer | Lukas Voegl <lvoegl@tdt.de> | 2022-03-18 14:47:44 +0100 |
commit | b6925a12277224b4a02dc1febb58de8d4d6fdbe0 (patch) | |
tree | 0e8bdfa370716cbbffea5c210119cd54521104f7 /protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol | |
parent | f27fe280aa7a1d39de7144298541bfac8bb59f7f (diff) |
luci-proto-wireguard: add generate psk button
Signed-off-by: Lukas Voegl <lvoegl@tdt.de>
Diffstat (limited to 'protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol')
-rw-r--r-- | protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol/wireguard.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol/wireguard.js b/protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol/wireguard.js index 50080ca9b6..677edb8bec 100644 --- a/protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol/wireguard.js +++ b/protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol/wireguard.js @@ -25,6 +25,12 @@ var generateQrCode = rpc.declare({ expect: { qr_code: '' } }); +var generatePsk = rpc.declare({ + object: 'luci.wireguard', + method: 'generatePsk', + expect: { psk: '' } +}); + function validateBase64(section_id, value) { if (value.length == 0) return true; @@ -273,6 +279,18 @@ return network.registerProtocol('wireguard', { o.validate = validateBase64; o.optional = true; + o = ss.option(form.Button, 'generate_key', _('Generate Key')); + o.inputstyle = 'apply'; + o.onclick = ui.createHandlerFn(this, function (section_id, ev, peer_id) { + return generatePsk().then(function (psk) { + var keyInput = document.getElementById('widget.cbid.network.%s.preshared_key'.format(peer_id)), + changeEvent = new Event('change'); + + keyInput.value = psk; + keyInput.dispatchEvent(changeEvent); + }); + }, s.section); + o = ss.option(form.DynamicList, 'allowed_ips', _('Allowed IPs'), _("Optional. IP addresses and prefixes that this peer is allowed to use inside the tunnel. Usually the peer's tunnel IP addresses and the networks the peer routes through the tunnel.")); o.datatype = 'ipaddr'; o.optional = true; |