Browse Source

test if removed hosts are still online

master
nervuri 2 months ago
parent
commit
c45f58fd20
Signed by: nervuri GPG Key ID: C4769EEA7BA61672
  1. 29
      get-hosts.sh

29
get-hosts.sh

@ -68,6 +68,35 @@ if [ -z "$hosts" ]; then
exit 1
fi
# Save to temporary file.
tempfile=$(mktemp)
echo "$hosts" > "$tempfile"
# Delete temporary file on exit.
finish() {
rm -f "$tempfile"
}
trap finish EXIT
# Test if removed hosts are still online.
echo "Testing removed hosts..."
for removed_host in $(diff hosts "$tempfile" | grep ^\< | cut -c 3-); do
printf "%s" "$removed_host"
# If direct connection fails, try to connect through Tor.
if agunua --no-tofu --maximum-time 20 "$removed_host" >/dev/null 2>&1 || \
agunua --socks 127.0.0.1:9050 --no-tofu --maximum-time 20 "$removed_host" >/dev/null 2>&1; then
echo " - ONLINE"
# Add removed host back.
hosts="$hosts
$removed_host"
else
echo " - offilne"
fi
done
# Sort entries again.
hosts=$(echo "$hosts" | sort)
# Save to file.
echo "$hosts" > hosts

Loading…
Cancel
Save