From b4fbcdd2db5e123c6b7f4e076a6baa6d69af3c18 Mon Sep 17 00:00:00 2001 From: DerDanilo Date: Sun, 26 Dec 2021 14:08:41 +0100 Subject: [PATCH 01/13] add optional client profile MTU var --- README.md | 1 + docker-compose.yml | 1 + src/config.js | 1 + src/lib/WireGuard.js | 4 ++++ 4 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 02c2517..8619f22 100644 --- a/README.md +++ b/README.md @@ -73,5 +73,6 @@ These options can be configured in `docker-compose.yml` under `environment`. | `WG_PORT` | `51820` | `51820` | The public UDP port of your VPN server | | `WG_DEFAULT_ADDRESS` | `10.8.0.x` | `10.6.0.x` | Clients IP address range | | `WG_DEFAULT_DNS` | `1.1.1.1` | `8.8.8.8, 8.8.4.4` | DNS server clients will use | +| `WG_MTU` | `null` | `1420` | The MTU the clients will use. (Server uses default WG MTU) | > If you change `WG_PORT`, make sure to also change the exposed port. diff --git a/docker-compose.yml b/docker-compose.yml index 4a49fe0..23d4c17 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,7 @@ services: # - WG_PORT=51820 # - WG_DEFAULT_ADDRESS=10.8.0.x # - WG_DEFAULT_DNS=1.1.1.1 + # - WG_MTU=1420 image: weejewel/wg-easy container_name: wg-easy diff --git a/src/config.js b/src/config.js index 0a7bf43..826b3b1 100644 --- a/src/config.js +++ b/src/config.js @@ -5,5 +5,6 @@ module.exports.PASSWORD = process.env.PASSWORD; module.exports.WG_PATH = process.env.WG_PATH || '/etc/wireguard/'; module.exports.WG_HOST = process.env.WG_HOST; module.exports.WG_PORT = process.env.WG_PORT || 51820; +module.exports.WG_MTU = process.env.WG_MTU || null; module.exports.WG_DEFAULT_ADDRESS = process.env.WG_DEFAULT_ADDRESS || '10.8.0.x'; module.exports.WG_DEFAULT_DNS = process.env.WG_DEFAULT_DNS || '1.1.1.1'; diff --git a/src/lib/WireGuard.js b/src/lib/WireGuard.js index 01ff330..5356ba9 100644 --- a/src/lib/WireGuard.js +++ b/src/lib/WireGuard.js @@ -14,6 +14,7 @@ const { WG_PATH, WG_HOST, WG_PORT, + WG_MTU, WG_DEFAULT_DNS, WG_DEFAULT_ADDRESS, } = require('../config'); @@ -174,6 +175,9 @@ AllowedIPs = ${client.address}/32`; PrivateKey = ${client.privateKey} Address = ${client.address}/24 DNS = ${WG_DEFAULT_DNS} +if (typeof ${WG_MTU} !== 'undefined' || ${WG_MTU} !== null) { +MTU = ${WG_MTU} +} [Peer] PublicKey = ${config.server.publicKey} From c6831a76fb7e1267a3bbc8095aaea4a3fb10a1f3 Mon Sep 17 00:00:00 2001 From: Emile Nijssen Date: Mon, 10 Jan 2022 22:28:18 -0800 Subject: [PATCH 02/13] fix eslint --- src/www/js/app.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/www/js/app.js b/src/www/js/app.js index df65975..137fb22 100644 --- a/src/www/js/app.js +++ b/src/www/js/app.js @@ -5,6 +5,24 @@ 'use strict'; +function bytes(bytes, decimals, kib, maxunit) { + kib = kib || false; + if (bytes === 0) return '0 B'; + if (Number.isNaN(parseFloat(bytes)) && !Number.isFinite(bytes)) return 'NaN'; + const k = kib ? 1024 : 1000; + const dm = decimals != null && !Number.isNaN(decimals) && decimals >= 0 ? decimals : 2; + const sizes = kib + ? ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB', 'BiB'] + : ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB', 'BB']; + let i = Math.floor(Math.log(bytes) / Math.log(k)); + if (maxunit !== undefined) { + const index = sizes.indexOf(maxunit); + if (index !== -1) i = index; + } + // eslint-disable-next-line no-restricted-properties + return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`; +} + new Vue({ el: '#app', components: { @@ -276,21 +294,3 @@ new Vue({ }).catch(console.error); }, }); - -function bytes(bytes, decimals, kib, maxunit) { - kib = kib || false; - if (bytes === 0) return '0 B'; - if (Number.isNaN(parseFloat(bytes)) && !Number.isFinite(bytes)) return 'NaN'; - const k = kib ? 1024 : 1000; - const dm = decimals != null && !Number.isNaN(decimals) && decimals >= 0 ? decimals : 2; - const sizes = kib - ? ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB', 'BiB'] - : ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB', 'BB']; - let i = Math.floor(Math.log(bytes) / Math.log(k)); - if (maxunit !== undefined) { - const index = sizes.indexOf(maxunit); - if (index !== -1) i = index; - } - // eslint-disable-next-line no-restricted-properties - return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`; -} From 72267b4d55c6ab360b7c2ec94f21f361c98eedd8 Mon Sep 17 00:00:00 2001 From: Emile Nijssen Date: Mon, 10 Jan 2022 22:28:24 -0800 Subject: [PATCH 03/13] use relative paths in front-end --- src/www/index.html | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/www/index.html b/src/www/index.html index d4d6521..4080c51 100644 --- a/src/www/index.html +++ b/src/www/index.html @@ -3,10 +3,10 @@ WireGuard - - - - + + + + @@ -200,7 +200,7 @@