Browse Source

parse protocol with slash in the beginning

develop
ray-1337 3 years ago
parent
commit
d001bc57ac
  1. 2
      src/methods/allow.js
  2. 2
      src/methods/deny.js

2
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"'); 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.stderr) throw new Error(res.stderr);
if (res.stdout) { if (res.stdout) {

2
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"'); 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.stderr) throw new Error(res.stderr);
if (res.stdout) { if (res.stdout) {

Loading…
Cancel
Save