diff --git a/src/methods/allow.js b/src/methods/allow.js index d195c24..403ba6e 100644 --- a/src/methods/allow.js +++ b/src/methods/allow.js @@ -59,9 +59,11 @@ module.exports.address = async function (address, port, protocol) { if (!checkAddress) return false; // port validation - if (typeof port !== "number") throw new Error("The port must be type of number."); - let checkPort = util.checkAppropriatePort(port); - if (!checkPort) return false; + if (port) { + if (typeof port !== "number") throw new Error("The port must be type of number."); + let checkPort = util.checkAppropriatePort(port); + if (!checkPort) return false; + }; // protocol (tcp/udp) validation if (protocol) { diff --git a/src/methods/deny.js b/src/methods/deny.js index 219c61c..3cee983 100644 --- a/src/methods/deny.js +++ b/src/methods/deny.js @@ -59,9 +59,11 @@ module.exports.address = async function (address, port, protocol) { if (!checkAddress) return false; // port validation - if (typeof port !== "number") throw new Error("The port must be type of number."); - let checkPort = util.checkAppropriatePort(port); - if (!checkPort) return false; + if (port) { + if (typeof port !== "number") throw new Error("The port must be type of number."); + let checkPort = util.checkAppropriatePort(port); + if (!checkPort) return false; + }; // protocol (tcp/udp) validation if (protocol) {