refactor: order functions by dependency
This commit is contained in:
1 parent
a09a229b44
commit
4d5faafd0c
1 file changed
+26
-26
+26
-26
@@ -47,6 +47,32 @@ check_command_and_run() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_iptables() {
|
||||||
|
# -w is recent addition to iptables
|
||||||
|
if [ -z "$CHECKED_IPTABLES_W" ] ; then
|
||||||
|
if iptables -S -w >/dev/null 2>&1 ; then
|
||||||
|
IPTABLES_W=-w
|
||||||
|
fi
|
||||||
|
CHECKED_IPTABLES_W=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
iptables $IPTABLES_W "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 $IPTABLES_TABLE -A "$@" >/dev/null
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
add_nat_rule() {
|
||||||
|
add_iptables_rule nat "$@"
|
||||||
|
}
|
||||||
|
|
||||||
create_bridge() {
|
create_bridge() {
|
||||||
[ ! -d /sys/class/net/$BRIDGE ] && {
|
[ ! -d /sys/class/net/$BRIDGE ] && {
|
||||||
ip link add dev $BRIDGE type bridge
|
ip link add dev $BRIDGE type bridge
|
||||||
@@ -74,32 +100,6 @@ destroy_bridge() {
|
|||||||
run_iptables -t filter -D FORWARD -i weave -o weave -j ACCEPT 2>/dev/null || true
|
run_iptables -t filter -D FORWARD -i weave -o weave -j ACCEPT 2>/dev/null || true
|
||||||
}
|
}
|
||||||
|
|
||||||
run_iptables() {
|
|
||||||
# -w is recent addition to iptables
|
|
||||||
if [ -z "$CHECKED_IPTABLES_W" ] ; then
|
|
||||||
if iptables -S -w >/dev/null 2>&1 ; then
|
|
||||||
IPTABLES_W=-w
|
|
||||||
fi
|
|
||||||
CHECKED_IPTABLES_W=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
iptables $IPTABLES_W "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
# 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 $IPTABLES_TABLE -A "$@" >/dev/null
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
add_nat_rule() {
|
|
||||||
add_iptables_rule nat "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_masquerading() {
|
setup_masquerading() {
|
||||||
run_iptables -t nat -N WEAVE >/dev/null 2>&1 || true
|
run_iptables -t nat -N WEAVE >/dev/null 2>&1 || true
|
||||||
add_nat_rule POSTROUTING -j WEAVE
|
add_nat_rule POSTROUTING -j WEAVE
|
||||||
|
|||||||
Reference in new issue
Block a user