diff --git a/ui/src/components/Network.vue b/ui/src/components/Network.vue index 0b93f2e..68eabd8 100644 --- a/ui/src/components/Network.vue +++ b/ui/src/components/Network.vue @@ -117,11 +117,12 @@ label="MTU" hint="Leave at 0 for auto, 1350 for IPv6 or if problems occur" /> - - + + + @@ -681,6 +682,7 @@ export default { readAllNetworks: 'readAll', createNet: 'create', updateNet: 'update', + update_net: 'update_net', deleteNet: 'delete', }), ...mapActions('account', { @@ -1138,6 +1140,35 @@ export default { }) }, + regenerate(net) { + if (confirm(`Do you really want to regenerate the preshared key for ${net.netName}? This will take effect immediately.`)) { + + const characters = 'ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789'; + const charactersLength = characters.length; + let counter = 0; + let length = 32; + let key = ""; + while (counter < length) { + key += characters.charAt(Math.floor(Math.random() * charactersLength)); + counter += 1; + } + + key = btoa(key) + net.default.presharedKey = key + net.forceUpdate = true + + ApiService.patch(`/net/${net.id}`, net) + .then((n) => { + this.update_net(n) + this.errorNet("Preshared key has been regenerated and distributed. Clients may need to reconnect.") + this.Refresh() + }) + .catch(() => { + this.errorNet('Failed to regenerate preshared key'); + }) + } + }, + async forceFileDownload(vpn) { console.log("vpn = ", vpn) diff --git a/ui/src/store/modules/net.js b/ui/src/store/modules/net.js index af8d29d..6466510 100644 --- a/ui/src/store/modules/net.js +++ b/ui/src/store/modules/net.js @@ -64,6 +64,10 @@ const actions = { }) }, + update_net( { commit }, net) { + commit('update', net) + }, + delete({ commit }, net) { ApiService.delete(`/net/${net.id}`) .then(() => {