From fcf1be52ac38fbfc64eed766bdcf26f247504469 Mon Sep 17 00:00:00 2001 From: Mariusz Kogen Date: Wed, 13 Sep 2023 20:25:00 +0200 Subject: [PATCH] Add tor-check to CLI (#2412) * Link tor-check * Add tor-check.sh * Improve code readability * Link tor-check from postinst --- build/lib/scripts/postinst | 1 + build/lib/scripts/tor-check.sh | 36 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 build/lib/scripts/tor-check.sh diff --git a/build/lib/scripts/postinst b/build/lib/scripts/postinst index d811d726a..2b0e09a12 100755 --- a/build/lib/scripts/postinst +++ b/build/lib/scripts/postinst @@ -99,6 +99,7 @@ CookieAuthentication 1 EOF rm -rf /var/lib/tor/* +ln -sf /usr/lib/embassy/scripts/tor-check.sh /usr/bin/tor-check echo "fs.inotify.max_user_watches=1048576" > /etc/sysctl.d/97-embassy.conf diff --git a/build/lib/scripts/tor-check.sh b/build/lib/scripts/tor-check.sh new file mode 100755 index 000000000..f434cf8a7 --- /dev/null +++ b/build/lib/scripts/tor-check.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +fail=$(printf " [\033[31m fail \033[0m]") +pass=$(printf " [\033[32m pass \033[0m]") + +onion_list=( + "Start9|http://privacy34kn4ez3y3nijweec6w4g54i3g54sdv7r5mr6soma3w4begyd.onion" + "Mempool|http://mempoolhqx4isw62xs7abwphsq7ldayuidyx2v2oethdhhj6mlo2r6ad.onion" + "DuckDuckGo|https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion" + "Brave Search|https://search.brave4u7jddbv7cyviptqjc7jusxh72uik7zt6adtckl5f4nwy2v72qd.onion" +) + +# Check if ~/.startos/tor-check.list exists and read its contents if available +if [ -f ~/.startos/tor-check.list ]; then + while IFS= read -r line; do + # Check if the line starts with a # + if [[ ! "$line" =~ ^# ]]; then + onion_list+=("$line") + fi + done < ~/.startos/tor-check.list +fi + +echo "Testing connection to Onion Pages ..." + +for data in "${onion_list[@]}"; do + name="${data%%|*}" + url="${data#*|}" + if curl --socks5-hostname localhost:9050 "$url" > /dev/null 2>&1; then + echo " ${pass}: $name ($url) " + else + echo " ${fail}: $name ($url) " + fi +done + +echo +echo "Done."