blockcheck: use defaults if BATCH=1

This commit is contained in:
bol-van 2025-01-03 14:40:02 +03:00
parent 5e84656707
commit 12a800db97
2 changed files with 57 additions and 37 deletions

View File

@ -23,7 +23,7 @@ CURL=${CURL:-curl}
. "$ZAPRET_BASE/common/fwtype.sh" . "$ZAPRET_BASE/common/fwtype.sh"
. "$ZAPRET_BASE/common/virt.sh" . "$ZAPRET_BASE/common/virt.sh"
DOMAINS_DEFAULT="rutracker.org" DOMAINS_DEFAULT=${DOMAINS_DEFAULT:-rutracker.org}
QNUM=${QNUM:-59780} QNUM=${QNUM:-59780}
SOCKS_PORT=${SOCKS_PORT:-1993} SOCKS_PORT=${SOCKS_PORT:-1993}
TPWS_UID=${TPWS_UID:-1} TPWS_UID=${TPWS_UID:-1}
@ -1733,18 +1733,22 @@ ask_params()
local dom local dom
[ -n "$DOMAINS" ] || { [ -n "$DOMAINS" ] || {
DOMAINS="$DOMAINS_DEFAULT" DOMAINS="$DOMAINS_DEFAULT"
[ "$BATCH" = 1 ] || {
echo "specify domain(s) to test. multiple domains are space separated." echo "specify domain(s) to test. multiple domains are space separated."
printf "domain(s) (default: $DOMAINS) : " printf "domain(s) (default: $DOMAINS) : "
read dom read dom
[ -n "$dom" ] && DOMAINS="$dom" [ -n "$dom" ] && DOMAINS="$dom"
} }
}
local IPVS_def=4 local IPVS_def=4
[ -n "$IPVS" ] || { [ -n "$IPVS" ] || {
# yandex public dns # yandex public dns
pingtest 6 2a02:6b8::feed:0ff && IPVS_def=46 pingtest 6 2a02:6b8::feed:0ff && IPVS_def=46
[ "$BATCH" = 1 ] || {
printf "ip protocol version(s) - 4, 6 or 46 for both (default: $IPVS_def) : " printf "ip protocol version(s) - 4, 6 or 46 for both (default: $IPVS_def) : "
read IPVS read IPVS
}
[ -n "$IPVS" ] || IPVS=$IPVS_def [ -n "$IPVS" ] || IPVS=$IPVS_def
[ "$IPVS" = 4 -o "$IPVS" = 6 -o "$IPVS" = 46 ] || { [ "$IPVS" = 4 -o "$IPVS" = 6 -o "$IPVS" = 46 ] || {
echo 'invalid ip version(s). should be 4, 6 or 46.' echo 'invalid ip version(s). should be 4, 6 or 46.'
@ -1757,48 +1761,60 @@ ask_params()
[ -n "$ENABLE_HTTP" ] || { [ -n "$ENABLE_HTTP" ] || {
ENABLE_HTTP=1 ENABLE_HTTP=1
[ "$BATCH" = 1 ] || {
echo echo
ask_yes_no_var ENABLE_HTTP "check http" ask_yes_no_var ENABLE_HTTP "check http"
} }
}
[ -n "$ENABLE_HTTPS_TLS12" ] || { [ -n "$ENABLE_HTTPS_TLS12" ] || {
ENABLE_HTTPS_TLS12=1 ENABLE_HTTPS_TLS12=1
[ "$BATCH" = 1 ] || {
echo echo
ask_yes_no_var ENABLE_HTTPS_TLS12 "check https tls 1.2" ask_yes_no_var ENABLE_HTTPS_TLS12 "check https tls 1.2"
} }
}
[ -n "$ENABLE_HTTPS_TLS13" ] || { [ -n "$ENABLE_HTTPS_TLS13" ] || {
ENABLE_HTTPS_TLS13=0 ENABLE_HTTPS_TLS13=0
echo
if [ -n "$TLS13" ]; then if [ -n "$TLS13" ]; then
[ "$BATCH" = 1 ] || {
echo
echo "TLS 1.3 uses encrypted ServerHello. DPI cannot check domain name in server response." echo "TLS 1.3 uses encrypted ServerHello. DPI cannot check domain name in server response."
echo "This can allow more bypass strategies to work." echo "This can allow more bypass strategies to work."
echo "What works for TLS 1.2 will also work for TLS 1.3 but not vice versa." echo "What works for TLS 1.2 will also work for TLS 1.3 but not vice versa."
echo "Most sites nowadays support TLS 1.3 but not all. If you can't find a strategy for TLS 1.2 use this test." echo "Most sites nowadays support TLS 1.3 but not all. If you can't find a strategy for TLS 1.2 use this test."
echo "TLS 1.3 only strategy is better than nothing." echo "TLS 1.3 only strategy is better than nothing."
ask_yes_no_var ENABLE_HTTPS_TLS13 "check https tls 1.3" ask_yes_no_var ENABLE_HTTPS_TLS13 "check https tls 1.3"
}
else else
echo
echo "installed curl version does not support TLS 1.3 . tests disabled." echo "installed curl version does not support TLS 1.3 . tests disabled."
fi fi
} }
[ -n "$ENABLE_HTTP3" ] || { [ -n "$ENABLE_HTTP3" ] || {
ENABLE_HTTP3=0 ENABLE_HTTP3=0
echo
if [ -n "$HTTP3" ]; then if [ -n "$HTTP3" ]; then
echo "make sure target domain(s) support QUIC or result will be negative in any case"
ENABLE_HTTP3=1 ENABLE_HTTP3=1
[ "$BATCH" = 1 ] || {
echo
echo "make sure target domain(s) support QUIC or result will be negative in any case"
ask_yes_no_var ENABLE_HTTP3 "check http3 QUIC" ask_yes_no_var ENABLE_HTTP3 "check http3 QUIC"
}
else else
echo
echo "installed curl version does not support http3 QUIC. tests disabled." echo "installed curl version does not support http3 QUIC. tests disabled."
fi fi
} }
[ -n "$REPEATS" ] || { [ -n "$REPEATS" ] || {
[ "$BATCH" = 1 ] || {
echo echo
echo "sometimes ISPs use multiple DPIs or load balancing. bypass strategies may work unstable." echo "sometimes ISPs use multiple DPIs or load balancing. bypass strategies may work unstable."
printf "how many times to repeat each test (default: 1) : " printf "how many times to repeat each test (default: 1) : "
read REPEATS read REPEATS
}
REPEATS=$((0+${REPEATS:-1})) REPEATS=$((0+${REPEATS:-1}))
[ "$REPEATS" = 0 ] && { [ "$REPEATS" = 0 ] && {
echo invalid repeat count echo invalid repeat count
@ -1806,23 +1822,27 @@ ask_params()
} }
} }
[ -z "$PARALLEL" -a $REPEATS -gt 1 ] && { [ -z "$PARALLEL" -a $REPEATS -gt 1 ] && {
PARALLEL=0
[ "$BATCH" = 1 ] || {
echo echo
echo "parallel scan can greatly increase speed but may also trigger DDoS protection and cause false result" echo "parallel scan can greatly increase speed but may also trigger DDoS protection and cause false result"
PARALLEL=0
ask_yes_no_var PARALLEL "enable parallel scan" ask_yes_no_var PARALLEL "enable parallel scan"
} }
}
PARALLEL=${PARALLEL:-0} PARALLEL=${PARALLEL:-0}
[ -n "$SCANLEVEL" ] || { [ -n "$SCANLEVEL" ] || {
SCANLEVEL=standard
[ "$BATCH" = 1 ] || {
echo echo
echo quick - scan as fast as possible to reveal any working strategy echo quick - scan as fast as possible to reveal any working strategy
echo standard - do investigation what works on your DPI echo standard - do investigation what works on your DPI
echo force - scan maximum despite of result echo force - scan maximum despite of result
SCANLEVEL=${SCANLEVEL:-standard}
ask_list SCANLEVEL "quick standard force" "$SCANLEVEL" ask_list SCANLEVEL "quick standard force" "$SCANLEVEL"
# disable tpws checks by default in quick mode # disable tpws checks by default in quick mode
[ "$SCANLEVEL" = quick -a -z "$SKIP_TPWS" -a "$UNAME" != Darwin ] && SKIP_TPWS=1 [ "$SCANLEVEL" = quick -a -z "$SKIP_TPWS" -a "$UNAME" != Darwin ] && SKIP_TPWS=1
} }
}
echo echo

View File

@ -1438,7 +1438,7 @@ ENABLE_HTTP3=0|1 - включить тест QUIC
REPEATS - количество попыток тестирования REPEATS - количество попыток тестирования
PARALLEL=0|1 - включить параллельные попытки. может обидеть сайт из-за долбежки и привести к неверному результату PARALLEL=0|1 - включить параллельные попытки. может обидеть сайт из-за долбежки и привести к неверному результату
SCANLEVEL=quick|standard|force - уровень сканирования SCANLEVEL=quick|standard|force - уровень сканирования
BATCH=1 - отключить "press enter to continue" BATCH=1 - пакетный режим без вопросов и ожидания ввода в консоли
HTTP_PORT, HTTPS_PORT, QUIC_PORT - номера портов для соответствующих протоколов HTTP_PORT, HTTPS_PORT, QUIC_PORT - номера портов для соответствующих протоколов
SKIP_DNSCHECK=1 - отказ от проверки DNS SKIP_DNSCHECK=1 - отказ от проверки DNS
SKIP_TPWS=1 - отказ от тестов tpws SKIP_TPWS=1 - отказ от тестов tpws