Skip to content

Commit

Permalink
Merge remote-tracking branch 'wg-easy/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dartegnian committed Mar 11, 2024
2 parents 5db7c84 + 2d68367 commit 3874d36
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 44 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Build & Publish Development

on:
workflow_dispatch:
pull_request:

jobs:
deploy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-update-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ "master" ]
schedule:
- cron: "0 0 * * *"
- cron: "0 0 * * 1"

jobs:
npmupbot:
Expand Down
6 changes: 3 additions & 3 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
const { release } = require('./package.json');

module.exports.RELEASE = release;
module.exports.PORT = process.env.PORT || 51821;
module.exports.PORT = process.env.PORT || '51821';
module.exports.WEBUI_HOST = process.env.WEBUI_HOST || '0.0.0.0';
module.exports.PASSWORD = process.env.PASSWORD;
module.exports.WG_PATH = process.env.WG_PATH || '/etc/wireguard/';
module.exports.WG_DEVICE = process.env.WG_DEVICE || 'eth0';
module.exports.WG_HOST = process.env.WG_HOST;
module.exports.WG_PORT = process.env.WG_PORT || 51820;
module.exports.WG_PORT = process.env.WG_PORT || '51820';
module.exports.WG_MTU = process.env.WG_MTU || null;
module.exports.WG_PERSISTENT_KEEPALIVE = process.env.WG_PERSISTENT_KEEPALIVE || 0;
module.exports.WG_PERSISTENT_KEEPALIVE = process.env.WG_PERSISTENT_KEEPALIVE || '0';
module.exports.WG_DEFAULT_ADDRESS = process.env.WG_DEFAULT_ADDRESS || '10.8.0.x';
module.exports.WG_DEFAULT_DNS = typeof process.env.WG_DEFAULT_DNS === 'string'
? process.env.WG_DEFAULT_DNS
Expand Down
15 changes: 8 additions & 7 deletions src/lib/WireGuard.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ PostDown = ${WG_POST_DOWN}
# Client: ${client.name} (${clientId})
[Peer]
PublicKey = ${client.publicKey}
PresharedKey = ${client.preSharedKey}
AllowedIPs = ${client.address}/32`;
${client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : ''
}AllowedIPs = ${client.address}/32`;
}

debug('Config saving...');
Expand Down Expand Up @@ -141,7 +141,7 @@ AllowedIPs = ${client.address}/32`;
createdAt: new Date(client.createdAt),
updatedAt: new Date(client.updatedAt),
allowedIPs: client.allowedIPs,

downloadableConfig: 'privateKey' in client,
persistentKeepalive: null,
latestHandshakeAt: null,
transferRx: null,
Expand Down Expand Up @@ -196,16 +196,17 @@ AllowedIPs = ${client.address}/32`;
const config = await this.getConfig();
const client = await this.getClient({ clientId });

return `[Interface]
PrivateKey = ${client.privateKey}
return `
[Interface]
PrivateKey = ${client.privateKey ? `${client.privateKey}` : 'REPLACE_ME'}
Address = ${client.address}/24
${WG_DEFAULT_DNS ? `DNS = ${WG_DEFAULT_DNS}\n` : ''}\
${WG_MTU ? `MTU = ${WG_MTU}\n` : ''}\
[Peer]
PublicKey = ${config.server.publicKey}
PresharedKey = ${client.preSharedKey}
AllowedIPs = ${WG_ALLOWED_IPS}
${client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : ''
}AllowedIPs = ${WG_ALLOWED_IPS}
PersistentKeepalive = ${WG_PERSISTENT_KEEPALIVE}
Endpoint = ${WG_HOST}:${WG_PORT}`;
}
Expand Down
58 changes: 29 additions & 29 deletions src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,15 @@ module.exports = {
'2xl': '1536px',
},
},
plugins: [
function addDisabledClass({ addUtilities }) {
const newUtilities = {
'.is-disabled': {
opacity: '0.25',
cursor: 'default',
},
};
addUtilities(newUtilities);
},
],
};
5 changes: 5 additions & 0 deletions src/www/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,11 @@ video {
transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
}

.is-disabled {
opacity: 0.25;
cursor: default;
}

.last\:border-b-0:last-child {
border-bottom-width: 0px;
}
Expand Down
21 changes: 17 additions & 4 deletions src/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,15 @@ <h2 class="text-sm text-gray-400 dark:text-neutral-400 mb-10"></h2>

<!-- Show QR-->

<button

<button :disabled="!client.downloadableConfig"
class="align-middle material-basic--secondary p-2 rounded transition"
title="Show QR Code" @click="qrcode = `./api/wireguard/client/${client.id}/qrcode.svg`">
:class="{
'hover:bg-red-800 dark:hover:bg-red-800 hover:text-white dark:hover:text-white': client.downloadableConfig,
'is-disabled': !client.downloadableConfig
}"
:title="!client.downloadableConfig ? $t('noPrivKey') : $t('showQR')"
@click="qrcode = `./api/wireguard/client/${client.id}/qrcode.svg`">
<svg class="w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
Expand All @@ -311,9 +317,16 @@ <h2 class="text-sm text-gray-400 dark:text-neutral-400 mb-10"></h2>
</button>

<!-- Download Config -->
<a :href="'./api/wireguard/client/' + client.id + '/configuration'" download
<a :disabled="!client.downloadableConfig"
:href="'./api/wireguard/client/' + client.id + '/configuration'"
:download="client.downloadableConfig ? 'configuration' : null"
class="align-middle inline-block material-basic--secondary p-2 rounded transition"
title="Download Configuration">
:class="{
'hover:bg-red-800 dark:hover:bg-red-800 hover:text-white dark:hover:text-white': client.downloadableConfig,
'is-disabled': !client.downloadableConfig
}"
:title="!client.downloadableConfig ? $t('noPrivKey') : $t('downloadConfig')"
@click="if(!client.downloadableConfig) { $event.preventDefault(); }">
<svg class="w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
Expand Down
2 changes: 2 additions & 0 deletions src/www/js/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const messages = { // eslint-disable-line no-unused-vars
disableClient: 'Disable Client',
enableClient: 'Enable Client',
noClients: 'There are no clients yet.',
noPrivKey: 'This client has no known private key. Cannot create Configuration.',
showQR: 'Show QR Code',
downloadConfig: 'Download Configuration',
madeBy: 'Made by',
Expand Down Expand Up @@ -213,6 +214,7 @@ const messages = { // eslint-disable-line no-unused-vars
disableClient: 'Client deaktivieren',
enableClient: 'Client aktivieren',
noClients: 'Es wurden noch keine Clients konfiguriert.',
noPrivKey: 'Es ist kein Private Key für diesen Client bekannt. Eine Konfiguration kann nicht erstellt werden.',
showQR: 'Zeige den QR Code',
downloadConfig: 'Konfiguration herunterladen',
madeBy: 'Erstellt von',
Expand Down

0 comments on commit 3874d36

Please sign in to comment.