Compare commits

...

2 Commits

Author SHA1 Message Date
nervuri c45f58fd20
test if removed hosts are still online 2021-09-24 15:18:34 +03:00
nervuri c46eb8b3d0
remove --insecure flag from agunua commands
No longer required, since version 1.5.
2021-09-24 12:35:45 +03:00
1 changed files with 31 additions and 4 deletions

View File

@ -14,16 +14,14 @@ cd "$(dirname "$0")" || exit
# If Agunua is installed, use it.
if command -v agunua >/dev/null; then
# Using Agunua is more secure, because it does certificate pinning.
# The --insecure option just makes it accept certificates that are
# not signed by a (known) CA.
hosts1=$(agunua --insecure --binary --maximum-time 20 \
hosts1=$(agunua --binary --maximum-time 20 \
gemini://geminispace.info/known-hosts 2>/dev/null \
| grep "gemini://" | cut -d ' ' -f 3)
if [ -z "$hosts1" ]; then
>&2 echo "geminispace.info/known-hosts download failed."
exit 1
fi
hosts2=$(agunua --insecure --binary --maximum-time 20 \
hosts2=$(agunua --binary --maximum-time 20 \
gemini://gemini.bortzmeyer.org/software/lupa/lupa-capsules.txt 2>/dev/null)
if [ -z "$hosts2" ]; then
>&2 echo "lupa-capsules.txt download failed."
@ -70,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