mirror of
https://github.com/bol-van/zapret.git
synced 2024-11-30 05:50:53 +03:00
init: openwrt optimize ifup/ifdown reloading
This commit is contained in:
parent
6b3d9153f8
commit
38a9db77a8
@ -2,6 +2,27 @@
|
|||||||
|
|
||||||
ZAPRET=/etc/init.d/zapret
|
ZAPRET=/etc/init.d/zapret
|
||||||
|
|
||||||
|
check_lan()
|
||||||
|
{
|
||||||
|
IS_LAN=
|
||||||
|
[ -n "$OPENWRT_LAN" ] || OPENWRT_LAN=lan
|
||||||
|
for lan in $OPENWRT_LAN; do
|
||||||
|
[ "$INTERFACE" = "$lan" ] && {
|
||||||
|
IS_LAN=1
|
||||||
|
break
|
||||||
|
}
|
||||||
|
done
|
||||||
|
}
|
||||||
|
check_need_to_reload_tpws6()
|
||||||
|
{
|
||||||
|
# tpws6 dnat target nft map can only be reloaded within firewall apply procedure
|
||||||
|
# interface ifsets (wanif, wanif6, lanif) can be reloaded independently
|
||||||
|
check_lan
|
||||||
|
RELOAD_TPWS6=
|
||||||
|
[ "$ACTION" = "ifup" -a "$DISABLE_IPV6" != 1 -a -n "$IS_LAN" ] && [ "$MODE" = "tpws" -o "$MODE" = "custom" ] && RELOAD_TPWS6=1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[ -n "$INTERFACE" -a -n "$ACTION" -a -x "$ZAPRET" ] && "$ZAPRET" enabled && {
|
[ -n "$INTERFACE" -a -n "$ACTION" -a -x "$ZAPRET" ] && "$ZAPRET" enabled && {
|
||||||
SCRIPT=$(readlink "$ZAPRET")
|
SCRIPT=$(readlink "$ZAPRET")
|
||||||
if [ -n "$SCRIPT" ]; then
|
if [ -n "$SCRIPT" ]; then
|
||||||
@ -11,23 +32,24 @@ ZAPRET=/etc/init.d/zapret
|
|||||||
ZAPRET_BASE=/opt/zapret
|
ZAPRET_BASE=/opt/zapret
|
||||||
fi
|
fi
|
||||||
. "$ZAPRET_BASE/config"
|
. "$ZAPRET_BASE/config"
|
||||||
[ "$ACTION" = "ifup" ] && {
|
|
||||||
[ -n "$OPENWRT_LAN" ] || OPENWRT_LAN=lan
|
check_need_to_reload_tpws6
|
||||||
for lan in $OPENWRT_LAN; do
|
[ -n "$RELOAD_TPWS6" ] && {
|
||||||
[ "$INTERFACE" = "$lan" ] && {
|
logger -t zapret restarting daemons due to $ACTION of $INTERFACE to update tpws6 dnat target
|
||||||
logger -t zapret restarting daemons due to $ACTION of $INTERFACE
|
"$ZAPRET" restart_daemons
|
||||||
"$ZAPRET" restart_daemons
|
|
||||||
break
|
|
||||||
}
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
. "$ZAPRET_BASE/common/base.sh"
|
. "$ZAPRET_BASE/common/base.sh"
|
||||||
. "$ZAPRET_BASE/common/fwtype.sh"
|
. "$ZAPRET_BASE/common/fwtype.sh"
|
||||||
linux_fwtype
|
linux_fwtype
|
||||||
case "$FWTYPE" in
|
case "$FWTYPE" in
|
||||||
nftables)
|
nftables)
|
||||||
logger -t zapret reloading nftables ifsets due to $ACTION of $INTERFACE
|
if [ -n "$RELOAD_TPWS6" ] ; then
|
||||||
"$ZAPRET" reload_ifsets
|
logger -t zapret reloading nftables due to $ACTION of $INTERFACE to update tpws6 dnat target
|
||||||
|
"$ZAPRET" restart_fw
|
||||||
|
else
|
||||||
|
logger -t zapret reloading nftables ifsets due to $ACTION of $INTERFACE
|
||||||
|
"$ZAPRET" reload_ifsets
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
iptables)
|
iptables)
|
||||||
openwrt_fw3 || {
|
openwrt_fw3 || {
|
||||||
|
Loading…
Reference in New Issue
Block a user