From 985d8863620e700ba67813fd5fa4a01a1b845c55 Mon Sep 17 00:00:00 2001 From: Emile Nijssen Date: Tue, 13 Jul 2021 21:00:40 +0200 Subject: [PATCH] make WG_DEFAULT_DNS optional, fixes #40 --- README.md | 6 +++++- src/config.js | 4 +++- src/lib/WireGuard.js | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b59ce33..63c0469 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,16 @@ You have found the easiest way to install & manage WireGuard on any Linux host! * All-in-one: WireGuard + Web UI. * Easy installation, simple to use. -* List, create, delete, enable & disable clients. +* List, create, edit, delete, enable & disable clients. * Show a client's QR code. * Download a client's configuration file. * Statistics for which clients are connected. * Gravatar support. +## Requirements + +* A host with a kernel that supports WireGuard (all modern kernels). + ## Installation ### 1. Install Docker diff --git a/src/config.js b/src/config.js index cade67f..8412344 100644 --- a/src/config.js +++ b/src/config.js @@ -6,5 +6,7 @@ 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_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'; +module.exports.WG_DEFAULT_DNS = typeof process.env.WG_DEFAULT_DNS === 'string' + ? process.env.WG_DEFAULT_DNS + : '1.1.1.1'; module.exports.WG_ALLOWED_IPS = process.env.WG_ALLOWED_IPS || '0.0.0.0/0, ::/0'; diff --git a/src/lib/WireGuard.js b/src/lib/WireGuard.js index 53f11ad..565cd3e 100644 --- a/src/lib/WireGuard.js +++ b/src/lib/WireGuard.js @@ -51,6 +51,7 @@ module.exports = class WireGuard { } await this.__saveConfig(config); + await Util.exec('wg-quick down wg0').catch(() => {}); await Util.exec('wg-quick up wg0'); await Util.exec(`iptables -t nat -A POSTROUTING -s ${WG_DEFAULT_ADDRESS.replace('x', '0')}/24 -o eth0 -j MASQUERADE`); await Util.exec('iptables -A INPUT -p udp -m udp --dport 51820 -j ACCEPT'); @@ -174,7 +175,7 @@ AllowedIPs = ${client.address}/32`; [Interface] PrivateKey = ${client.privateKey} Address = ${client.address}/24 -DNS = ${WG_DEFAULT_DNS} +${WG_DEFAULT_DNS ? `DNS = ${WG_DEFAULT_DNS}` : ''} [Peer] PublicKey = ${config.server.publicKey}