Browse Source

fix: lint

pull/1210/head
tetuaoro 2 years ago
parent
commit
9819362c63
  1. 13
      src/lib/Firewall.js

13
src/lib/Firewall.js

@ -163,25 +163,32 @@ module.exports = class Firewall {
throw new Error('Invalid target or protocol.'); throw new Error('Invalid target or protocol.');
} }
<<<<<<< HEAD
// If empty source or destination // If empty source or destination
if (!source || !destination) { if (!source || !destination) {
throw new Error('Invalid source or destination address.') throw new Error('Invalid source or destination address.')
>>>>>>> a20e416 (fix: source & destination are required) >>>>>>> a20e416 (fix: source & destination are required)
} }
=======
>>>>>>> 48f8be5 (fix: lint)
/* /*
Support command : 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}`; 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}`; 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}`; iptablesCommand += ` -d ${destination}`;
} else {
throw new Error('Invalid destination address.');
} }
iptablesCommand += ` -p ${protocol} -j ${target}`; iptablesCommand += ` -p ${protocol} -j ${target}`;

Loading…
Cancel
Save