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) {