From 2c7221b64a595f180abad8607e377c61edd58e2f Mon Sep 17 00:00:00 2001 From: Peter Lewis Date: Wed, 1 Feb 2023 10:58:36 +0000 Subject: [PATCH 1/9] Update branch name in lint.yml --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2f88a007..85de8d1e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,7 +3,7 @@ name: Lint on: push: branches: - - master + - development - production pull_request: From 90b6c19c6a73bce65e669cbd4f74aa97f8afbae3 Mon Sep 17 00:00:00 2001 From: Peter Lewis Date: Wed, 1 Feb 2023 11:05:16 +0000 Subject: [PATCH 2/9] Update server.js to keep lint happy --- src/server.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server.js b/src/server.js index ac26c6d3..2f26824c 100644 --- a/src/server.js +++ b/src/server.js @@ -1,8 +1,8 @@ -'use strict'; +"use strict"; -require('./services/Server'); +require("./services/Server"); -const WireGuard = require('./services/WireGuard'); +const WireGuard = require("./services/WireGuard"); WireGuard.getConfig() .catch(err => { From 563cb77176bf665ae33d92b66ce46f7ba2d53d6b Mon Sep 17 00:00:00 2001 From: Peter Lewis Date: Wed, 1 Feb 2023 11:08:05 +0000 Subject: [PATCH 3/9] Revert "Update server.js to keep lint happy" This reverts commit 90b6c19c6a73bce65e669cbd4f74aa97f8afbae3. --- src/server.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server.js b/src/server.js index 2f26824c..ac26c6d3 100644 --- a/src/server.js +++ b/src/server.js @@ -1,8 +1,8 @@ -"use strict"; +'use strict'; -require("./services/Server"); +require('./services/Server'); -const WireGuard = require("./services/WireGuard"); +const WireGuard = require('./services/WireGuard'); WireGuard.getConfig() .catch(err => { From 6bbd46e7df26e98b20042f9b88980f56c5198c6e Mon Sep 17 00:00:00 2001 From: Peter Lewis Date: Wed, 1 Feb 2023 11:21:40 +0000 Subject: [PATCH 4/9] Update Server.js --- src/lib/Server.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/Server.js b/src/lib/Server.js index f8f380bd..ff8c494e 100644 --- a/src/lib/Server.js +++ b/src/lib/Server.js @@ -35,7 +35,7 @@ module.exports = class Server { }))) // Authentication - .get('/api/session', Util.promisify(async req => { + .get('/api/session', Util.promisify(async (req) => { const requiresPassword = !!process.env.PASSWORD; const authenticated = requiresPassword ? !!(req.session && req.session.authenticated) @@ -46,7 +46,7 @@ module.exports = class Server { authenticated, }; })) - .post('/api/session', Util.promisify(async req => { + .post('/api/session', Util.promisify(async (req) => { const { password, } = req.body; @@ -79,14 +79,14 @@ module.exports = class Server { error: 'Not Logged In', }); }) - .delete('/api/session', Util.promisify(async req => { + .delete('/api/session', Util.promisify(async (req) => { const sessionId = req.session.id; req.session.destroy(); debug(`Deleted Session: ${sessionId}`); })) - .get('/api/wireguard/client', Util.promisify(async req => { + .get('/api/wireguard/client', Util.promisify(async (req) => { return WireGuard.getClients(); })) .get('/api/wireguard/client/:clientId/qrcode.svg', Util.promisify(async (req, res) => { @@ -108,28 +108,28 @@ module.exports = class Server { res.header('Content-Type', 'text/plain'); res.send(config); })) - .post('/api/wireguard/client', Util.promisify(async req => { + .post('/api/wireguard/client', Util.promisify(async (req) => { const { name } = req.body; return WireGuard.createClient({ name }); })) - .delete('/api/wireguard/client/:clientId', Util.promisify(async req => { + .delete('/api/wireguard/client/:clientId', Util.promisify(async (req) => { const { clientId } = req.params; return WireGuard.deleteClient({ clientId }); })) - .post('/api/wireguard/client/:clientId/enable', Util.promisify(async req => { + .post('/api/wireguard/client/:clientId/enable', Util.promisify(async (req) => { const { clientId } = req.params; return WireGuard.enableClient({ clientId }); })) - .post('/api/wireguard/client/:clientId/disable', Util.promisify(async req => { + .post('/api/wireguard/client/:clientId/disable', Util.promisify(async (req) => { const { clientId } = req.params; return WireGuard.disableClient({ clientId }); })) - .put('/api/wireguard/client/:clientId/name', Util.promisify(async req => { + .put('/api/wireguard/client/:clientId/name', Util.promisify(async (req) => { const { clientId } = req.params; const { name } = req.body; return WireGuard.updateClientName({ clientId, name }); })) - .put('/api/wireguard/client/:clientId/address', Util.promisify(async req => { + .put('/api/wireguard/client/:clientId/address', Util.promisify(async (req) => { const { clientId } = req.params; const { address } = req.body; return WireGuard.updateClientAddress({ clientId, address }); From 1a11c6f39670fc0f273044f58e602da6fe0a19c0 Mon Sep 17 00:00:00 2001 From: Peter Lewis Date: Wed, 1 Feb 2023 11:22:07 +0000 Subject: [PATCH 5/9] Update Util.js --- src/lib/Util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/Util.js b/src/lib/Util.js index 2a47a20e..cc6e89c2 100644 --- a/src/lib/Util.js +++ b/src/lib/Util.js @@ -21,7 +21,7 @@ module.exports = class Util { // eslint-disable-next-line func-names return function(req, res) { Promise.resolve().then(async () => fn(req, res)) - .then(result => { + .then((result) => { if (res.headersSent) return; if (typeof result === 'undefined') { @@ -34,7 +34,7 @@ module.exports = class Util { .status(200) .json(result); }) - .catch(error => { + .catch((error) => { if (typeof error === 'string') { error = new Error(error); } From 8800cd9b0d13499c0c0b4cefcd368e265f1ee0f4 Mon Sep 17 00:00:00 2001 From: Peter Lewis Date: Wed, 1 Feb 2023 11:22:33 +0000 Subject: [PATCH 6/9] Update WireGuard.js --- src/lib/WireGuard.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/WireGuard.js b/src/lib/WireGuard.js index 7886ac91..fd19458a 100644 --- a/src/lib/WireGuard.js +++ b/src/lib/WireGuard.js @@ -60,7 +60,7 @@ module.exports = class WireGuard { await this.__saveConfig(config); await Util.exec('wg-quick down wg0').catch(() => { }); - await Util.exec('wg-quick up wg0').catch(err => { + await Util.exec('wg-quick up wg0').catch((err) => { if (err && err.message && err.message.includes('Cannot find device "wg0"')) { throw new Error('WireGuard exited with the error: Cannot find device "wg0"\nThis usually means that your host\'s kernel does not support WireGuard!'); } @@ -156,7 +156,7 @@ AllowedIPs = ${client.address}/32`; .trim() .split('\n') .slice(1) - .forEach(line => { + .forEach((line) => { const [ publicKey, preSharedKey, // eslint-disable-line no-unused-vars @@ -168,7 +168,7 @@ AllowedIPs = ${client.address}/32`; persistentKeepalive, ] = line.split('\t'); - const client = clients.find(client => client.publicKey === publicKey); + const client = clients.find((client) => client.publicKey === publicKey); if (!client) return; client.latestHandshakeAt = latestHandshakeAt === '0' @@ -233,7 +233,7 @@ Endpoint = ${WG_HOST}:${WG_PORT}`; // Calculate next IP let address; for (let i = 2; i < 255; i++) { - const client = Object.values(config.clients).find(client => { + const client = Object.values(config.clients).find((client) => { return client.address === WG_DEFAULT_ADDRESS.replace('x', i); }); From 1b835bfb4012b370fa6cb6fcac656c1c56a04b78 Mon Sep 17 00:00:00 2001 From: Peter Lewis Date: Wed, 1 Feb 2023 11:22:48 +0000 Subject: [PATCH 7/9] Update server.js --- src/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server.js b/src/server.js index ac26c6d3..0bc2c985 100644 --- a/src/server.js +++ b/src/server.js @@ -5,7 +5,7 @@ require('./services/Server'); const WireGuard = require('./services/WireGuard'); WireGuard.getConfig() - .catch(err => { + .catch((err) => { // eslint-disable-next-line no-console console.error(err); From a00a9f044901d4620293c35c5d3386f4085e5d9d Mon Sep 17 00:00:00 2001 From: Peter Lewis Date: Wed, 1 Feb 2023 11:24:58 +0000 Subject: [PATCH 8/9] Update api.js --- src/www/js/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/www/js/api.js b/src/www/js/api.js index 84885f17..826a7652 100644 --- a/src/www/js/api.js +++ b/src/www/js/api.js @@ -62,7 +62,7 @@ class API { return this.call({ method: 'get', path: '/wireguard/client', - }).then(clients => clients.map(client => ({ + }).then((clients) => clients.map((client) => ({ ...client, createdAt: new Date(client.createdAt), updatedAt: new Date(client.updatedAt), From fb3ece4360796001856fd8ec4753f228b3e08474 Mon Sep 17 00:00:00 2001 From: Peter Lewis Date: Wed, 1 Feb 2023 11:25:12 +0000 Subject: [PATCH 9/9] Update app.js --- src/www/js/app.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/www/js/app.js b/src/www/js/app.js index e22cbfe0..3b9a89bf 100644 --- a/src/www/js/app.js +++ b/src/www/js/app.js @@ -112,7 +112,7 @@ new Vue({ }, }, methods: { - dateTime: value => { + dateTime: (value) => { return new Intl.DateTimeFormat(undefined, { year: 'numeric', month: 'short', @@ -127,7 +127,7 @@ new Vue({ if (!this.authenticated) return; const clients = await this.api.getClients(); - this.clients = clients.map(client => { + this.clients = clients.map((client) => { if (client.name.includes('@') && client.name.includes('.')) { client.avatar = `https://www.gravatar.com/avatar/${md5(client.name)}?d=blank`; } @@ -186,7 +186,7 @@ new Vue({ this.requiresPassword = session.requiresPassword; return this.refresh(); }) - .catch(err => { + .catch((err) => { alert(err.message || err.toString()); }) .finally(() => { @@ -202,7 +202,7 @@ new Vue({ this.authenticated = false; this.clients = null; }) - .catch(err => { + .catch((err) => { alert(err.message || err.toString()); }); }, @@ -211,54 +211,54 @@ new Vue({ if (!name) return; this.api.createClient({ name }) - .catch(err => alert(err.message || err.toString())) + .catch((err) => alert(err.message || err.toString())) .finally(() => this.refresh().catch(console.error)); }, deleteClient(client) { this.api.deleteClient({ clientId: client.id }) - .catch(err => alert(err.message || err.toString())) + .catch((err) => alert(err.message || err.toString())) .finally(() => this.refresh().catch(console.error)); }, enableClient(client) { this.api.enableClient({ clientId: client.id }) - .catch(err => alert(err.message || err.toString())) + .catch((err) => alert(err.message || err.toString())) .finally(() => this.refresh().catch(console.error)); }, disableClient(client) { this.api.disableClient({ clientId: client.id }) - .catch(err => alert(err.message || err.toString())) + .catch((err) => alert(err.message || err.toString())) .finally(() => this.refresh().catch(console.error)); }, updateClientName(client, name) { this.api.updateClientName({ clientId: client.id, name }) - .catch(err => alert(err.message || err.toString())) + .catch((err) => alert(err.message || err.toString())) .finally(() => this.refresh().catch(console.error)); }, updateClientAddress(client, address) { this.api.updateClientAddress({ clientId: client.id, address }) - .catch(err => alert(err.message || err.toString())) + .catch((err) => alert(err.message || err.toString())) .finally(() => this.refresh().catch(console.error)); }, }, filters: { bytes, - timeago: value => { + timeago: (value) => { return timeago().format(value); }, }, mounted() { this.api = new API(); this.api.getSession() - .then(session => { + .then((session) => { this.authenticated = session.authenticated; this.requiresPassword = session.requiresPassword; this.refresh({ updateCharts: true, - }).catch(err => { + }).catch((err) => { alert(err.message || err.toString()); }); }) - .catch(err => { + .catch((err) => { alert(err.message || err.toString()); }); @@ -271,8 +271,8 @@ new Vue({ Promise.resolve().then(async () => { const currentRelease = await this.api.getRelease(); const latestRelease = await fetch('https://weejewel.github.io/wg-easy/changelog.json') - .then(res => res.json()) - .then(releases => { + .then((res) => res.json()) + .then((releases) => { const releasesArray = Object.entries(releases).map(([version, changelog]) => ({ version: parseInt(version, 10), changelog,