blockcheck: summary report

This commit is contained in:
bol-van 2021-12-25 12:22:47 +03:00
parent 9f5b44a021
commit b9e46f4b2d

View File

@ -197,6 +197,36 @@ check_prerequisites()
fi fi
} }
curl_translate_code()
{
# $1 - code
$ECHON $1
case $1 in
0) $ECHON ": ok"
;;
1) $ECHON ": unsupported protocol"
;;
2) $ECHON ": early initialization code failed"
;;
3) $ECHON ": the URL was not properly formatted"
;;
4) $ECHON ": feature not supported by libcurl"
;;
5) $ECHON ": could not resolve proxy"
;;
6) $ECHON ": could not resolve host"
;;
7) $ECHON ": could not connect"
;;
8) $ECHON ": invalid server reply"
;;
9) $ECHON ": remote access denied"
;;
27) $ECHON ": out of memory"
;;
esac
}
curl_supports_tls13() curl_supports_tls13()
{ {
curl --tlsv1.3 -Is -o /dev/null http://$LOCALHOST_IPT:65535 2>/dev/null curl --tlsv1.3 -Is -o /dev/null http://$LOCALHOST_IPT:65535 2>/dev/null
@ -426,18 +456,37 @@ tpws_curl_test_update()
xxxws_curl_test_update tpws_curl_test "$@" xxxws_curl_test_update tpws_curl_test "$@"
} }
report_append()
{
NREPORT=${NREPORT:-0}
eval REPORT_${NREPORT}=\"$@\"
NREPORT=$(($NREPORT+1))
}
report_print()
{
local n=0 s
NREPORT=${NREPORT:-0}
while [ $n -lt $NREPORT ]; do
eval s=\"\${REPORT_$n}\"
echo $s
n=$(($n+1))
done
}
report_strategy() report_strategy()
{ {
# $1 - domain # $1 - test function
# $2 - daemon # $2 - domain
# $3 - daemon
echo echo
if [ -n "$strategy" ]; then if [ -n "$strategy" ]; then
echo "!!!!! working strategy found for ipv${IPV} $1 : $2 $strategy !!!!!" echo "!!!!! $1: working strategy found for ipv${IPV} $2 : $3 $strategy !!!!!"
echo echo
report_append "ipv${IPV} $2 $1 : $3 $strategy"
return 0 return 0
else else
echo "strategy for ipv${IPV} $1 not found" echo "$1: $3 strategy for ipv${IPV} $2 not found"
echo echo
report_append "ipv${IPV} $2 $1 : $3 not working"
return 1 return 1
fi fi
} }
@ -492,7 +541,7 @@ pktws_check_domain_bypass()
# do not do wssize test for http. it's useless # do not do wssize test for http. it's useless
[ "$sec" = 1 ] || break [ "$sec" = 1 ] || break
done done
report_strategy $3 $PKTWSD report_strategy $1 $3 $PKTWSD
} }
tpws_check_domain_bypass() tpws_check_domain_bypass()
{ {
@ -512,7 +561,7 @@ tpws_check_domain_bypass()
tpws_curl_test_update $1 $3 $s && break tpws_curl_test_update $1 $3 $s && break
done done
fi fi
report_strategy $3 tpws report_strategy $1 $3 tpws
} }
check_domain() check_domain()
@ -533,10 +582,16 @@ check_domain()
ws_kill ws_kill
echo "- checking without DPI bypass" echo "- checking without DPI bypass"
curl_test $1 $4 && return curl_test $1 $4 && {
report_append "ipv${IPV} $4 $1 : working without bypass"
return
}
code=$? code=$?
for c in 1 2 3 4 6 27 ; do for c in 1 2 3 4 6 27 ; do
[ $code = $c ] && return [ $code = $c ] && {
report_append "ipv${IPV} $4 $1 : test aborted, no reason to continue. curl code $(curl_translate_code $code)"
return
}
done done
echo echo
@ -807,6 +862,7 @@ sigpipe()
exit 1 exit 1
} }
check_system check_system
check_prerequisites check_prerequisites
require_root require_root
@ -814,6 +870,7 @@ check_dns
ask_params ask_params
PID= PID=
NREPORT=
trap sigint INT trap sigint INT
trap sigpipe PIPE trap sigpipe PIPE
for dom in $DOMAINS; do for dom in $DOMAINS; do
@ -827,4 +884,8 @@ done
trap - PIPE trap - PIPE
trap - INT trap - INT
echo
echo \* SUMMARY
report_print
exitp 0 exitp 0