From 2a9a7eecac73d0a97672356f87a79a182acff356 Mon Sep 17 00:00:00 2001 From: Emile Nijssen Date: Mon, 10 Jan 2022 22:52:24 -0800 Subject: [PATCH] add helpful error message --- src/lib/WireGuard.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/WireGuard.js b/src/lib/WireGuard.js index c94fc18..3722273 100644 --- a/src/lib/WireGuard.js +++ b/src/lib/WireGuard.js @@ -55,7 +55,13 @@ 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('wg-quick up wg0').catch(err => { + if (err && err.message && err.message.includes('Cannot find device "wg0"')) { + throw new Error('WireGuard exited with the error: Cannot find device "wg0"\nThis usually means that your host\'s kernel does not support WireGuard!'); + } + + throw err; + }); 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'); await Util.exec('iptables -A FORWARD -i wg0 -j ACCEPT');