make WG_DEFAULT_DNS optional, fixes #40

This commit is contained in:
Emile Nijssen 2021-07-13 21:00:40 +02:00
parent 016382dd01
commit 985d886362
3 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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';

View File

@ -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}