Refactor add_nat_rule into add_iptables_rule that is more general
This commit is contained in:
1 parent
393b5cd459
commit
a31d8c4d80
1 file changed
+10
-3
+10
-3
@@ -82,13 +82,20 @@ run_iptables() {
|
||||
iptables $IPTABLES_W "$@"
|
||||
}
|
||||
|
||||
add_nat_rule() {
|
||||
if ! run_iptables -t nat -C "$@" >/dev/null 2>&1
|
||||
# Add a rule to iptables, if it doesn't exist already
|
||||
add_iptables_rule() {
|
||||
IPTABLES_TABLE="$1"
|
||||
shift 1
|
||||
if ! run_iptables -t $IPTABLES_TABLE -C "$@" >/dev/null 2>&1
|
||||
then
|
||||
run_iptables -t nat -A "$@" >/dev/null
|
||||
run_iptables -t $IPTABLES_TABLE -A "$@" >/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
add_nat_rule() {
|
||||
add_iptables_rule nat $@
|
||||
}
|
||||
|
||||
setup_masquerading() {
|
||||
run_iptables -t nat -N WEAVE >/dev/null 2>&1 || true
|
||||
add_nat_rule POSTROUTING -j WEAVE
|
||||
|
||||
Reference in new issue
Block a user