From f2f80cfa038de52061dbac54014dfed69fcc9949 Mon Sep 17 00:00:00 2001 From: wander Date: Fri, 6 Feb 2026 21:03:29 -0500 Subject: [PATCH] ERM excuse me? wheres tor at? =vanguard probably --- assets/entrypoint.sh | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/assets/entrypoint.sh b/assets/entrypoint.sh index 5271f21..61c4c44 100755 --- a/assets/entrypoint.sh +++ b/assets/entrypoint.sh @@ -2,12 +2,41 @@ set -e # --- Configuration --- -# Check if command is passed # If the first argument is 'vanguards', skip Tor setup and just run vanguards if [ "$1" = "vanguards" ]; then echo "Starting Vanguards Sidecar Mode..." shift # remove 'vanguards' from the arguments - exec vanguards "$@" + + # Extract the hostname from the arguments? + # For now, we assume 'tor-service' as per the standard docker-compose setup + TARGET_HOST="tor-service" + TARGET_PORT=9051 + + echo "Waiting for Tor Control Port at $TARGET_HOST:$TARGET_PORT..." + while ! nc -z "$TARGET_HOST" "$TARGET_PORT"; do + sleep 1 + done + echo "Tor is awake! Resolving IP..." + + # Fix for ValueError: Invalid IP address + # stem/vanguards requires a valid IP, not a hostname + TARGET_IP=$(python3 -c "import socket; print(socket.gethostbyname('$TARGET_HOST'))") + echo "Resolved $TARGET_HOST to $TARGET_IP" + + # Replace hostname with IP in arguments + # Note: This crude replacement assumes 'tor-service' is passed as an arg + args="" + for arg in "$@"; do + if [ "$arg" = "$TARGET_HOST" ]; then + args="$args $TARGET_IP" + else + args="$args $arg" + fi + done + + # Execute with new args (unquoted expansion nicely splits args here, + # safe enough for this specific use case of rigid flags) + exec vanguards $args fi # If other arguments are passed, exec them (fallback)