2022-07-27 16:35:05 +03:00
|
|
|
find_hostlists()
|
|
|
|
{
|
|
|
|
[ -n "$HOSTLIST_BASE" ] || HOSTLIST_BASE="$ZAPRET_BASE/ipset"
|
|
|
|
|
|
|
|
HOSTLIST="$HOSTLIST_BASE/zapret-hosts.txt.gz"
|
|
|
|
[ -f "$HOSTLIST" ] || HOSTLIST="$HOSTLIST_BASE/zapret-hosts.txt"
|
|
|
|
[ -f "$HOSTLIST" ] || HOSTLIST=
|
|
|
|
|
|
|
|
HOSTLIST_USER="$HOSTLIST_BASE/zapret-hosts-user.txt.gz"
|
|
|
|
[ -f "$HOSTLIST_USER" ] || HOSTLIST_USER="$HOSTLIST_BASE/zapret-hosts-user.txt"
|
|
|
|
[ -f "$HOSTLIST_USER" ] || HOSTLIST_USER=
|
|
|
|
|
|
|
|
HOSTLIST_EXCLUDE="$HOSTLIST_BASE/zapret-hosts-user-exclude.txt.gz"
|
|
|
|
[ -f "$HOSTLIST_EXCLUDE" ] || HOSTLIST_EXCLUDE="$HOSTLIST_BASE/zapret-hosts-user-exclude.txt"
|
|
|
|
[ -f "$HOSTLIST_EXCLUDE" ] || HOSTLIST_EXCLUDE=
|
2023-10-26 15:12:32 +03:00
|
|
|
|
|
|
|
HOSTLIST_AUTO="$HOSTLIST_BASE/zapret-hosts-auto.txt"
|
2023-11-09 12:08:09 +03:00
|
|
|
HOSTLIST_AUTO_DEBUGLOG="$HOSTLIST_BASE/zapret-hosts-auto-debug.log"
|
2022-07-27 16:35:05 +03:00
|
|
|
}
|
|
|
|
|
2023-10-26 15:44:04 +03:00
|
|
|
filter_apply_autohostlist_target()
|
|
|
|
{
|
|
|
|
# $1 - var name of tpws or nfqws params
|
|
|
|
|
|
|
|
local parm1="${AUTOHOSTLIST_FAIL_THRESHOLD:+--hostlist-auto-fail-threshold=$AUTOHOSTLIST_FAIL_THRESHOLD}"
|
|
|
|
local parm2="${AUTOHOSTLIST_FAIL_TIME:+--hostlist-auto-fail-time=$AUTOHOSTLIST_FAIL_TIME}"
|
2023-11-09 12:08:09 +03:00
|
|
|
local parm3 parm4
|
2023-10-26 15:44:04 +03:00
|
|
|
[ "$MODE" = "tpws" -o "$MODE" = "tpws-socks" ] || parm3="${AUTOHOSTLIST_RETRANS_THRESHOLD:+--hostlist-auto-retrans-threshold=$AUTOHOSTLIST_RETRANS_THRESHOLD}"
|
2023-11-09 12:08:09 +03:00
|
|
|
[ "$AUTOHOSTLIST_DEBUGLOG" = 1 ] && parm4="--hostlist-auto-debug=$HOSTLIST_AUTO_DEBUGLOG"
|
|
|
|
eval $1="\"\$$1 --hostlist-auto=$HOSTLIST_AUTO $parm1 $parm2 $parm3 $parm4\""
|
2023-10-26 15:44:04 +03:00
|
|
|
}
|
|
|
|
|
2022-07-27 16:35:05 +03:00
|
|
|
filter_apply_hostlist_target()
|
|
|
|
{
|
|
|
|
# $1 - var name of tpws or nfqws params
|
|
|
|
|
2023-10-26 15:12:32 +03:00
|
|
|
[ "$MODE_FILTER" = "hostlist" -o "$MODE_FILTER" = "autohostlist" ] || return
|
2022-07-27 16:35:05 +03:00
|
|
|
|
|
|
|
local HOSTLIST_BASE HOSTLIST HOSTLIST_USER HOSTLIST_EXCLUDE
|
|
|
|
|
|
|
|
find_hostlists
|
|
|
|
|
|
|
|
[ -n "$HOSTLIST" ] && eval $1="\"\$$1 --hostlist=$HOSTLIST\""
|
|
|
|
[ -n "$HOSTLIST_USER" ] && eval $1="\"\$$1 --hostlist=$HOSTLIST_USER\""
|
|
|
|
[ -n "$HOSTLIST_EXCLUDE" ] && eval $1="\"\$$1 --hostlist-exclude=$HOSTLIST_EXCLUDE\""
|
2023-10-26 15:44:04 +03:00
|
|
|
[ "$MODE_FILTER" = "autohostlist" ] && filter_apply_autohostlist_target $1
|
2022-07-27 16:35:05 +03:00
|
|
|
}
|
2024-09-18 19:27:50 +03:00
|
|
|
|
|
|
|
filter_apply_suffix()
|
|
|
|
{
|
|
|
|
# $1 - var name of tpws or nfqws params
|
|
|
|
# $2 - suffix value
|
|
|
|
local v="${2:+ --new $2}"
|
|
|
|
eval $1="\"\$$1$v\""
|
|
|
|
}
|