diff --git a/src/lib/Server.js b/src/lib/Server.js index 3a20ed02..7b64717b 100644 --- a/src/lib/Server.js +++ b/src/lib/Server.js @@ -62,7 +62,7 @@ module.exports = class Server { req.session.authenticated = true; req.session.save(); - console.log(`New Session: ${req.session.id})`); + debug(`New Session: ${req.session.id})`); })) // WireGuard @@ -84,7 +84,7 @@ module.exports = class Server { req.session.destroy(); - console.log(`Deleted Session: ${sessionId}`); + debug(`Deleted Session: ${sessionId}`); })) .get('/api/wireguard/hardened', Util.promisify(async req => { return WireGuard.areClientsHardened(); @@ -92,6 +92,9 @@ module.exports = class Server { .get('/api/wireguard/dns', Util.promisify(async req => { return WireGuard.getDns(); })) + .get('/api/wireguard/default-allowed-ips', Util.promisify(async req => { + return WireGuard.getDefaultAllowedIPs(); + })) .get('/api/wireguard/client', Util.promisify(async req => { return WireGuard.getClients(); })) @@ -138,7 +141,7 @@ module.exports = class Server { })) .listen(PORT, () => { - console.log(`Listening on http://0.0.0.0:${PORT}`); + debug(`Listening on http://0.0.0.0:${PORT}`); }); } diff --git a/src/lib/WireGuard.js b/src/lib/WireGuard.js index 853e7a51..8a1d13ba 100644 --- a/src/lib/WireGuard.js +++ b/src/lib/WireGuard.js @@ -33,12 +33,12 @@ module.exports = class WireGuard { throw new Error('WG_HOST Environment Variable Not Set!'); } - console.log('Loading configuration...'); + debug('Loading configuration...'); let config; try { config = await fs.readFile(path.join(WG_PATH, 'wg0.json'), 'utf8'); config = JSON.parse(config); - console.log('Configuration loaded.'); + debug('Configuration loaded.'); } catch (err) { const privateKey = await Util.exec('wg genkey'); const publicKey = await Util.exec(`echo ${privateKey} | wg pubkey`, privateKey); @@ -52,7 +52,7 @@ module.exports = class WireGuard { }, clients: {}, }; - console.log('Configuration generated.'); + debug('Configuration generated.'); } await this.__saveConfig(config); @@ -110,26 +110,30 @@ PresharedKey = ${client.preSharedKey} AllowedIPs = ${client.address}/32`; } - console.log('Config saving...'); + debug('Config saving...'); await fs.writeFile(path.join(WG_PATH, 'wg0.json'), JSON.stringify(config, false, 2), { mode: 0o660, }); await fs.writeFile(path.join(WG_PATH, 'wg0.conf'), result, { mode: 0o600, }); - console.log('Config saved.'); + debug('Config saved.'); } async __syncConfig() { - console.log('Config syncing...'); + debug('Config syncing...'); await Util.exec('wg syncconf wg0 <(wg-quick strip wg0)'); - console.log('Config synced.'); + debug('Config synced.'); } async getDns() { return WG_DEFAULT_DNS; } + async getDefaultAllowedIPs() { + return WG_ALLOWED_IPS; + } + async areClientsHardened() { return WG_HARDEN_CLIENTS; } diff --git a/src/www/index.html b/src/www/index.html index db81a176..0ee88f8f 100644 --- a/src/www/index.html +++ b/src/www/index.html @@ -54,7 +54,7 @@
Clients
There are no clients yet.
-