From 81418c813ec1085ecac31915f5c1e13de4188571 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Fri, 16 Feb 2024 09:07:44 +0700 Subject: [PATCH] Fix set record --- src/executor/iptables.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/executor/iptables.js b/src/executor/iptables.js index f7cee02..17468d6 100644 --- a/src/executor/iptables.js +++ b/src/executor/iptables.js @@ -1,8 +1,11 @@ -import { encodeIptablesDoc, genRules, parseIptablesDoc } from '../parsers/iptables.js'; +import { + appendIfRecordNotExist, + deleteIfRecordExist, + encodeIptablesDoc, + genRules, parseIptablesDoc +} from '../parsers/iptables.js'; import { cat, - appendIfNotExist, - deleteIfExist, executeLock, spawnSudoUtil, writeTo @@ -32,7 +35,7 @@ class IptablesExecutor { const rules = p.filter; const setRules = genRules(userName, userID); - if (!appendIfNotExist(rules, setRules)) { + if (!appendIfRecordNotExist(rules, setRules)) { return "Done unchanged for iptables"; } writeTo(tmpFile, encodeIptablesDoc(p)); @@ -45,7 +48,7 @@ class IptablesExecutor { const rules = p.filter; const setRules = genRules(userName, userID); - if (!appendIfNotExist(rules, setRules)) { + if (!appendIfRecordNotExist(rules, setRules)) { return "Done unchanged for iptables"; } writeTo(tmpFile6, encodeIptablesDoc(p)); @@ -61,7 +64,7 @@ class IptablesExecutor { const rules = p.filter; const setRules = genRules(userName, userID); - if (!deleteIfExist(rules, setRules)) { + if (!deleteIfRecordExist(rules, setRules)) { return "Done unchanged for iptables"; } writeTo(tmpFile, encodeIptablesDoc(p)); @@ -74,7 +77,7 @@ class IptablesExecutor { const rules = p.filter; const setRules = genRules(userName, userID); - if (!deleteIfExist(rules, setRules)) { + if (!deleteIfRecordExist(rules, setRules)) { return "Done unchanged for iptables"; } writeTo(tmpFile6, encodeIptablesDoc(p));