2021-03-04 16:30:38 +05:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
ZAPRET=/etc/init.d/zapret
|
2021-09-29 16:09:53 +05:00
|
|
|
|
2022-02-23 15:06:34 +05:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-15 19:15:36 +05:00
|
|
|
[ -n "$INTERFACE" -a -n "$ACTION" -a -x "$ZAPRET" ] && "$ZAPRET" enabled && {
|
2021-12-28 13:59:50 +05:00
|
|
|
SCRIPT=$(readlink "$ZAPRET")
|
|
|
|
if [ -n "$SCRIPT" ]; then
|
|
|
|
EXEDIR=$(dirname "$SCRIPT")
|
|
|
|
ZAPRET_BASE=$(readlink -f "$EXEDIR/../..")
|
|
|
|
else
|
|
|
|
ZAPRET_BASE=/opt/zapret
|
|
|
|
fi
|
2021-09-29 16:09:53 +05:00
|
|
|
. "$ZAPRET_BASE/config"
|
2022-02-23 15:06:34 +05:00
|
|
|
|
|
|
|
check_need_to_reload_tpws6
|
|
|
|
[ -n "$RELOAD_TPWS6" ] && {
|
|
|
|
logger -t zapret restarting daemons due to $ACTION of $INTERFACE to update tpws6 dnat target
|
|
|
|
"$ZAPRET" restart_daemons
|
2022-02-15 19:15:36 +05:00
|
|
|
}
|
|
|
|
. "$ZAPRET_BASE/common/base.sh"
|
|
|
|
. "$ZAPRET_BASE/common/fwtype.sh"
|
|
|
|
linux_fwtype
|
|
|
|
case "$FWTYPE" in
|
|
|
|
nftables)
|
2022-02-23 15:06:34 +05:00
|
|
|
if [ -n "$RELOAD_TPWS6" ] ; then
|
|
|
|
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
|
2022-02-15 19:15:36 +05:00
|
|
|
;;
|
|
|
|
iptables)
|
|
|
|
openwrt_fw3 || {
|
|
|
|
logger -t zapret reloading iptables due to $ACTION of $INTERFACE
|
|
|
|
"$ZAPRET" restart_fw
|
|
|
|
}
|
|
|
|
;;
|
|
|
|
esac
|
2021-03-04 16:30:38 +05:00
|
|
|
}
|