mirror of
https://github.com/dockur/proxmox.git
synced 2026-07-27 16:54:51 +07:00
feat: Suppress empty iptables debug sections (#90)
This commit is contained in:
+23
-13
@@ -474,18 +474,37 @@ createTap() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showRules() {
|
||||||
|
|
||||||
|
local table="$1"
|
||||||
|
local chain="$2"
|
||||||
|
local label="$3"
|
||||||
|
local rules=""
|
||||||
|
|
||||||
|
rules=$(iptables -t "$table" -S "$chain" 2>/dev/null |
|
||||||
|
awk '$1 == "-A"' || true)
|
||||||
|
|
||||||
|
[ -n "$rules" ] || return 0
|
||||||
|
|
||||||
|
printf "Existing %s rules:\n\n%s\n\n" "$label" "$rules"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
checkExistingTables() {
|
checkExistingTables() {
|
||||||
|
|
||||||
|
local msg=""
|
||||||
local rules=""
|
local rules=""
|
||||||
local conflicts=""
|
local conflicts=""
|
||||||
|
|
||||||
rules=$(iptables -t filter -S FORWARD 2>/dev/null || true)
|
rules=$(iptables -t filter -S FORWARD 2>/dev/null |
|
||||||
|
awk '$1 == "-A"' || true)
|
||||||
|
|
||||||
conflicts=$(grep -E -- \
|
conflicts=$(grep -E -- \
|
||||||
'^-A FORWARD .*(-j DROP|-j REJECT)( |$)' \
|
'^-A FORWARD .*(-j DROP|-j REJECT)( |$)' \
|
||||||
<<< "$rules" || true)
|
<<< "$rules" || true)
|
||||||
|
|
||||||
if [ -n "$conflicts" ]; then
|
if [ -n "$conflicts" ]; then
|
||||||
local msg="existing firewall rules may block traffic forwarded to or from the VM subnet"
|
msg="your existing firewall rules may block traffic forwarded to or from the VM subnet"
|
||||||
|
|
||||||
if enabled "$DEBUG"; then
|
if enabled "$DEBUG"; then
|
||||||
warn "${msg}."
|
warn "${msg}."
|
||||||
@@ -494,18 +513,9 @@ checkExistingTables() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if enabled "$DEBUG" && [ -n "$rules" ]; then
|
|
||||||
printf "Existing filter FORWARD rules:\n\n%s\n\n" "$rules"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if enabled "$DEBUG"; then
|
if enabled "$DEBUG"; then
|
||||||
|
showRules filter FORWARD "filter FORWARD"
|
||||||
rules=$(iptables -t nat -S POSTROUTING 2>/dev/null || true)
|
showRules nat POSTROUTING "NAT POSTROUTING"
|
||||||
|
|
||||||
if [ -n "$rules" ]; then
|
|
||||||
printf "Existing NAT POSTROUTING rules:\n\n%s\n\n" "$rules"
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user