From 566e3d153697212af5c905ff07195313c46f3f5b Mon Sep 17 00:00:00 2001 From: bol-van Date: Sat, 1 Jan 2022 10:42:38 +0300 Subject: [PATCH] init: MODE_OVERRIDE to allow code reuse from custom scripts --- init.d/macos/functions | 4 ++-- init.d/openwrt/functions | 2 +- init.d/openwrt/zapret | 2 +- init.d/sysv/functions | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/init.d/macos/functions b/init.d/macos/functions index bca60a9..01f5bfd 100644 --- a/init.d/macos/functions +++ b/init.d/macos/functions @@ -395,7 +395,7 @@ zapret_do_firewall() { # $1 - 1 - add, 0 - del - case "${MODE}" in + case "${MODE_OVERRIDE:-$MODE}" in tpws|filter|custom) if [ "$1" = "1" ] ; then pf_anchor_root || return 1 @@ -438,7 +438,7 @@ zapret_do_daemons() local opt - case "${MODE}" in + case "${MODE_OVERRIDE:-$MODE}" in tpws) [ "$1" = "1" ] && [ "$DISABLE_IPV4" = "1" ] && [ "$DISABLE_IPV6" = "1" ] && { echo "both ipv4 and ipv6 are disabled. nothing to do" diff --git a/init.d/openwrt/functions b/init.d/openwrt/functions index 2108ffa..89fa44c 100644 --- a/init.d/openwrt/functions +++ b/init.d/openwrt/functions @@ -457,7 +457,7 @@ zapret_apply_firewall() # always create ipsets. ip_exclude ipset is required create_ipset no-update - case "${MODE}" in + case "${MODE_OVERRIDE:-$MODE}" in tpws) if [ ! "$MODE_HTTP" = "1" ] && [ ! "$MODE_HTTPS" = "1" ]; then echo both http and https are disabled. not applying redirection. diff --git a/init.d/openwrt/zapret b/init.d/openwrt/zapret index 232ee59..75494cd 100755 --- a/init.d/openwrt/zapret +++ b/init.d/openwrt/zapret @@ -107,7 +107,7 @@ tpws_apply_socks_binds() start_service() { local opt qn qns qn6 qns6 - case "${MODE}" in + case "${MODE_OVERRIDE:-$MODE}" in tpws) opt="--port=$TPPORT $TPWS_OPT" filter_apply_hostlist_target opt diff --git a/init.d/sysv/functions b/init.d/sysv/functions index 0890d5b..85f79db 100644 --- a/init.d/sysv/functions +++ b/init.d/sysv/functions @@ -630,7 +630,7 @@ zapret_do_firewall() # always create ipsets. ip_exclude ipset is required [ "$1" != "1" ] || create_ipset no-update - case "${MODE}" in + case "${MODE_OVERRIDE:-$MODE}" in tpws) if [ ! "$MODE_HTTP" = "1" ] && [ ! "$MODE_HTTPS" = "1" ]; then echo both http and https are disabled. not applying redirection. @@ -708,7 +708,7 @@ zapret_do_daemons() local opt qn qns qn6 qns6 - case "${MODE}" in + case "${MODE_OVERRIDE:-$MODE}" in tpws) opt="--port=$TPPORT $TPWS_OPT" filter_apply_hostlist_target opt