From 9819362c63676d277aefb93083609d63b4781c14 Mon Sep 17 00:00:00 2001 From: tetuaoro <65575727+tetuaoro@users.noreply.github.com> Date: Thu, 25 Jul 2024 16:29:53 +0200 Subject: [PATCH] fix: lint --- src/lib/Firewall.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lib/Firewall.js b/src/lib/Firewall.js index 41b51426..7c5aca38 100644 --- a/src/lib/Firewall.js +++ b/src/lib/Firewall.js @@ -163,25 +163,32 @@ module.exports = class Firewall { throw new Error('Invalid target or protocol.'); } +<<<<<<< HEAD // If empty source or destination if (!source || !destination) { throw new Error('Invalid source or destination address.') >>>>>>> a20e416 (fix: source & destination are required) } +======= +>>>>>>> 48f8be5 (fix: lint) /* Support command : - iptables -A CHAIN -s [IP | IP/CIDR] -d [IP | IP/CIDR] -p PROTOCOL -j TARGET + iptables -A CHAIN -s [IPv4 | IPv4/CIDR] -d [IPv4 | IPv4/CIDR] -p PROTOCOL -j TARGET */ let iptablesCommand = `iptables -A ${WG_IPT_CHAIN_NAME}`; - if (Util.isIPAddress(source) || Util.isCIDR(source)) { + if (source && (Util.isIPAddress(source) || Util.isCIDR(source))) { iptablesCommand += ` -s ${source}`; + } else { + throw new Error('Invalid source address.'); } - if (Util.isIPAddress(destination) || Util.isCIDR(destination)) { + if (destination && (Util.isIPAddress(destination) || Util.isCIDR(destination))) { iptablesCommand += ` -d ${destination}`; + } else { + throw new Error('Invalid destination address.'); } iptablesCommand += ` -p ${protocol} -j ${target}`;