mirror of
https://github.com/dockur/proxmox.git
synced 2026-07-27 16:54:51 +07:00
feat: Improve iptables rule cleanup (#86)
This commit is contained in:
+9
-3
@@ -576,7 +576,7 @@ clearTables() {
|
||||
local table=""
|
||||
local line=""
|
||||
local rules=""
|
||||
local args=()
|
||||
local failed="N"
|
||||
local rule_tag="remove"
|
||||
local re="--comment[[:space:]]+\"?$rule_tag\"?([[:space:]]|\$)"
|
||||
|
||||
@@ -598,12 +598,18 @@ clearTables() {
|
||||
esac
|
||||
|
||||
if [[ "$line" == -A* ]] && [[ "$line" =~ $re ]]; then
|
||||
read -ra args <<< "${line/-A /-D }"
|
||||
iptables -t "$table" "${args[@]}" > /dev/null 2>&1 || :
|
||||
line="${line/-A /-D }"
|
||||
|
||||
# Parse the quoting produced by iptables-save before deleting the rule.
|
||||
if ! printf '%s\n' "$line" |
|
||||
xargs -r iptables -t "$table" > /dev/null 2>&1; then
|
||||
failed="Y"
|
||||
fi
|
||||
fi
|
||||
|
||||
done <<< "$rules"
|
||||
|
||||
enabled "$failed" && return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user