Don't let new peers be deleted

master
Keith Irwin 2022-10-21 12:42:34 -06:00
parent c0aef84f0a
commit 036b6cdeca
Signed by: ki9
GPG Key ID: DF773B3F4A88DA86
3 changed files with 7 additions and 7 deletions

View File

@ -87,7 +87,7 @@ if ! sudo /usr/bin/openssl x509 -req -sha256 -extensions SAN -CAcreateserial \
fi; if ! sudo [ -f "${SSL_CONFIG_DIR:?}/${username:?}/${hostname:?}/server.crt" ]; then
printf 'ERROR! SSL key %s/%s/server.crt was not generated!\n' "${username}" "${hostname}" >>"${LOGFILE}"
exit 7
fi; if ! sudo chmod 640 "${SSL_CONFIG_DIR}/${username}/${hostname}/server.*"; then
fi; if ! sudo chmod 640 "${SSL_CONFIG_DIR}/${username}/${hostname}/server.crt" "${SSL_CONFIG_DIR}/${username}/${hostname}/server.key"; then
printf 'ERROR! Failed to chmod SSL cert %s/%s/server.*\n' "${username}" "${hostname}" >>"${LOGFILE}"
exit 8
fi & if ! sudo chgrp -R www-data "${SSL_CONFIG_DIR}/${username}/"; then

View File

@ -4,7 +4,7 @@
</head>
<body>
<p>Use this console to edit network-connected devices. </p>
<h2>Peers</h2>
<table>
<thead><tr>
@ -13,10 +13,10 @@
<tbody data-bind="foreach:peers"><tr>
<td data-bind="text:domain"></td>
<td data-bind="text:ipv4"></td>
<td><button style="float:right" data-bind="click:$parent.delPeer,disable:$data.isDeleting,text:deleteText">Delete</button></td>
<td><button style="float:right" data-bind="click:$parent.delPeer,disable:$data.isDeleting,disable:$data.cantDelete,text:deleteText">Delete</button></td>
</tr></tbody>
</table>
<h2>Add peer</h2>
<p>To add a new peer, type in a hostname and select a user. The hostname must be 3-10 lowercase letters and numbers <code>/[a-z0-9]{3,10}/</code>. </p>
<div>
@ -28,7 +28,7 @@
<p>After clicking "Add", the new peer's config will appear below. Copy and paste it into your wireguard client and start the service. <b>This configuration will not be shown again!</b> If you lose the config, you will need to delete the peer and recreate it. </p>
<hr>
<pre data-bind="text:newConfigText"></pre>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.5.1/knockout-latest.js" integrity="sha512-2AL/VEauKkZqQU9BHgnv48OhXcJPx9vdzxN1JrKDVc4FPU/MEE/BZ6d9l0mP7VmvLsjtYwqiYQpDskK9dG8KBA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="/admin.js"></script>
</body>

View File

@ -6,7 +6,7 @@ function Peer(data) {
this.pubkey = data.pubkey
this.ipv4 = data.ipv4
this.ipv6 = data.ipv6
this.canDelete = data.canDelete || true
this.cantDelete = data.cantDelete
this.isDeleting = ko.observable(false)
this.deleteText = ko.computed(() => this.isDeleting()?'Deleting...':'Delete')
}
@ -94,7 +94,7 @@ function PeerList() {
self.newPeerHostname('')
self.peers.push(new Peer({
domain:`${validHostname}.${self.newPeerUser().name}.${TLD}`,
canDelete: false,
cantDelete: true,
}))
self.newConfigText(parsedRes)
}