From d001bc57acd4f0b2ede40daa78424d99367a8ecf Mon Sep 17 00:00:00 2001 From: ray-1337 <33544674+ray-1337@users.noreply.github.com> Date: Mon, 11 Apr 2022 21:35:41 +0200 Subject: [PATCH] parse protocol with slash in the beginning --- src/methods/allow.js | 2 +- src/methods/deny.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/methods/allow.js b/src/methods/allow.js index d714395..ba725d0 100644 --- a/src/methods/allow.js +++ b/src/methods/allow.js @@ -17,7 +17,7 @@ module.exports.port = async function (port, protocol) { if (protocol !== "tcp" || protocol !== "udp") throw new Error('The protocol must be either "tcp" or "udp"'); }; - let res = await promisifiedExec(`echo "y" | sudo ufw allow ${port} ${protocol || ""}`); + let res = await promisifiedExec(`echo "y" | sudo ufw allow ${port}${protocol ? `/${protocol}` : ""}`); if (res.stderr) throw new Error(res.stderr); if (res.stdout) { diff --git a/src/methods/deny.js b/src/methods/deny.js index 261f27e..f651923 100644 --- a/src/methods/deny.js +++ b/src/methods/deny.js @@ -17,7 +17,7 @@ module.exports.port = async function (port, protocol) { if (protocol !== "tcp" || protocol !== "udp") throw new Error('The protocol must be either "tcp" or "udp"'); }; - let res = await promisifiedExec(`echo "y" | sudo ufw deny ${port} ${protocol || ""}`); + let res = await promisifiedExec(`echo "y" | sudo ufw deny ${port}${protocol ? `/${protocol}` : ""}`); if (res.stderr) throw new Error(res.stderr); if (res.stdout) {