Commit f7d0ab65 authored by Vitaly Lipatov's avatar Vitaly Lipatov

check_system: add check-blocked.sh for testing site access through gateways

Tests site availability and download speed through different egw/ogw gateways via their SOCKS5 proxies. Uses eget --check-url and --speedtest. Default sites: instagram.com, facebook.com, youtube.com, rutracker.org, flibusta.is. Gateway list is easily extensible. Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent d192466d
#!/bin/sh
# Check if sites are blocked/throttled through different gateways
# Usage: check-blocked.sh [site...]
# Without arguments checks the default site list.
#
# Tests each site through configured gateways via SOCKS5 proxies
# (microsocks :1080 on each egw/ogw container).
# Two-step check: availability (eget --check-url), then speed (eget --speedtest).
#
# Verdicts per gateway:
# OK(speed) — available, speed > 0 MB/s
# SLOW(speed) — available, speed < 0.10 MB/s (throttled)
# BLOCK — unavailable (connection refused / timeout)
# FAIL — eget error
EGET="epm tool eget"
# Gateway list: name and SOCKS5 proxy URL
# Extend this list as needed.
# "direct" = no proxy (default route of this machine).
GATEWAYS="
direct
gre.hetzner socks5h://91.232.225.122:1080
gre.beget socks5h://91.232.225.124:1080
ikev2.beget socks5h://91.232.225.130:1080
"
# Default sites to check
DEFAULT_SITES="instagram.com facebook.com youtube.com rutracker.org flibusta.is"
SLOW_THRESHOLD="0.10" # MB/s — below this is "throttled"
TIMEOUT=15
# ---------------------------------------------------------------
TMPFILE=$(mktemp)
trap 'rm -f "$TMPFILE"' EXIT
# Run eget with optional SOCKS5 proxy
# Usage: run_eget [proxy_url] [eget_args...]
run_eget()
{
local proxy="$1"
shift
if [ -n "$proxy" ] ; then
EGET_BACKEND=curl ALL_PROXY="$proxy" timeout "$TIMEOUT" $EGET "$@"
else
timeout "$TIMEOUT" $EGET "$@"
fi
}
# Parse gateway list into arrays
gw_count=0
while IFS=' ' read -r name proxy ; do
[ -z "$name" ] && continue
eval "gw_name_$gw_count=\"$name\""
eval "gw_proxy_$gw_count=\"$proxy\""
gw_count=$((gw_count + 1))
done <<EOF
$(echo "$GATEWAYS" | sed '/^$/d')
EOF
# Determine sites
sites="${*:-$DEFAULT_SITES}"
# Print banner
hostname=$(hostname -f 2>/dev/null || hostname)
printf "Site availability & download speed test from %s\n" "$hostname"
printf "Gateways: SOCKS5 proxies on egw/ogw containers (microsocks :1080)\n\n"
# Print header
printf "%-20s" "site"
i=0
while [ "$i" -lt "$gw_count" ] ; do
eval "name=\$gw_name_$i"
printf " %-14s" "$name"
i=$((i + 1))
done
printf "\n"
# Separator
printf "%-20s" "--------------------"
i=0
while [ "$i" -lt "$gw_count" ] ; do
printf " %-14s" "--------------"
i=$((i + 1))
done
printf "\n"
# Check each site
for site in $sites ; do
url="https://$site/"
printf "%-20s" "$site"
i=0
while [ "$i" -lt "$gw_count" ] ; do
eval "proxy=\$gw_proxy_$i"
# Step 1: availability
if run_eget "$proxy" --check-url "$url" >/dev/null 2>&1 ; then
# Step 2: speed
speed=$(run_eget "$proxy" --speedtest --tsv "$url" 2>/dev/null | cut -f2)
[ -z "$speed" ] && speed="0.00"
# Compare with threshold (using awk for float comparison)
is_slow=$(echo "$speed $SLOW_THRESHOLD" | awk '{print ($1 < $2) ? 1 : 0}')
if [ "$is_slow" = "1" ] ; then
cell="SLOW($speed)"
else
cell="OK($speed)"
fi
else
cell="BLOCK"
fi
printf " %-14s" "$cell"
i=$((i + 1))
done
printf "\n"
done
echo
echo "Legend: OK(N) = available, N MB/s download speed"
echo " SLOW(N) = available but speed < ${SLOW_THRESHOLD} MB/s (throttled)"
echo " BLOCK = connection failed (blocked or down)"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment