From 4ead4c2cc9fd76578cd50332e9b11ced35e867f3 Mon Sep 17 00:00:00 2001 From: Bernd Storath <999999bst@gmail.com> Date: Tue, 13 Aug 2024 08:30:51 +0200 Subject: [PATCH 1/6] fix pr template location --- .../pull_request_template.md => PULL_REQUEST_TEMPLATE.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{PULL_REQUEST_TEMPLATE/pull_request_template.md => PULL_REQUEST_TEMPLATE.md} (100%) diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from .github/PULL_REQUEST_TEMPLATE/pull_request_template.md rename to .github/PULL_REQUEST_TEMPLATE.md From 8591b35d4e44142cd3ffabcaa14ca776583cd7c0 Mon Sep 17 00:00:00 2001 From: jkh0kr Date: Wed, 14 Aug 2024 10:00:58 +0900 Subject: [PATCH 2/6] Update i18n.js Additional Korean language updates --- src/www/js/i18n.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/www/js/i18n.js b/src/www/js/i18n.js index 2666961..226516b 100644 --- a/src/www/js/i18n.js +++ b/src/www/js/i18n.js @@ -340,6 +340,12 @@ const messages = { // eslint-disable-line no-unused-vars downloadConfig: '구성 다운로드', madeBy: '만든 사람', donate: '기부', + toggleCharts: '차트 표시/숨기기', + theme: { dark: '어두운 테마', light: '밝은 테마', auto: '자동 테마' }, + restore: '복원', + backup: '백업', + titleRestoreConfig: '구성 파일 복원', + titleBackupConfig: '구성 파일 백업', }, vi: { name: 'Tên', From 2ea37dd7bac2271627db6ad82713109ccca8ec94 Mon Sep 17 00:00:00 2001 From: NPM Update Bot Date: Thu, 15 Aug 2024 15:04:36 +0000 Subject: [PATCH 3/6] npm: package updates --- src/package-lock.json | 8 ++++---- src/package.json | 2 +- src/www/css/app.css | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/package-lock.json b/src/package-lock.json index c1781a1..7d0e900 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -18,7 +18,7 @@ "devDependencies": { "eslint-config-athom": "^3.1.3", "nodemon": "^3.1.4", - "tailwindcss": "^3.4.9" + "tailwindcss": "^3.4.10" }, "engines": { "node": ">=18" @@ -4687,9 +4687,9 @@ "peer": true }, "node_modules/tailwindcss": { - "version": "3.4.9", - "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.9.tgz", - "integrity": "sha512-1SEOvRr6sSdV5IDf9iC+NU4dhwdqzF4zKKq3sAbasUWHEM6lsMhX+eNN5gkPx1BvLFEnZQEUFbXnGj8Qlp83Pg==", + "version": "3.4.10", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.10.tgz", + "integrity": "sha512-KWZkVPm7yJRhdu4SRSl9d4AK2wM3a50UsvgHZO7xY77NQr2V+fIrEuoDGQcbvswWvFGbS2f6e+jC/6WJm1Dl0w==", "dev": true, "license": "MIT", "dependencies": { diff --git a/src/package.json b/src/package.json index 92582e9..655cb34 100644 --- a/src/package.json +++ b/src/package.json @@ -24,7 +24,7 @@ "devDependencies": { "eslint-config-athom": "^3.1.3", "nodemon": "^3.1.4", - "tailwindcss": "^3.4.9" + "tailwindcss": "^3.4.10" }, "nodemonConfig": { "ignore": [ diff --git a/src/www/css/app.css b/src/www/css/app.css index 92bb704..ae3fc3c 100644 --- a/src/www/css/app.css +++ b/src/www/css/app.css @@ -1,5 +1,5 @@ /* -! tailwindcss v3.4.9 | MIT License | https://tailwindcss.com +! tailwindcss v3.4.10 | MIT License | https://tailwindcss.com */ /* From 0a33b1f7df3576d99ef9644618d300ac652a5a8c Mon Sep 17 00:00:00 2001 From: Vadim Babadzhanyan Date: Fri, 16 Aug 2024 18:39:24 +0300 Subject: [PATCH 4/6] Supports displaying short links, for easy downloading on TVs and Android TVs --- README.md | 2 ++ docker-compose.yml | 3 ++- src/config.js | 1 + src/lib/Server.js | 17 +++++++++++++++++ src/lib/WireGuard.js | 2 ++ src/www/index.html | 7 +++++-- src/www/js/api.js | 7 +++++++ src/www/js/app.js | 9 +++++++++ 8 files changed, 45 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index be8a32c..67f5ecb 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ You have found the easiest way to install & manage WireGuard on any Linux host! * Automatic Light / Dark Mode * Multilanguage Support * UI_TRAFFIC_STATS (default off) +* UI_SHOW_LINKS (default off) ## Requirements @@ -120,6 +121,7 @@ These options can be configured by setting environment variables using `-e KEY=" | `LANG` | `en` | `de` | Web UI language (Supports: en, ua, ru, tr, no, pl, fr, de, ca, es, ko, vi, nl, is, pt, chs, cht, it, th, hi). | | `UI_TRAFFIC_STATS` | `false` | `true` | Enable detailed RX / TX client stats in Web UI | | `UI_CHART_TYPE` | `0` | `1` | UI_CHART_TYPE=0 # Charts disabled, UI_CHART_TYPE=1 # Line chart, UI_CHART_TYPE=2 # Area chart, UI_CHART_TYPE=3 # Bar chart | +| `UI_SHOW_LINKS` | `false` | `true` | Enable display of a short download link in Web UI | > If you change `WG_PORT`, make sure to also change the exposed port. diff --git a/docker-compose.yml b/docker-compose.yml index dd450ed..dd135fd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,6 +27,7 @@ services: # - WG_POST_DOWN=echo "Post Down" > /etc/wireguard/post-down.txt # - UI_TRAFFIC_STATS=true # - UI_CHART_TYPE=0 # (0 Charts disabled, 1 # Line chart, 2 # Area chart, 3 # Bar chart) + # - UI_SHOW_LINKS=true image: ghcr.io/wg-easy/wg-easy container_name: wg-easy @@ -39,7 +40,7 @@ services: cap_add: - NET_ADMIN - SYS_MODULE - # - NET_RAW # ⚠️ Uncomment if using Podman + # - NET_RAW # ⚠️ Uncomment if using Podman sysctls: - net.ipv4.ip_forward=1 - net.ipv4.conf.all.src_valid_mark=1 diff --git a/src/config.js b/src/config.js index 9785053..9335bfb 100644 --- a/src/config.js +++ b/src/config.js @@ -37,3 +37,4 @@ iptables -D FORWARD -o wg0 -j ACCEPT; module.exports.LANG = process.env.LANG || 'en'; module.exports.UI_TRAFFIC_STATS = process.env.UI_TRAFFIC_STATS || 'false'; module.exports.UI_CHART_TYPE = process.env.UI_CHART_TYPE || 0; +module.exports.UI_SHOW_LINKS = process.env.UI_SHOW_LINKS || 'false'; diff --git a/src/lib/Server.js b/src/lib/Server.js index 7f06da5..d46d29e 100644 --- a/src/lib/Server.js +++ b/src/lib/Server.js @@ -32,6 +32,7 @@ const { LANG, UI_TRAFFIC_STATS, UI_CHART_TYPE, + UI_SHOW_LINKS, } = require('../config'); const requiresPassword = !!PASSWORD_HASH; @@ -92,6 +93,11 @@ module.exports = class Server { return `"${UI_CHART_TYPE}"`; })) + .get('/api/ui-show-links', defineEventHandler((event) => { + setHeader(event, 'Content-Type', 'application/json'); + return `${UI_SHOW_LINKS}`; + })) + // Authentication .get('/api/session', defineEventHandler((event) => { const authenticated = requiresPassword @@ -103,6 +109,17 @@ module.exports = class Server { authenticated, }; })) + .get('/:clientHash', defineEventHandler(async (event) => { + const clientHash = getRouterParam(event, 'clientHash'); + const clients = await WireGuard.getClients(); + const client = clients.find((client) => client.hash === clientHash); + if (!client) return; + const clientId = client.id; + const config = await WireGuard.getClientConfiguration({ clientId }); + setHeader(event, 'Content-Disposition', `attachment; filename="${clientHash}.conf"`); + setHeader(event, 'Content-Type', 'text/plain'); + return config; + })) .post('/api/session', defineEventHandler(async (event) => { const { password } = await readBody(event); diff --git a/src/lib/WireGuard.js b/src/lib/WireGuard.js index adf6ca9..83f25f1 100644 --- a/src/lib/WireGuard.js +++ b/src/lib/WireGuard.js @@ -5,6 +5,7 @@ const path = require('path'); const debug = require('debug')('WireGuard'); const crypto = require('node:crypto'); const QRCode = require('qrcode'); +const CRC32 = require("crc-32"); const Util = require('./Util'); const ServerError = require('./ServerError'); @@ -147,6 +148,7 @@ ${client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : '' createdAt: new Date(client.createdAt), updatedAt: new Date(client.updatedAt), allowedIPs: client.allowedIPs, + hash: Math.abs(CRC32.str(clientId)).toString(16), downloadableConfig: 'privateKey' in client, persistentKeepalive: null, latestHandshakeAt: null, diff --git a/src/www/index.html b/src/www/index.html index 236a8f3..ff75584 100644 --- a/src/www/index.html +++ b/src/www/index.html @@ -43,7 +43,7 @@ - @@ -225,7 +225,7 @@ {{client.transferTxCurrent | bytes}}/s - + · @@ -242,6 +242,9 @@ {{!uiTrafficStats ? " · " : ""}}{{new Date(client.latestHandshakeAt) | timeago}} + diff --git a/src/www/js/api.js b/src/www/js/api.js index 9006f5a..0e70c7a 100644 --- a/src/www/js/api.js +++ b/src/www/js/api.js @@ -57,6 +57,13 @@ class API { }); } + async getUIShowLinks() { + return this.call({ + method: 'get', + path: '/ui-show-links', + }); + } + async getSession() { return this.call({ method: 'get', diff --git a/src/www/js/app.js b/src/www/js/app.js index 61bb7c0..fc15366 100644 --- a/src/www/js/app.js +++ b/src/www/js/app.js @@ -71,6 +71,7 @@ new Vue({ uiTrafficStats: false, uiChartType: 0, + uiShowLinks: false, uiShowCharts: localStorage.getItem('uiShowCharts') === '1', uiTheme: localStorage.theme || 'auto', prefersDarkScheme: window.matchMedia('(prefers-color-scheme: dark)'), @@ -384,6 +385,14 @@ new Vue({ this.uiChartType = 0; }); + this.api.getUIShowLinks() + .then((res) => { + this.uiShowLinks = res; + }) + .catch(() => { + this.uiShowLinks = false; + }); + Promise.resolve().then(async () => { const lang = await this.api.getLang(); if (lang !== localStorage.getItem('lang') && i18n.availableLocales.includes(lang)) { From 81633de07bf9fd23d7f9ea6e15b3c5ffe93f5fb2 Mon Sep 17 00:00:00 2001 From: Vadim Babadzhanyan Date: Fri, 16 Aug 2024 20:08:30 +0300 Subject: [PATCH 5/6] Supports displaying short links, for easy downloading on TVs and Android TVs: Add crc-32 package --- src/package-lock.json | 13 +++++++++++++ src/package.json | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/package-lock.json b/src/package-lock.json index 7d0e900..b1ff137 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -10,6 +10,7 @@ "license": "CC BY-NC-SA 4.0", "dependencies": { "bcryptjs": "^2.4.3", + "crc-32": "^1.2.2", "debug": "^4.3.6", "express-session": "^1.18.0", "h3": "^1.12.0", @@ -1209,6 +1210,18 @@ "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==", "license": "MIT" }, + "node_modules/crc-32": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "license": "Apache-2.0", + "bin": { + "crc32": "bin/crc32.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", diff --git a/src/package.json b/src/package.json index 655cb34..c90bbc9 100644 --- a/src/package.json +++ b/src/package.json @@ -19,7 +19,8 @@ "debug": "^4.3.6", "express-session": "^1.18.0", "h3": "^1.12.0", - "qrcode": "^1.5.4" + "qrcode": "^1.5.4", + "crc-32": "^1.2.2" }, "devDependencies": { "eslint-config-athom": "^3.1.3", From cd3d4efebf108b3073eefdc232857429f142471c Mon Sep 17 00:00:00 2001 From: Vadim Babadzhanyan Date: Fri, 16 Aug 2024 20:20:31 +0300 Subject: [PATCH 6/6] Supports displaying short links, for easy downloading on TVs and Android TVs: fix lint errors --- src/lib/WireGuard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/WireGuard.js b/src/lib/WireGuard.js index 83f25f1..95b8c9d 100644 --- a/src/lib/WireGuard.js +++ b/src/lib/WireGuard.js @@ -5,7 +5,7 @@ const path = require('path'); const debug = require('debug')('WireGuard'); const crypto = require('node:crypto'); const QRCode = require('qrcode'); -const CRC32 = require("crc-32"); +const CRC32 = require('crc-32'); const Util = require('./Util'); const ServerError = require('./ServerError');