#!/usr/bin/env bash # Print every CyberLux hidden-service URL (reads /var/lib/tor/*/hostname). # Tor creates these files — not Next.js. Use sudo if not readable as your user. # # bash scripts/list-onion-urls.sh # sudo bash scripts/list-onion-urls.sh # set -euo pipefail REPO="$(cd "$(dirname "$0")/.." && pwd)" TOR_DIRS="${REPO}/scripts/generated/tor-dirs.txt" if [[ ! -f "${TOR_DIRS}" ]]; then echo "Missing ${TOR_DIRS}. Run: cd ${REPO} && node scripts/generate-onion-config.cjs" exit 1 fi read_host() { local f="$1" if [[ -r "${f}" ]]; then tr -d '\n' < "${f}" elif command -v sudo >/dev/null 2>&1 && sudo test -r "${f}" 2>/dev/null; then sudo tr -d '\n' < "${f}" else echo "" fi } echo "" echo "CyberLux .onion URLs (http:// only — open in Tor Browser)" echo "────────────────────────────────────────────────────────────" ready=0 while IFS= read -r d || [[ -n "${d}" ]]; do [[ -z "${d}" ]] && continue f="/var/lib/tor/${d}/hostname" host="$(read_host "${f}")" if [[ -n "${host}" ]]; then printf '%-28s http://%s\n' "${d}" "${host}" ((ready++)) || true else printf '%-28s (no hostname yet — %s)\n' "${d}" "${f}" fi done < "${TOR_DIRS}" echo "────────────────────────────────────────────────────────────" if [[ "${ready}" -eq 0 ]] && [[ -f "${REPO}/onion-urls.txt" ]]; then echo "" echo "Could not read /var/lib/tor (permission). Last exported list:" echo "────────────────────────────────────────────────────────────" grep -vE '^#|^$' "${REPO}/onion-urls.txt" 2>/dev/null | head -120 || true echo "" echo "Refresh: sudo bash ${REPO}/scripts/export-onion-urls.sh" elif [[ "${ready}" -eq 0 ]]; then echo "" echo "No hostnames resolved. Ensure Tor is running and keys exist under /var/lib/tor/," echo "or run: sudo bash ${REPO}/scripts/export-onion-urls.sh" fi echo ""