Skip to content

Commit

Permalink
Fix get firewall status
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Feb 16, 2024
1 parent 61121e3 commit daef953
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/controllers/iptables.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ export default function () {
router.get('/show', async function (req, res, next) {
try {
const p = await executor.getParsed();
const user = req.body.user.toString();
if (user) {
if (user.match(/[^\w.-]/)) {
throw new Error("invalid username");
}
const id = shelljs.exec("id -u " + user).stdout.trim();
return res.json(executor.getByUser(p, user, id));
}
res.json(p);
} catch (error) {
next(error);
Expand All @@ -21,7 +29,7 @@ export default function () {
try {
const user = req.body.user.toString();
if (user.match(/[^\w.-]/)) {
throw new Error();
throw new Error("invalid username");
}
const id = shelljs.exec("id -u " + user).stdout.trim();
res.json(await executor.setAddUser(user, id));
Expand All @@ -33,7 +41,7 @@ export default function () {
try {
const user = req.body.user.toString();
if (user.match(/[^\w.-]/)) {
throw new Error();
throw new Error("invalid username");
}
const id = shelljs.exec("id -u " + user).stdout.trim();
res.json(await executor.setDelUser(user, id));
Expand Down

0 comments on commit daef953

Please sign in to comment.