diff --git a/src/config.js b/src/config.js index ab825f14..e161144c 100644 --- a/src/config.js +++ b/src/config.js @@ -4,15 +4,15 @@ const childProcess = require('child_process'); 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_ADDRESS6 = process.env.WG_DEFAULT_ADDRESS6 || 'fdcc:ad94:bacf:61a4::cafe:x'; module.exports.WG_DEFAULT_DNS = typeof process.env.WG_DEFAULT_DNS === 'string' diff --git a/src/lib/WireGuard.js b/src/lib/WireGuard.js index 2db75827..afec7724 100644 --- a/src/lib/WireGuard.js +++ b/src/lib/WireGuard.js @@ -118,8 +118,8 @@ PostDown = ${WG_POST_DOWN} # Client: ${client.name} (${clientId}) [Peer] PublicKey = ${client.publicKey} -PresharedKey = ${client.preSharedKey} -AllowedIPs = ${client.address}/32, ${client.address6}/128`; +${client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : '' +}AllowedIPs = ${client.address}/32`; } debug('Config saving...'); @@ -150,7 +150,7 @@ AllowedIPs = ${client.address}/32, ${client.address6}/128`; createdAt: new Date(client.createdAt), updatedAt: new Date(client.updatedAt), allowedIPs: client.allowedIPs, - + downloadableConfig: 'privateKey' in client, persistentKeepalive: null, latestHandshakeAt: null, transferRx: null, @@ -207,16 +207,17 @@ AllowedIPs = ${client.address}/32, ${client.address6}/128`; const isDnsSet = WG_DEFAULT_DNS || WG_DEFAULT_DNS6; const dnsServers = [WG_DEFAULT_DNS, WG_DEFAULT_DNS6].filter((item) => !!item).join(', '); - return `[Interface] -PrivateKey = ${client.privateKey} -Address = ${client.address}/24, ${client.address6}/64 -${isDnsSet ? `DNS = ${dnsServers}\n` : ''}\ + 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}`; } diff --git a/src/package-lock.json b/src/package-lock.json index 532fa5bb..738ef0d6 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -5078,9 +5078,9 @@ "dev": true }, "node_modules/yaml": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.0.tgz", - "integrity": "sha512-j9iR8g+/t0lArF4V6NE/QCfT+CO7iLqrXAHZbJdo+LfjqP1vR8Fg5bSiaq6Q2lOD1AUEVrEVIgABvBFYojJVYQ==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.1.tgz", + "integrity": "sha512-pIXzoImaqmfOrL7teGUBt/T7ZDnyeGBWyXQBvOVhLkWLN37GXv8NMLK406UY6dS51JfcQHsmcW5cJ441bHg6Lg==", "dev": true, "bin": { "yaml": "bin.mjs" diff --git a/src/tailwind.config.js b/src/tailwind.config.js index 8070b0cd..33ba6746 100644 --- a/src/tailwind.config.js +++ b/src/tailwind.config.js @@ -16,4 +16,15 @@ module.exports = { '2xl': '1536px', }, }, + plugins: [ + function addDisabledClass({ addUtilities }) { + const newUtilities = { + '.is-disabled': { + opacity: '0.25', + cursor: 'default', + }, + }; + addUtilities(newUtilities); + }, + ], }; diff --git a/src/www/css/app.css b/src/www/css/app.css index 3064646a..00837d4c 100644 --- a/src/www/css/app.css +++ b/src/www/css/app.css @@ -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; } diff --git a/src/www/index.html b/src/www/index.html index 8e7d060d..ee70469f 100644 --- a/src/www/index.html +++ b/src/www/index.html @@ -279,9 +279,14 @@ -