mirror of
https://github.com/bol-van/zapret.git
synced 2024-11-26 20:20:53 +03:00
blockcheck: verbose output in ip block tests
This commit is contained in:
parent
04e8106b98
commit
b23b98a14b
@ -575,22 +575,29 @@ curl_test_http()
|
|||||||
# $1 - ip version : 4/6
|
# $1 - ip version : 4/6
|
||||||
# $2 - domain name
|
# $2 - domain name
|
||||||
# $3 - subst ip
|
# $3 - subst ip
|
||||||
|
# $4 - "detail" - detail info
|
||||||
|
|
||||||
local code loc
|
local code loc
|
||||||
curl_probe $1 $2 $HTTP_PORT "$3" -SsD "$HDRTEMP" -A "$USER_AGENT" --max-time $CURL_MAX_TIME $CURL_OPT "http://$2" -o /dev/null 2>&1 || {
|
curl_probe $1 $2 $HTTP_PORT "$3" -SsD "$HDRTEMP" -A "$USER_AGENT" --max-time $CURL_MAX_TIME $CURL_OPT "http://$2" -o /dev/null 2>&1 || {
|
||||||
code=$?
|
code=$?
|
||||||
rm -f "$HDRTEMP"
|
rm -f "$HDRTEMP"
|
||||||
return $code
|
return $code
|
||||||
}
|
}
|
||||||
code=$(hdrfile_http_code "$HDRTEMP")
|
if [ "$4" = "detail" ] ; then
|
||||||
[ "$code" = 301 -o "$code" = 302 -o "$code" = 307 -o "$code" = 308 ] && {
|
head -n 1 "$HDRTEMP"
|
||||||
loc=$(hdrfile_location "$HDRTEMP")
|
grep "^[lL]ocation:" "$HDRTEMP"
|
||||||
echo "$loc" | grep -qE "^https?://.*$2(/|$)" ||
|
else
|
||||||
echo "$loc" | grep -vqE '^https?://' || {
|
code=$(hdrfile_http_code "$HDRTEMP")
|
||||||
echo suspicious redirection $code to : $loc
|
[ "$code" = 301 -o "$code" = 302 -o "$code" = 307 -o "$code" = 308 ] && {
|
||||||
rm -f "$HDRTEMP"
|
loc=$(hdrfile_location "$HDRTEMP")
|
||||||
return 254
|
echo "$loc" | grep -qE "^https?://.*$2(/|$)" ||
|
||||||
|
echo "$loc" | grep -vqE '^https?://' || {
|
||||||
|
echo suspicious redirection $code to : $loc
|
||||||
|
rm -f "$HDRTEMP"
|
||||||
|
return 254
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
fi
|
||||||
rm -f "$HDRTEMP"
|
rm -f "$HDRTEMP"
|
||||||
[ "$code" = 400 ] && {
|
[ "$code" = 400 ] && {
|
||||||
# this can often happen if the server receives fake packets it should not receive
|
# this can often happen if the server receives fake packets it should not receive
|
||||||
@ -820,25 +827,28 @@ curl_test()
|
|||||||
# $1 - test function
|
# $1 - test function
|
||||||
# $2 - domain
|
# $2 - domain
|
||||||
# $3 - subst ip
|
# $3 - subst ip
|
||||||
|
# $4 - param of test function
|
||||||
local code=0 n=0
|
local code=0 n=0
|
||||||
|
|
||||||
while [ $n -lt $REPEATS ]; do
|
while [ $n -lt $REPEATS ]; do
|
||||||
n=$(($n+1))
|
n=$(($n+1))
|
||||||
[ $REPEATS -gt 1 ] && printf "[attempt $n] "
|
[ $REPEATS -gt 1 ] && printf "[attempt $n] "
|
||||||
if $1 "$IPV" $2 $3 ; then
|
if $1 "$IPV" $2 $3 "$4" ; then
|
||||||
[ $REPEATS -gt 1 ] && echo 'AVAILABLE'
|
[ $REPEATS -gt 1 ] && echo 'AVAILABLE'
|
||||||
else
|
else
|
||||||
code=$?
|
code=$?
|
||||||
[ "$SCANLEVEL" = quick ] && break
|
[ "$SCANLEVEL" = quick ] && break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ $code = 254 ]; then
|
[ "$4" = detail ] || {
|
||||||
echo "UNAVAILABLE"
|
if [ $code = 254 ]; then
|
||||||
elif [ $code = 0 ]; then
|
echo "UNAVAILABLE"
|
||||||
echo '!!!!! AVAILABLE !!!!!'
|
elif [ $code = 0 ]; then
|
||||||
else
|
echo '!!!!! AVAILABLE !!!!!'
|
||||||
echo "UNAVAILABLE code=$code"
|
else
|
||||||
fi
|
echo "UNAVAILABLE code=$code"
|
||||||
|
fi
|
||||||
|
}
|
||||||
return $code
|
return $code
|
||||||
}
|
}
|
||||||
ws_curl_test()
|
ws_curl_test()
|
||||||
@ -1236,7 +1246,7 @@ check_dpi_ip_block()
|
|||||||
echo
|
echo
|
||||||
echo "- IP block tests (requires manual interpretation)"
|
echo "- IP block tests (requires manual interpretation)"
|
||||||
|
|
||||||
echo "testing $UNBLOCKED_DOM on it's original ip"
|
echo "> testing $UNBLOCKED_DOM on it's original ip"
|
||||||
if curl_test $1 $UNBLOCKED_DOM; then
|
if curl_test $1 $UNBLOCKED_DOM; then
|
||||||
unblocked_ip=$(mdig_resolve $IPV $UNBLOCKED_DOM)
|
unblocked_ip=$(mdig_resolve $IPV $UNBLOCKED_DOM)
|
||||||
[ -n "$unblocked_ip" ] || {
|
[ -n "$unblocked_ip" ] || {
|
||||||
@ -1244,13 +1254,13 @@ check_dpi_ip_block()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "testing $blocked_dom on $unblocked_ip ($UNBLOCKED_DOM)"
|
echo "> testing $blocked_dom on $unblocked_ip ($UNBLOCKED_DOM)"
|
||||||
curl_test $1 $blocked_dom $unblocked_ip
|
curl_test $1 $blocked_dom $unblocked_ip detail
|
||||||
|
|
||||||
blocked_ips=$(mdig_resolve_all $IPV $blocked_dom)
|
blocked_ips=$(mdig_resolve_all $IPV $blocked_dom)
|
||||||
for blocked_ip in $blocked_ips; do
|
for blocked_ip in $blocked_ips; do
|
||||||
echo "testing $UNBLOCKED_DOM on $blocked_ip ($blocked_dom)"
|
echo "> testing $UNBLOCKED_DOM on $blocked_ip ($blocked_dom)"
|
||||||
curl_test $1 $UNBLOCKED_DOM $blocked_ip
|
curl_test $1 $UNBLOCKED_DOM $blocked_ip detail
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo $UNBLOCKED_DOM is not available. skipping this test.
|
echo $UNBLOCKED_DOM is not available. skipping this test.
|
||||||
|
Loading…
Reference in New Issue
Block a user